xml-general mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Samson, Lyndon [IT]" <lyndon.sam...@ssmb.com>
Subject XSLT Interesting behaviour
Date Mon, 26 Feb 2001 10:01:24 GMT
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

Mime
View raw message