Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XSLT
|
XSLT General questions and answers about XSLT. For issues strictly specific to the book XSLT 1.1 Programmers Reference, please post to that forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XSLT section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old June 15th, 2006, 08:25 AM
Authorized User
 
Join Date: Jun 2006
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
Default get value, not the path...

Hi,

New to the world of xslt, and working my way through my first project. 99% there, but I'm having a problem trying to compare two nodes. The $expectedValue variable winds up with the path's location, not with the value of the node at the path's location. How do I accomplish what I'm looking to do?

        <xsl:variable name="myTag" select="name()" />
        <xsl:variable name="uniqueAncestor" select="Step_1_DummyInfo" />
        <xsl:variable name="thisValue" select="." />
        <xsl:variable name="partPath1" select = "concat('../../../../../ExpectedHeader/',$uniqueAncestor)" />
        <xsl:variable name="partPath2" select = "concat($partPath1,'//')" />
        <xsl:variable name="expectedPath" select = "concat($partPath2,$myTag)" />

        <xsl:variable name="expectedValue" select="$expectedPath" />

        <!-- having trouble - the $expectedValue variable contains the STRING, not the Value, how do I get it to pull
             the VALUE so I can test it as follows: -->

            <xsl:choose>
               <xsl:when test="$expectedValue = $thisValue">


Thanks!
__________________
Thanks!
 
Old June 15th, 2006, 08:41 AM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

XSLT doesn't allow an XPath expression to be constructed on-the-fly as a character string, it has to be written literally in the select attribute. Some products (such as Saxon) have an extension function (e.g. saxon:evaluate()) that will allow you to do this.

But I suspect that in your case you can achieve what you want with something like

select="../../../../../ExpectedHeader/*[name()=$uniqueAncestor]//*[name()=$myTag]"

Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference
 
Old June 15th, 2006, 08:58 AM
Authorized User
 
Join Date: Jun 2006
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks Michael. That was exactly it, and I spent hours on it before I came here (lesson learned).



Thanks!





Similar Threads
Thread Thread Starter Forum Replies Last Post
Need Help with path for loading Pics (app.path) Tabbasum Beginning VB 6 2 November 15th, 2007 04:57 AM
Implementing the all-path shortest path problem bitwords XSLT 1 December 6th, 2006 11:37 AM
using app.path in database path and filename kd8con VB Databases Basics 2 October 25th, 2006 11:45 AM
Convert logical path to absolute path zoostar J2EE 1 April 15th, 2005 10:36 AM
Path cavaleiro4 C++ Programming 0 September 15th, 2004 04:56 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.