XML Editor
Sign up for a WebBoard account Sign Up Keyword Search Search More Options... Options
Chat Rooms Chat Help Help News News Log in to WebBoard Log in Not Logged in
Show tree view Topic
Topic Page 1 2 3 4 5 6 7 8 9 Go to previous topicPrev TopicGo to next topicNext Topic
Postnext
chris wallaceSubject: Path problem
Author: chris wallace
Date: 21 Feb 2006 06:31 AM
With this input:
<doc>
<bs>
<b><c>A</c><d>AAA</d></b>
<b><c>B</c><d>BBB</d></b>
<b><c>C</c><d>CCC</d></b>
<b><c>D</c><d>DDD</d></b>
</bs>
<body>
<x>A</x>
<x>D</x>
</body>
</doc>

I want to expand the codes (A, D) to their values in the bs table. (AAA, DDD)

This template works:
<xsl:template match="x">
<xsl:variable name="x">
<xsl:value-of select="."/>
</xsl:variable>
<xsl:value-of select="/doc/bs/b[c=$x]/d)"/>
</xsl:template>

But this does not:
<xsl:template match="x">
<xsl:value-of select="/doc/bs/b[c=.]/d)"/>
</xsl:template>

and I dont understand why. I would welcome enlightenment.

Chris

Postnext
(Deleted User) Subject: Path problem
Author: (Deleted User)
Date: 21 Feb 2006 10:52 AM

Hi, Chris. When you create a predicate inside brackets ( b[c=$x], for example), you are setting a new input context set to the current node being examined by the predicate. The variable you set in your first XSLT sample is what allows you to compare a node with the input context of the template.

The reason your second XSLT doesn't work is that when the evaluation reaches the predicate ( b[c=.] ), the context node points to a "b" node. In order to reach the "x" node, you either need to use the current() function (like [c=current()], for example), or store the value of "." as a variable and use it later (as you did in your first XSLT).

Hope this helps.

David Foster
Stylus Studio Team

Posttop
chris wallaceSubject: Path problem
Author: chris wallace
Date: 21 Feb 2006 11:48 AM
Hi David

Thank you very much for that answer - just the ticket! And of course thats just why you need current()!

Chris

 
Topic Page 1 2 3 4 5 6 7 8 9 Go to previous topicPrev TopicGo to next topicNext Topic
Download A Free Trial of Stylus Studio 6 XML Professional Edition Today! Powered by Stylus Studio, the world's leading XML IDE for XML, XSLT, XQuery, XML Schema, DTD, XPath, WSDL, XHTML, SQL/XML, and XML Mapping!  
go

Log In Options

Site Map | Privacy Policy | Terms of Use | Trademarks
Stylus Scoop XML Newsletter:
W3C Member
Stylus Studio® and DataDirect XQuery ™are from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2016 All Rights Reserved.