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
Conferences Close Tree View
+ Stylus Studio Feature Requests (1192)
+ Stylus Studio Technical Forum (14621)
+ Website Feedback (249)
- XSLT Help and Discussion (7625)
-> + Use of before and after string (3) Sticky Topic
-> - How do I substitute element ty... (1)
-> + How does one add working days ... (4)
-> - Help, I have existing XLT and... (1)
-> + Need help on XSLT issue - (2)
-> + EDI to XML Conversion (7)
-> - XML To JSON Conversion using X... (1)
-> + Formatting Paragraphs to same ... (2)
-> - Grouping of records (1)
-> + Problems with xsd 1.1 (4)
-> + XML to HL7 mapping (3)
-> + XSLT 3 and Iterate (2)
-> + XSL-FO to PDF preview (3)
-> + java.lang.RuntimeException: Er... (2)
-> + Create Acroforms with Stylus X... (2)
-> + How to change XSLT parameter s... (3)
-> + how to change format of the da... (2)
-> + Search "Next 8 Results " doesn... (2)
-> - Support for Git (1)
-> + newbee (8)
-- [1-20] [21-40] [41-60] Next
+ XQuery Help and Discussion (2017)
+ Stylus Studio FAQs (159)
+ Stylus Studio Code Samples & Utilities (364)
+ Stylus Studio Announcements (113)
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

   
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.