xsl-list
[Top] [All Lists]

RE: [xsl] Removing the namespace in the output tags

2007-10-03 02:56:31
In your input, the p element is in the XHTML namespace. In the output, you
want it to be in a different namespace (technically, in no namespace). So
you can't copy the element, you have to rename it (because the namespace is
part of the name). The same applies to all its descendants. You can do this
with a modified version of the identity template:

<xsl:template match="*">
  <xsl:element name="{local-name()}" namespace="">
    <xsl:copy-of select="@*"/>
    <xsl:apply-templates/>
  </xsl:element>
</xsl:template>

Michael Kay
http://www.saxonica.com/ 

-----Original Message-----
From: Thangavelu Srinivasan [mailto:vasantry(_at_)gmail(_dot_)com] 
Sent: 03 October 2007 10:17
To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
Subject: [xsl] Removing the namespace in the output tags

Hi Folks

INPUT:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE NewsML SYSTEM 
"http://idsdat06.reuters.com/newsml/NewsMLv1.0.dtd " [ 
<!ENTITY % xhtml SYSTEM 
"http://idsdat06.reuters.com/newsml/xhtml1-strict.dtd";>
%xhtml;
]>
<NewsML Duid="165_NEWSML">
<ContentItem>
<DataContent>
<html xmlns="http://www.w3.org/1999/xhtml";>
<head>
<title/>
</head>
<body>
<p>  (Adds company news, index futures and analyst 
comment)</p> <p> Early signs of improving confidence in the 
markets were crushed by comments from Countrywide Financial 
&lt;CFC.N&gt; Chief Executive Angelo Mozilo, who said on 
Thursday the housing downturn could drag the U.S. economy 
into recession.</p> <p> New home sales data at 1400 GMT may 
provide further clues about the state of the housing sector. 
Click on [ID:nN22401142]</p> <p> For related news, double 
click on [BASF.DE-E]</p> </body> </html> </DataContent> 
</ContentItem> </NewsML>


My XSL:

<xsl:stylesheet version=" 1.1"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
xmlns:str="http://exslt.org/strings";
xmlns:xhtml=" http://www.w3.org/1999/xhtml";
xmlns:libxslt="http://xmlsoft.org/XSLT/namespace";
exclude-result-prefixes="xhtml">
<xsl:template match="NewsML">
<story_text deepcopy='yes'><xsl:copy-of
select="ContentItem/DataContent/xhtml:html/xhtml:body/*"/></st
ory_text>
</xsl:template>
</xsl:stylesheet>



OUTPUT:

<story_text><p xmlns="http://www.w3.org/1999/xhtml";>  (Adds 
company news, index futures and analyst comment)</p> <p 
xmlns="http://www.w3.org/1999/xhtml";> Early signs of 
improving confidence in the markets were crushed by comments 
from Countrywide Financial &lt;CFC.N&gt; Chief Executive 
Angelo Mozilo, who said on Thursday the housing downturn 
could drag the U.S. economy into recession.</p> <p 
xmlns="http://www.w3.org/1999/xhtml";> New home sales data at 
1400 GMT may provide further clues about the state of the 
housing sector. Click on [ID:nN22401142]</p> <p 
xmlns="http://www.w3.org/1999/xhtml";> For related news, 
double click on [BASF.DE-E]</p></story_text>


Question:

How to remove the namespace from the p tags for the output 
through XSL. Is there any syntax error in XSL.

Any suggestions are welcome

Thanks and Regards
Srinivas

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: 
<mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--



--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--

<Prev in Thread] Current Thread [Next in Thread>