[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: how to exclude namespaces from copy-of

Subject: Re: how to exclude namespaces from copy-of
From: cert21 <cert21@xxxxxxx>
Date: Thu, 05 Nov 2009 10:52:39 -0500
Re:  how to exclude namespaces from copy-of
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@xxxxxxx] Sent: 05 November 2009 15:13
To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Subject: 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.

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.