[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

RE: Can I access the children by their Index?

Subject: RE: Can I access the children by their Index?
From: "Daniel Newman" <daniel.newman@xxxxxxxxxxx>
Date: Tue, 27 Feb 2001 16:59:11 -0000
xsl child index
I fixed this in the end by using

<xsl:value-of
select="ANNUALSNAPSHOT[3]/CONSENSUSVALUE/ESTIMATEDATA/child::*[position()=$I
ndex]" />

Now I know might not be pretty, but it DOES return what I want. $Index will
range from 1 to 9

-----Original Message-----
From: owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx
[mailto:owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx]On Behalf Of Francis
Norton
Sent: 27 February 2001 16:22
To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Subject: Re:  Can I access the children by their Index?


something like this should do it... you don't have to know the name of
an element or an attribute to process it :)

Francis.

<xsl:template match="ESTIMATEDATA">
  <table>
  <xsl:for-each select="*">
  <!--
    select="*" is shorthand for select="child::*",
    in other words all child elements
  -->
    <tr>
      <td><xsl:value-of select="local-name()"/></td>

      <xsl:for-each select="@*">
      <!--
        select="@*" is shorthand for select="attribute::*",
        in other words all attributes
      -->
        <td><xsl:value-of select="."/></td>
      </xsl:for-each>
      <td><xsl:value-of select="."/></td>
    </tr>
  </xsl:for-each>
  </table>
</xsl:template>

Daniel Newman wrote:
>
> sorry all, thought my original request might confuse. Time for more
> illustration. My XML (the part we're interested in anyway) looks like
this:
>
>  <ESTIMATEDATA>
>   <SALES name="Sales" grade="none">***.*</SALES>
>   <PROFIT name="Profit" grade="none">**.*</PROFIT>
>   <EPS name="EPS" grade="none">**.*</EPS>
>   <CFPS name="CFPS" grade="none" />
>   <DPS name="DPS" grade="none">**.**</DPS>
>   <PE name="P/E Ratio" grade="none">**.*</PE>
>   <DIVCOVER name="Div Cover" grade="none">*.*</DIVCOVER>
>   <DIVYIELD name="Yield" grade="none">*.*</DIVYIELD>
>   <PEG name="PEG Factor" grade="none" />
>  </ESTIMATEDATA>
>
> Now I want to set up a function that will loop 9 times, and then retrieve
> the value of that child node. I don't want to refer to each child by their
> name, as this would mean getting rid of the loop and having nine table
rows.
> There must be a way of accessing CFPS without calling it by name. So
again,
> can I get the value of CFPS by doing something like:
>
> xsl:value-of select="../../../ESTIMATEDATE/child(4)/@name"
>

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.