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

possible to use copy-of without namespace

Subject: possible to use copy-of without namespace
From: Thomas Brand <brand@xxxxxxxxx>
Date: Wed, 08 Jan 2003 05:03:22 +0100
copy of xmlns

Hello dear reader,


i try to get a 1:1 copy of a tree (using xsl:copy-of) without having the xmlns attribute set in the root node of the result tree.

http://www.w3.org/TR/xslt#copy-of says "copying an element node copies the attribute nodes, namespace nodes and children of the element node as well as the element node itself"

Is there a possibility to avoid the xmlns attribute added?

In the following, i have a simple document b.xml which is transformed with a.xsl:

b.xml ---

<?xml-stylesheet type="text/xsl" href="a.xsl"?>
<ans:mydoc xmlns:ans="http://www.someurl.com/a" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">


<ans:anode>anodevalue1</ans:anode>

        <somenode>
                <![CDATA[
                <somechildnode>childvalue1</somechildnode>
                ]]>
        </somenode>

        <anothernode>
                <anotherchildnode>anotherchildvalue1</anotherchildnode>
        </anothernode>

</ans:mydoc>

a.xsl ---

<?xml version="1.0" encoding="ISO-8859-1"?>

<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:ans="http://www.someurl.com/a" exclude-result-prefixes="ans"
version="1.0">

<xsl:output method="xml" encoding="iso-8859-1" indent="yes" omit-xml-declaration="no"/>

<xsl:template match="ans:mydoc">
<xsl:element name="result">
<xsl:copy-of select="ans:anode" />
<xsl:value-of select="somenode" disable-output-escaping="yes"/>
<xsl:copy-of select="anothernode"/>
</xsl:element>
</xsl:template>


</xsl:stylesheet>

---

the result is:

<?xml version="1.0" encoding="iso-8859-1"?>
<result>
<ans:anode xmlns:ans="http://www.someurl.com/a" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">anodevalue1</ans:anode>


<somechildnode>childvalue1</somechildnode> <!-- how it should be -->

<anothernode xmlns:ans="http://www.someurl.com/a" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<anotherchildnode>anotherchildvalue1</anotherchildnode>
</anothernode>
</result>


---

The best result I get is by using <![CDATA[ ]]> in b.xml, and then take it as a string (xsl:value-of), and printing it out with disable-output-escaping="yes". This produces the desired output, but it is not a very good solution.

I think there must be a way to avoid the xmlns attributes to show up..

Any help is very appreciated

Regards,
 Thomas Brand


XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list



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.