Thank you. That makes sense. I took your advice and created this template
<xsl:template match="*" mode="fragment">
<xsl:element name="{local-name()}">
<xsl:value-of select="." />
<xsl:apply-templates select="*" mode="fragment" />
</xsl:element>
</xsl:template>
Now from another template that processes the atom feed item I call it
like this:
<xsl:when test="@type='xhtml' or @type =
'application/xhtml+xml'">
<fragment>
<xsl:apply-templates mode="fragment"
select="xhtml:div" />
</fragment>
</xsl:when>
<xsl:when test="@type='html' or @type = 'text/html'">
<xsl:value-of select="." />
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="normalize-space()" />
</xsl:otherwise>
IT works well now!
Michael Kay wrote:
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>
--~--