Subject: Re: [xsl] FW: Retrieving values of variables. From: Jeni Tennison <mail@xxxxxxxxxxxxxxxx> Date: Tue, 27 Feb 2001 11:31:04 +0000 |
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 |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] FW: Retrieving values of vari, Daniel Newman | Thread | [xsl] Embedded Javascript (xsl:scri, Zeynep Gunal |
RE: [xsl] I'm really annoyed!!!!, Ben Robb | Date | Re: [xsl] I'm really annoyed!!!!, David Carlisle |
Month |