Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

using substring function in xsl with xml by ado

Status
Not open for further replies.

sjimmie

Programmer
Mar 3, 2001
2
0
0
NL
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=&quot;1&quot; Sjimmie=&quot;12.0000&quot; Babak=&quot;-12.0000&quot;/>

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=&quot; doesn't understand substring.

Can someone please help me out?
The xml-document and xsl-document I use are:

xml:

<?xml-stylesheet type=&quot;text/xsl&quot; href=&quot;C:\Documents and Settings\Administrator\My Documents\XML\Microsoft\Example1\Simple.xsl&quot;?>
<xml xmlns:s=&quot;uuid:BDC6E3F0-6DA3-11d1-A2A3-00AA00C14882&quot; xmlns:dt=&quot;uuid:C2F41010-65B3-11d1-A29F-00AA00C14882&quot; xmlns:rs=&quot;urn:schemas-microsoft-com:rowset&quot; xmlns:z=&quot;#RowsetSchema&quot;>
<s:Schema id=&quot;RowsetSchema&quot;>
<s:ElementType name=&quot;row&quot; content=&quot;eltOnly&quot;>
<s:AttributeType name=&quot;ID&quot; rs:number=&quot;1&quot;>
<s:datatype dt:type=&quot;int&quot; dt:maxLength=&quot;4&quot; rs:precision=&quot;10&quot; rs:fixedlength=&quot;true&quot; rs:maybenull=&quot;false&quot;/>
</s:AttributeType>
<s:AttributeType name=&quot;Sjimmie&quot; rs:number=&quot;2&quot; rs:nullable=&quot;true&quot; rs:write=&quot;true&quot;>
<s:datatype dt:type=&quot;i8&quot; rs:dbtype=&quot;currency&quot; dt:maxLength=&quot;8&quot; rs:precision=&quot;19&quot; rs:fixedlength=&quot;true&quot;/>
</s:AttributeType>
<s:AttributeType name=&quot;Babak&quot; rs:number=&quot;3&quot; rs:nullable=&quot;true&quot; rs:write=&quot;true&quot;>
<s:datatype dt:type=&quot;i8&quot; rs:dbtype=&quot;currency&quot; dt:maxLength=&quot;8&quot; rs:precision=&quot;19&quot; rs:fixedlength=&quot;true&quot;/>
</s:AttributeType>
<s:extends type=&quot;rs:rowbase&quot;/>
</s:ElementType>
</s:Schema>
<rs:data>
<z:row ID=&quot;1&quot; Sjimmie=&quot;12.0000&quot; Babak=&quot;-12.0000&quot;/>
<z:row ID=&quot;2&quot; Sjimmie=&quot;1.0000&quot; Babak=&quot;-1.0000&quot;/>
</rs:data>
</xml>


************************************************************


xsl:

<?xml version=&quot;1.0&quot;?>

<xsl:stylesheet xmlns:xsl=&quot; xmlns:html=&quot; result-ns=&quot;&quot;>

<xsl:template match=&quot;/&quot;>

<xsl:for-each select=&quot;xml/rs:data/z:row&quot;>
<xsl:value-of select=&quot;@Sjimmie&quot;/>
</xsl:for-each>
</xsl:template>


</xsl:stylesheet>


************************************************************

<xsl:value-of select=&quot;substring(@Sjimmie,1,2)&quot;/>
results in an error.

Thanks a lot!

Joost
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top