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

Re: FW: Retrieving values of variables.

Subject: Re: FW: Retrieving values of variables.
From: Jeni Tennison <mail@xxxxxxxxxxxxxxxx>
Date: Tue, 27 Feb 2001 11:31:04 +0000
xslt updating variable value tennison
Hi Daniel,

Just looking at the first line of your stylesheet, I see that you're
using the old MSXML XSL syntax rather than XSLT 1.0. I recommend that
you update your stylesheet to XSLT 1.0 - have a look at
http://www.netcrucible.com/xslt/msxml-faq.htm for more details.  Using
XSLT 1.0 will help you to get help.

> If you have a look at the code
> <<http://www.arbitrary.co.uk/whatt/xml/new.xsl>>, template "RunLoop"
> is passed a value "CurrentCount", and checks if this value is <= 2
> (limiting the loop from 1 to 2). If it is, it calls "ESTIMATES", and
> this template then calls "ESTIMATE" (terrible naming, but not my
> XML). "ESTIMATE" is the loop of the records, but I need this
> template to retrieve either "ESTIMATE[1]" or "ESTIMATE[2]", with the
> index being the current value of "$CurrentCount". But as the
> templates are nested, can I retrieve the value, or do I need to pass
> it down the tree?

Can I just check whether I've got this right: you want to create two
tables, both with the same set of headers. Each table uses the data
from the ESTIMATE elements.  The first table uses the data held in the
first ANNUALFORECAST child element of the ESTIMATE and the second
table uses the data held in the second ANNUALFORECAST child element of
the ESTIMATE?

If that's right, you need to have a template for the ESTIMATES element
that creates the two tables.  In the first table, you need to apply
templates to the ANNUALFORECAST elements that are the first
ANNUALFORECAST element children of their ESTIMATE parent.  In the
second table, you need to apply templates to the ANNUALFORECAST
elements that are the *second* ANNUALFORECAST element children of
their ESTIMATE parent:

<xsl:template match="ESTIMATES">
   <table>
      <xsl:call-template name="table-header" />
      ... table-specific headers ...
      <xsl:apply-templates select="ESTIMATE/ANNUALFORECAST[1]" />
   </table>
   <table>
      <xsl:call-template name="table-header" />
      ... table-specific headers ...
      <xsl:apply-templates select="ESTIMATE/ANNUALFORECAST[2]" />
   </table>
</xsl:template>

Have a named template to hold the headers that are common to the two
templates:

<xsl:template name="table-header">
   ... a row with lots of table headers in it ...
</xsl:template>

and have a template that matches an ANNUALFORECAST and gives the
relevant information:

<xsl:template match="ANNUALFORECAST">
   ... a row with lots of table cells in it ...
</xsl:template>

Within that template you can get information about the ESTIMATE (e.g.
who the broker is) using the parent axis.  For example, to insert the
value of the broker's name, you can use:

  <xsl:value-of select="parent::ESTIMATE/BROKER/BROKERNAME" />

or, more simply:

  <xsl:value-of select="../BROKER/BROKERNAME" />

I hope that helps,

Jeni

---
Jeni Tennison
http://www.jenitennison.com/



 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.