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

RE: Problem writing a XSLT stylesheet

Subject: RE: Problem writing a XSLT stylesheet
From: Jarno.Elovirta@xxxxxxxxx
Date: Tue, 18 Feb 2003 08:55:23 +0200
xslt st
Hi,

[...]

> There are certain tags missing in <TAG>. The missing
> tags <A> and <B> are repetitive information. Therefore
> the first <TAG> tag will have data and will not be
> present in tags after that unless there is a change in
> these tag's value. 
> 
> The <A> tag can have 3 possible values
> value1, value2, value3
> 
> Based on this value, the label for <E> that needs to
> be output will change --
> if <A> is value1, output E's label as Label1
> if <A> is value2, output E's label as Label2
> if <A> is value3, output E's label as Label3
> 
> 
> I want the output to appear as
> 
> Label1  <value-of E>
> Label3  <value-of E>
> Label2  <value-of E>
> ..etc
> (the Labels will be different depending on the value
> of <A>)

[...]

If I understood you correctly

<xsl:template match="/">
  <xsl:for-each select="rootelem/TAG/E">
    <xsl:variable name="A" select="preceding::A[1]" />
    <xsl:choose>
      <xsl:when test="$A = 'value1'">Label1</xsl:when>
      <xsl:when test="$A = 'value2'">Label2</xsl:when>
      <xsl:otherwise>Label3</xsl:otherwise>
    </xsl:choose>
    <xsl:text> </xsl:text><xsl:value-of select="." /><xsl:text>&#xA;</xsl:text>
  </xsl:for-each>
</xsl:template>

displays how it can be achieved. It may be worth testing if keys could speed things up, but if your document is smallish, preceding axis may be faster.

Cheers,

Jarno - Assemblage 23: Document (Ultimate-Gloom-Mix By Echo Image)

 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.