I use ado to create an xml-document.
This document has a couple of namspaces in it, which I can't control. The format of the file is: it describes the attributes and elements and after that the data-section is written. Each row from the recordset is like:
<z:row ID="1" Sjimmie="12.0000" Babak="-12.0000"/>
After that I use an xsl-stylesheet, which loops over the rows and writes the attributes as new elements for a new xml-document. The value of the attributes becomes the value of the elements.
Some fields I want to format. I found a couple of examples that use substring. Unfortunately, the namespace that I have to use to read this xml-document that is created by ADO, xmlns:xsl=" doesn't understand substring.
Can someone please help me out?
The xml-document and xsl-document I use are:
xml:
<?xml-stylesheet type="text/xsl" href="C:\Documents and Settings\Administrator\My Documents\XML\Microsoft\Example1\Simple.xsl"?>
<xml xmlns:s="uuid:BDC6E3F0-6DA3-11d1-A2A3-00AA00C14882" xmlns:dt="uuid:C2F41010-65B3-11d1-A29F-00AA00C14882" xmlns:rs="urn:schemas-microsoft-com:rowset" xmlns:z="#RowsetSchema">
<s:Schema id="RowsetSchema">
<s:ElementType name="row" content="eltOnly">
<s:AttributeType name="ID" rs:number="1">
<s:datatype dt:type="int" dt:maxLength="4" rs
recision="10" rs:fixedlength="true" rs:maybenull="false"/>
</s:AttributeType>
<s:AttributeType name="Sjimmie" rs:number="2" rs:nullable="true" rs:write="true">
<s:datatype dt:type="i8" rs:dbtype="currency" dt:maxLength="8" rs
recision="19" rs:fixedlength="true"/>
</s:AttributeType>
<s:AttributeType name="Babak" rs:number="3" rs:nullable="true" rs:write="true">
<s:datatype dt:type="i8" rs:dbtype="currency" dt:maxLength="8" rs
recision="19" rs:fixedlength="true"/>
</s:AttributeType>
<s:extends type="rs:rowbase"/>
</s:ElementType>
</s:Schema>
<rs:data>
<z:row ID="1" Sjimmie="12.0000" Babak="-12.0000"/>
<z:row ID="2" Sjimmie="1.0000" Babak="-1.0000"/>
</rs:data>
</xml>
************************************************************
xsl:
<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl=" xmlns:html=" result-ns="">
<xsl:template match="/">
<xsl:for-each select="xml/rs:data/z:row">
<xsl:value-of select="@Sjimmie"/>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
************************************************************
<xsl:value-of select="substring(@Sjimmie,1,2)"/>
results in an error.
Thanks a lot!
Joost
This document has a couple of namspaces in it, which I can't control. The format of the file is: it describes the attributes and elements and after that the data-section is written. Each row from the recordset is like:
<z:row ID="1" Sjimmie="12.0000" Babak="-12.0000"/>
After that I use an xsl-stylesheet, which loops over the rows and writes the attributes as new elements for a new xml-document. The value of the attributes becomes the value of the elements.
Some fields I want to format. I found a couple of examples that use substring. Unfortunately, the namespace that I have to use to read this xml-document that is created by ADO, xmlns:xsl=" doesn't understand substring.
Can someone please help me out?
The xml-document and xsl-document I use are:
xml:
<?xml-stylesheet type="text/xsl" href="C:\Documents and Settings\Administrator\My Documents\XML\Microsoft\Example1\Simple.xsl"?>
<xml xmlns:s="uuid:BDC6E3F0-6DA3-11d1-A2A3-00AA00C14882" xmlns:dt="uuid:C2F41010-65B3-11d1-A29F-00AA00C14882" xmlns:rs="urn:schemas-microsoft-com:rowset" xmlns:z="#RowsetSchema">
<s:Schema id="RowsetSchema">
<s:ElementType name="row" content="eltOnly">
<s:AttributeType name="ID" rs:number="1">
<s:datatype dt:type="int" dt:maxLength="4" rs
</s:AttributeType>
<s:AttributeType name="Sjimmie" rs:number="2" rs:nullable="true" rs:write="true">
<s:datatype dt:type="i8" rs:dbtype="currency" dt:maxLength="8" rs
</s:AttributeType>
<s:AttributeType name="Babak" rs:number="3" rs:nullable="true" rs:write="true">
<s:datatype dt:type="i8" rs:dbtype="currency" dt:maxLength="8" rs
</s:AttributeType>
<s:extends type="rs:rowbase"/>
</s:ElementType>
</s:Schema>
<rs:data>
<z:row ID="1" Sjimmie="12.0000" Babak="-12.0000"/>
<z:row ID="2" Sjimmie="1.0000" Babak="-1.0000"/>
</rs:data>
</xml>
************************************************************
xsl:
<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl=" xmlns:html=" result-ns="">
<xsl:template match="/">
<xsl:for-each select="xml/rs:data/z:row">
<xsl:value-of select="@Sjimmie"/>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
************************************************************
<xsl:value-of select="substring(@Sjimmie,1,2)"/>
results in an error.
Thanks a lot!
Joost