This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
xml to xml with a xmlns schema reference
- From: "Ian Hord" <ian at hord dot com>
- To: <xsl-list at lists dot mulberrytech dot com>
- Date: Sat, 4 May 2002 19:10:45 +1000
- Subject: [xsl] xml to xml with a xmlns schema reference
- Reply-to: xsl-list at lists dot mulberrytech dot com
Hi all,
I am pretty new to xslt and trying to produce xml from another xml. I am
putting a reference in to the new xml file root element for a schema, which
works, but get an empty namespace reference in the child element.
I am using xmlspy with internet explorer 6.0.26 for transformations.
What is going wrong any suggestions?
Thanks in advance,
Ian.
The xml is..
<?xml version="1.0" encoding="ISO-8859-1"?>
<!-- edited with XML Spy v3.0.7 (http://www.xmlspy.com) by ianhord
(private) -->
<!DOCTYPE cabinet SYSTEM "C:\My
Documents\projectdevelopment\xmldocs\cabinet.dtd">
<?xml-stylesheet type="text/xsl" href="C:\My
Documents\projectdevelopment\xmldocs\cabnettoloclist2.xsl"?>
<cabinet>
<report>
<reportid>001</reportid>
<datestart>
<day>1</day>
<month>February</month>
<year>1990</year>
</datestart>
<datefinish>
<day>1</day>
<month>2</month>
<year>98</year>
</datefinish>
<report>
<cabinet>
the stylesheet is ..
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform" >
<xsl:output method="xml" indent="yes"/>
<xsl:template match="/cabinet">
<xsl:element name="XML_DATA_ISLAND_LOCATION"
namespace="x-schema:DD_16394.xml"> <xsl:apply-templates select="report"/>
</xsl:element>
</xsl:template>
<xsl:template match="report">
<xsl:element name="report">
<xsl:element name="finishday">
<xsl:value-of select="datefinish/day"/>
</xsl:element>
<xsl:element name="finishmonth">
<xsl:value-of select="datefinish/month"/>
</xsl:element>
<xsl:element name="finishyear">
<xsl:value-of select="datefinish/year"/>
</xsl:element>
</xsl:element>
</xsl:template>
</xsl:stylesheet>
The output is..
<?xml version="1.0" encoding="UTF-16"?>
<XML_DATA_ISLAND_LOCATION xmlns="x-schema:DD_16394.xml">
<report xmlns="">
<finishday>1</finishday>
<finishmonth>2</finishmonth>
<finishyear>98</finishyear>
</report>
</XML_DATA_ISLAND_LOCATION>
the output I want is...
<?xml version="1.0" encoding="UTF-16"?>
<XML_DATA_ISLAND_LOCATION xmlns="x-schema:DD_16394.xml">
<report>
<finishday>1</finishday>
<finishmonth>2</finishmonth>
<finishyear>98</finishyear>
</report>
</XML_DATA_ISLAND_LOCATION>
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list