S
Si
Hi,
I have a xml dataset I'd like to order, and save in that
order. I've written an xsl to do the transformation, but
because the xml file has a xsd namespace, it doesn't work.
A cutdown version of the xml file looks like this:
<?xml version="1.0" standalone="yes"?>
<hsPrinters xmlns:xsi="http://www.w3.org/2001/XMLSchema-
instance" xmlns="http://tempuri.org/printer.xsd">
<city>
<code>LN</code>
<name>London</name>
<comment>Herbert Smith London Offices</comment>
</city>
<city>
<code>PA</code>
<name>Paris</name>
<comment>Herbert Smith Paris Offices</comment>
</city>
<city>
<code>BR</code>
<name>Brussels</name>
<comment>Brussels Offices</comment>
</city>
<city>
<code>MW</code>
<name>Moscow</name>
<comment>Moscow Office</comment>
</city>
</hsPrinters>
This is the xsl:
<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">
<xsl:template match="hsPrinters">
<hsPrinters xmlns:xsi="http://www.w3.org/2001/XMLSchema-
instance" xmlns="http://tempuri.org/printer.xsd">
<xsl:for-each select="city">
<xsl:sort select="code" order="ascending"/>
<city>
<xsl:copy-of select="code"/>
<xsl:copy-of select="name"/>
<xsl:copy-of select="comment"/>
</city>
</xsl:for-each>
</hsPrinters>
</xsl:template>
</xsl:stylesheet>
Like I said if I take out the namespace from the
<hsprinter>, the transform works, but then I cannot load
the xml doc into my dataset in c#.
c# tranform code I'm using is:
System.Xml.XPath.XPathDocument xmldoc = new
System.Xml.XPath.XPathDocument(info[1] + info[0]);
System.Xml.Xsl.XslTransform xfm = new
System.Xml.Xsl.XslTransform();
xfm.Load("c:\printer.xsl");
System.Xml.XmlTextWriter writer = new
System.Xml.XmlTextWriter("c:\printer.xsl"null);
xfm.Transform(xmldoc, null, writer);
I'd be grateful for any pointers
Many thanks
Simon
I have a xml dataset I'd like to order, and save in that
order. I've written an xsl to do the transformation, but
because the xml file has a xsd namespace, it doesn't work.
A cutdown version of the xml file looks like this:
<?xml version="1.0" standalone="yes"?>
<hsPrinters xmlns:xsi="http://www.w3.org/2001/XMLSchema-
instance" xmlns="http://tempuri.org/printer.xsd">
<city>
<code>LN</code>
<name>London</name>
<comment>Herbert Smith London Offices</comment>
</city>
<city>
<code>PA</code>
<name>Paris</name>
<comment>Herbert Smith Paris Offices</comment>
</city>
<city>
<code>BR</code>
<name>Brussels</name>
<comment>Brussels Offices</comment>
</city>
<city>
<code>MW</code>
<name>Moscow</name>
<comment>Moscow Office</comment>
</city>
</hsPrinters>
This is the xsl:
<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">
<xsl:template match="hsPrinters">
<hsPrinters xmlns:xsi="http://www.w3.org/2001/XMLSchema-
instance" xmlns="http://tempuri.org/printer.xsd">
<xsl:for-each select="city">
<xsl:sort select="code" order="ascending"/>
<city>
<xsl:copy-of select="code"/>
<xsl:copy-of select="name"/>
<xsl:copy-of select="comment"/>
</city>
</xsl:for-each>
</hsPrinters>
</xsl:template>
</xsl:stylesheet>
Like I said if I take out the namespace from the
<hsprinter>, the transform works, but then I cannot load
the xml doc into my dataset in c#.
c# tranform code I'm using is:
System.Xml.XPath.XPathDocument xmldoc = new
System.Xml.XPath.XPathDocument(info[1] + info[0]);
System.Xml.Xsl.XslTransform xfm = new
System.Xml.Xsl.XslTransform();
xfm.Load("c:\printer.xsl");
System.Xml.XmlTextWriter writer = new
System.Xml.XmlTextWriter("c:\printer.xsl"null);
xfm.Transform(xmldoc, null, writer);
I'd be grateful for any pointers
Many thanks
Simon