xsl-list
[Top] [All Lists]

RE: [xsl] how to exclude namespaces from copy-of

2009-11-05 10:27:34

Although xsl:copy-of in XSLT 2.0 can exclude unused namespaces
(copy-namespaces="no"), it can't remove declarations of namespaces that are
actually in use. You don't actually want to make a copy of the data, you
want to transform it by changing the names of the elements. Remember that
the difference between <rss/> and <rss xmlns="xyz"/> is not just a namespace
declaration - the two elements have different names. So you need to do a
"renaming identity transform" along the lines

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

Regards,

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

-----Original Message-----
From: cert21 [mailto:cert21(_at_)ptd(_dot_)net] 
Sent: 05 November 2009 15:13
To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
Subject: [xsl] how to exclude namespaces from copy-of

Hello!

I am trying to parse the atom feed using the xsl template.

The item in the feed contains this element: (example) <div 
xmlns="http://www.w3.org/1999/xhtml"; 
xmlns:dc="http://purl.org/dc/elements/1.1/"; 
xmlns:thr="http://purl.org/syndication/thread/1.0";>
<p>
October and November are busy months for Amazon Web 
Services!</p> </div>

I want to copy the div with all its child elements, so I use 
copy-of The problem is that I don't want the 
xmlns="http://www.w3.org/1999/xhtml";
or xmlns:dc or any other extra data in the div attribute

I just want the result to be
<div>
<p>
October and November are busy months for Amazon Web 
Services!</p> </div>

How can I do this?

Thank you.

--~------------------------------------------------------------------
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>