I don't understand exactly what is the 'xmlns' attribute, nor why it have
problems with the xmlns attribute of the sylesheet, but I need it in
my output XML file. Could anybody tell me how to transform this input:
<ROOT-ELEMENT>
<SOHN>...</SOHN>
</ROOT-ELEMENT>
in this output:
<ROOT-ELEMENT xmlns="http://www.whatever">
<SOHN>...</SOHN>
</ROOT-ELEMENT>
Thanks a lot of,
Rgf
The xmlns attribute is how you associate an xml tag with an xml namespace.
Some namespaces are pre-defined by the w3c (World Wide Web Consortium) and
MUST be referenced correctly or your xml parser won't know what the special
tags in that namespace mean.
"Rosa Mª Gómez Flores" <fili...@auna.com> wrote in message
news:%23MzbszC...@TK2MSFTNGP11.phx.gbl...
> <ROOT-ELEMENT>
> <xsl:attribute name="xmlns">http://www.whatever.com</xsl:attribute>
> </ROOT-ELEMENT>
This won't work. xmlns (namespace declaration) is not treated as
attribute in XPath/XSLT data model, so one cannot create namespace
declaration using xsl:attribute instruction, see
http://www.w3.org/TR/xslt#creating-attributes
The solution is to use xsl:element instruction to create new elements in
the namespace.
--
Oleg Tkachenko
http://www.tkachenko.com/blog
Multiconn Technologies, Israel
Try an identity transform with a default output namespace, something like...
<?xml version="1.0"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns="http://www.whatever">
<xsl:output method="xml"/>
<xsl:template match="/">
<xsl:apply-templates/>
</xsl:template>
<xsl:template match="*">
<xsl:element name="{name()}">
<xsl:apply-templates select="@* | node()"/>
</xsl:element>
</xsl:template>
<xsl:template match="@* | comment() | text() | processing-instruction()">
<xsl:copy/>
</xsl:template>
</xsl:stylesheet>
Hope this helps
Marrow
http://www.marrowsoft.com - home of Xselerator (XSLT IDE and debugger)
http://www.topxml.com/Xselerator
"Rosa Mª Gómez Flores" <fili...@auna.com> wrote in message
news:%23MzbszC...@TK2MSFTNGP11.phx.gbl...