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 August 16th, 2010, 04:19 PM
Friend of Wrox
 
Join Date: May 2004
Posts: 109
Thanks: 18
Thanked 0 Times in 0 Posts
Default Pointers or by-references to nodes in a temporary tree?

I am using Saxon 9.


I find a table of interest by a cross reference and display the title:
Code:
<xsl:value-of select="$repoSubTree//pmtable/pmtitle[@Id eq $myIDRef]"/>
But, I need to do some work based on other parts of this table I just found

I tried:
Code:
<xsl:variable name="myPMTable">
   <xsl:sequence select="$repoSubTree//pmtable[./pmtitle/@Id eq $myIDRef]"></xsl:sequence>
</xsl:variable>
To put the interesting table in a variable so I can do xpath statements to pull information from the table.
For example to get the title, I tried
Code:
<xsl:value-of select="$myPMTable/pmtitle"></xsl:value-of>
But I don't get anything. I also tried copy-of instead of sequence, nothing...

But this really doesn't seem like the right approach anyway. I don't need a another copy of my table, I've already got it in my $repoSubTree temporary tree. I just need a reference or pointer to it stored in a variable that I can use in subsequent xpath statements to find data stored in the table.

Is this sort of thing possible in XSLT?

Thanks,
__________________
------------------------
Keep Moving Forward

GnuPG Key fingerprint = 1AD4 726D E359 A31D 05BF ACE5 CA93 7AD5 D8E3 A876

Michael Hare
 
Old August 16th, 2010, 05:46 PM
samjudson's Avatar
Friend of Wrox
 
Join Date: Aug 2007
Posts: 2,128
Thanks: 1
Thanked 189 Times in 188 Posts
Default

In XSLT 2.0 the following should work fine:

Code:
<xsl:variable name="myPMTable" select="$repoSubTree//pmtable[pmtitle/@Id eq $myIDRef]"/>
__________________
/- Sam Judson : Wrox Technical Editor -/

Think before you post: What have you tried?
The Following User Says Thank You to samjudson For This Useful Post:
mphare (August 16th, 2010)
 
Old August 16th, 2010, 05:56 PM
Friend of Wrox
 
Join Date: May 2004
Posts: 109
Thanks: 18
Thanked 0 Times in 0 Posts
Default

Well, I do feel the idiot now.. I knew I had to be over thinking this.

I did get it to work by adding as="node()" to the line that creates the variable. Apparently I have more reading about as='node()' to do.

But, your answer worked as well.. and I don't have to read about as='node()' just yet.

Thanks!
__________________
------------------------
Keep Moving Forward

GnuPG Key fingerprint = 1AD4 726D E359 A31D 05BF ACE5 CA93 7AD5 D8E3 A876

Michael Hare





Similar Threads
Thread Thread Starter Forum Replies Last Post
Xpath more specific or return tree fragment or nodes peterdums BOOK: XSLT Programmer's Reference, 2nd Edition 0 November 26th, 2009 09:10 AM
C/C++ Pointers reality_42000 C++ Programming 1 March 4th, 2007 01:26 AM
array and pointers amrinder C++ Programming 1 November 10th, 2006 07:58 AM
pointers Stuby085 Visual C++ 1 August 30th, 2003 11:58 PM
Pointers jake VB How-To 12 June 21st, 2003 11:30 AM





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