You're expressing your problem in the wrong terms. Your problem isn't
the xmlns declaration, your problem is that you have generated an
element called (www.myhome.com, Transaction) when you wanted to generate
an element called (~, Transaction), where ~ represents the null
namespace. In other words, you want to change the name of the element,
but your stylesheet has left it unchanged - always remember that the
name has two components, the namespace URI and the local name.
If you are changing the names of the elements, you are transforming them
not copying them. Create a new element instead of using xsl:copy, by
writing <xsl:element name="local-name()" namespace="">.
Since your stylesheet has no literal result elements, you will then find
that the unused namespace declaration magically disappears from the
output.
Michael Kay
-----Original Message-----
From: owner-xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
[mailto:owner-xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com] On Behalf Of
Abhijit Junnare
Sent: 07 October 2003 21:44
To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
Subject: [xsl] Copying nodes from source XML to the result tree
I am trying to copy nodes from the source XML to the
output generated using XSL.
My problem is that all the nodes that I copy have the
namespace attribute attached with them. I am wondering
if there is any alternative to get rid of the
namespace attribute.
Here is my sample code.
INPUT XML
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="temp.xsl"?>
<AssembleRequest xmlns="www.myhome.com">
<Transaction>
<TransactionID>111</TransactionID>
</Transaction>
</AssembleRequest>
STYLEHSEET
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:fo="http://www.w3.org/1999/XSL/Format"
xmlns:temp="www.myhome.com"
<xsl:output method="xml" version="1.0"
encoding="UTF-8" indent="yes"/>
<xsl:template match="/">
<xsl:apply-templates
select="temp:AssembleRequest"/>
</xsl:template>
<xsl:template match="temp:AssembleRequest" >
<xsl:element name="TransData">
<xsl:apply-templates/>
</xsl:element>
</xsl:template>
<xsl:template match="temp:Transaction">
<xsl:copy/>
<xsl:copy-of select="node()"/>
</xsl:template>
OUTPUT
<?xml version="1.0" encoding="UTF-8"?>
<TransData>
<Transaction xmlns="www.myhome.com" />
<TransactionID
xmlns="www.myhome.com">111</TransactionID>
</TransData>
Is there a way to get rid of the xmlns attribute on
the Trasaction and TransactionID elements.
Also is there a FAQ on copying source nodes to the
result tree using XSL.
Any help is appreciated.
Thanks
__________________________________
Do you Yahoo!?
The New Yahoo! Shopping - with improved product search
http://shopping.yahoo.com
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list