You are viewing a plain text version of this content. The canonical link for it is here.
Posted to general@xml.apache.org by "Samson, Lyndon [IT]" <ly...@ssmb.com> on 2001/02/26 11:01:24 UTC

XSLT Interesting behaviour

Hi Listers

I want to control the output of matches based on an order tag. Something
like this;

Input

<allthings>
  <thing id='1'>Thing1</thing>
  <thing id='2'>Thing2</thing>
  <thing id='3'>Thing3</thing>

  <orderofthings>
    <thing>2</thing>
    <thing>1</thing>
    <thing>3</thing>
  </orderofthings>

</allthings>

Template 

<xsl:template match="/allthings/orderofthings/*">
  <xsl:variable name="thisval"><xsl:value-of select="."/></xsl:variable>
  <xsl:apply-templates select="/allthings/thing[@id=$thisval]"/>
</xsl:template>

Output

Thing2
Thing1
Thing3

This works but I would have thought that the best way to define the template
would be;

<xsl:template match="/allthings/orderofthings/*">
  <xsl:apply-templates select="/allthings/thing[@id=text(.)]"/>
</xsl:template>

But this doesn't seem to work, what have I missed? Can I not use functions
in expressions?



thanks
l