[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: Thu, 20 Feb 2003 08:29:04 +0200
xslt current tag name
Hi,

>    If you recall my problem. It remains same. I wrote
> in my problem ..
> 
>   "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"
> 
> Can I test when the value of <A> tag changes? I want
> to display a line break as '---------' when value of
> <A> will change..?

So your problem is basically a grouping one. See Jeni's grouping pages, <http://jenitennison.com/xslt/grouping> IIRC.

<xsl:key name="x" match="TAG[not(A)]" use="generate-id(preceding::A[1])" />

<xsl:template match="/">
  <!--get all TAGs with A-->
  <xsl:for-each select="rootelem/TAG[A]">
    <xsl:variable name="x" select="A" />
    <!--process current TAG and all following without A before next TAG with A-->
    <xsl:for-each select=". | key('x', generate-id($x))">
      <xsl:choose>
        <xsl:when test="$x = 'value1'">Label1</xsl:when>
        <xsl:when test="$x = '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:text>---------&#xA;</xsl:text>
  </xsl:for-each>
</xsl:template>

You still didn't show us your desired output, so again I'm assuming this is what you want. It uses node identity in case there are multiple TAG elements with the same value for A child. It's the fourth Monday of this week and my knees are busted, so it shouldn't be a surprise that there a probably faster ways to solve this.

Cheers,

Jarno - Feindflug: Glaubenskrieg

 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.