Smart questions
Smart answers
Smart people
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Member Login

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips now!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

Join Tek-Tips
*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

LINK TO THIS FORUM!

Add Stickiness To Your Site By Linking To This Professionally Managed Technical Forum.
Just copy and paste the
code below into your site.

Partner With Us!

"Best Of Breed" Forums Add Stickiness To Your Site
Partner Button
(Download This Button Today!)

Feedback

"...A lot of the information I've found at this site would've taken me forever if I'd have attempted to research it on my own. Thanks again."

Geography

Where in the world do Tek-Tips members come from?

using substring function in xsl with xml by ado

sjimmie (Programmer)
3 Mar 01 10:22
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="http://www.w3.org/TR/WD-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:precision="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:precision="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:precision="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="http://www.w3.org/TR/WD-xsl";
                xmlns:html="http://www.w3.org/TR/REC-html40";
                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

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Back To Forum

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close