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 RE: XSLT Interesting behaviour
Date Mon, 26 Feb 2001 11:47:42 GMT
I think I have my answer, 

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

text(.) applys to the future matched node, not the current node.

Doh!

sorry for the noise.

l


-----Original Message-----
From: Samson, Lyndon [IT] [mailto:lyndon.samson@ssmb.com]
Sent: Monday, February 26, 2001 10:01 AM
To: 'general@xml.apache.org'
Subject: 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

---------------------------------------------------------------------
In case of troubles, e-mail:     webmaster@xml.apache.org
To unsubscribe, e-mail:          general-unsubscribe@xml.apache.org
For additional commands, e-mail: general-help@xml.apache.org

Mime
View raw message