cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "spam2006@meeque.de" <spam2...@meeque.de>
Subject Re: XSL for nested sql result
Date Tue, 18 Jul 2006 14:41:40 GMT
> I need some advice for writing a xsl for a nested sql result.
> the source file is
>  
>  <rowset>
>    <row>
>      <id>test</id>
>      <rowset>
>        <row>
>          <class_name> 111</class_name>
>          <rowset>
>            <row>
>              <class_name> 11</class_name>
>              <rowset>
>                <row>
>                  <class_name> 1</class_name>
>                  <rowset>
>                    <row>
>                      <class_name>0</class_name>
>                    </row>
>                  </rowset>
>                </row>
>              </rowset>
>            </row>
>          </rowset>
>        </row>
>      </rowset>
>    </row>
> </rowset>
>  
> I want the result as 0/1/11/111,

Ok, Toby was faster than me, and actually I like his solution better.
Nevertheless, here is a non-recursive solution to your problem. You can
insert the following snippet somewhere in your stylesheet, where a node
containing your outermost class_name element is the context node:

<xsl:for-each select="descendant::class_name">
  <xsl:sort select="position()" order="descending"/>
  <xsl:value-of select="normalize-space(.)"/>
  <xsl:if test="position() != last()">
    <xsl:text>/</xsl:text>
  </xsl:if>
</xsl:for-each>

If you want to be more typesafe, use "descendant::rowset/row/class_name"
in the first select attribute instead.

Regards,
Michael


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Mime
View raw message