|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] RE: Problem writing a XSLT stylesheet
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>
</xsl:text>
</xsl:for-each>
<xsl:text>---------
</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
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|

Cart








