Subject: RE: [xsl] xml to xml with a xmlns schema reference From: "Julian Reschke" <julian.reschke@xxxxxx> Date: Sat, 4 May 2002 11:30:34 +0200 |
Hi. 1) You need to place all result elements into the same namespace. The easiest way to do this is to simply declare the namespace globally in the XSLT, for instance: <?xml version="1.0" encoding="ISO-8859-1"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns="x-schema:DD_16394.xml"> <xsl:output method="xml" indent="yes"/> <xsl:template match="/cabinet"> <XML_DATA_ISLAND_LOCATION> <xsl:apply-templates select="report"/> </XML_DATA_ISLAND_LOCATION> </xsl:template> <xsl:template match="report"> <report> <finishday> <xsl:value-of select="datefinish/day"/> </finishday> <finishmonth> <xsl:value-of select="datefinish/month"/> </finishmonth> <finishyear> <xsl:value-of select="datefinish/year"/> </finishyear> </report> </xsl:template> </xsl:stylesheet> 2) "x-schema:DD_16394.xml" is an extremly poor choice for a namespace name, as the URI scheme "x-schema" is proprietary to Microsoft. It's not a good idea to wire a namespace name (which should never change unless the vocabulary changes) directly to a vendor-specific URI schema or even a particular XDR file. Julian > -----Original Message----- > From: owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx > [mailto:owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx]On Behalf Of Ian Hord > Sent: Saturday, May 04, 2002 11:11 AM > To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx > Subject: [xsl] xml to xml with a xmlns schema reference > > > 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 > XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] xml to xml with a xmlns schem, Ian Hord | Thread | [xsl] Sorting XML with XSL, output , Ernst Wolthaus |
[xsl] xml to xml with a xmlns schem, Ian Hord | Date | Re: [xsl] data translation => desce, Joerg Heinicke |
Month |