xsl-list
[Top] [All Lists]

RE: Problem writing a XSLT stylesheet

2003-02-20 05:25:14
Hi Jarno ,
Thank you very much. I'll try your suggestion and read
the information at URL given by you.

If I'll have some problem, I'll ask you..

Regards,
Mukul

--- Jarno(_dot_)Elovirta(_at_)nokia(_dot_)com wrote:
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



__________________________________________________
Do you Yahoo!?
Yahoo! Tax Center - forms, calculators, tips, more
http://taxes.yahoo.com/

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list



<Prev in Thread] Current Thread [Next in Thread>