DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

+ Reply to Thread
Results 1 to 2 of 2
  1. #1
    TC Guest

    ADO, XML accessing a parent node's row context from a child node attributes???

    Hi All

    Extract of style sheet, I do not seem to understand how to refernce a parent
    node when I processing the
    inner <xsl:for-each select='@*'>, I want to fill the HREf with the orderID
    that is in the <xsl:for-each select='z:row'>
    outer loop I thought that preceeding a filter with ".." allow access to the
    parent node values eg.
    <xsl:value-of select="..['@OrderID']" /> would return in the current row
    context the value of the orderid
    associated with the "OrderNUmber"

    <xsl:template match="xml/rs:data">
    <xsl:for-each select='z:row'>
    <tr>

    <xsl:for-each select='@*'>
    <td nowrap="nowrap" class='Cell'>
    <xsl:choose>
    <xsl:when test=".[nodeName()='OrderNumber']">
    <a>
    <xsl:attribute name="HREF">Order.asp?OrderID=<xsl:value-of
    select="..['@OrderID']" />
    </xsl:attribute>
    <xsl:value-of match='.'/>
    </a>

    </xsl:when>
    </xsl:choose>

    </td>
    </xsl:for-each>
    </tr>
    </xsl:for-each>
    </xsl:template>

    Extract of xml ado data looks like

    <rs:data>
    <z:row OrderNumber='71826' OrderID='71826' ...bunch of other fields />

    </rs:data>
    </xml>




  2. #2
    TC Guest

    Re: ADO, XML accessing a parent node's row context from a child node attributes???

    Figured this out about 2 sec's after i hit the send
    <xsl:value-of select="../@OrderID" />
    or of course you can go <xsl:value-of select="context(-2)/@OrderID" />


    TC wrote in message <38ea66c8@news.devx.com>...
    >Hi All
    >
    >Extract of style sheet, I do not seem to understand how to refernce a

    parent
    >node when I processing the
    >inner <xsl:for-each select='@*'>, I want to fill the HREf with the orderID
    >that is in the <xsl:for-each select='z:row'>
    >outer loop I thought that preceeding a filter with ".." allow access to the
    >parent node values eg.
    ><xsl:value-of select="..['@OrderID']" /> would return in the current row
    >context the value of the orderid
    >associated with the "OrderNUmber"
    >
    ><xsl:template match="xml/rs:data">
    > <xsl:for-each select='z:row'>
    > <tr>
    >
    > <xsl:for-each select='@*'>
    > <td nowrap="nowrap" class='Cell'>
    > <xsl:choose>
    > <xsl:when test=".[nodeName()='OrderNumber']">
    > <a>
    > <xsl:attribute name="HREF">Order.asp?OrderID=<xsl:value-of
    >select="..['@OrderID']" />
    > </xsl:attribute>
    > <xsl:value-of match='.'/>
    > </a>
    >
    > </xsl:when>
    > </xsl:choose>
    >
    > </td>
    > </xsl:for-each>
    > </tr>
    > </xsl:for-each>
    ></xsl:template>
    >
    >Extract of xml ado data looks like
    >
    ><rs:data>
    > <z:row OrderNumber='71826' OrderID='71826' ...bunch of other fields />
    >
    ></rs:data>
    ></xml>
    >
    >
    >




Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


Top DevX Stories

Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL


Sponsored Links