Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > XML > XSLT
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old February 28th, 2006, 05:04 AM
Registered User
 
Join Date: Feb 2006
Location: , , .
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default constructing node-set content to xsl:variable

Hi,

I would be very glad if anyone could explain this to me.

Given this xml data
<a>
  <b>blablabla</b>
</a>

and this stylesheet

<xsl:template match="/"/>
  <xsl:variable name="a">
    <xsl:copy-of select="/a"/>
  </xsl:variable>

  <xsl:value-of select="exsl:node-set($a)/b"/>
</xsl:template>

I am aiming to get the output "blablabla" but currently i get nothing.
If I hardcode the variable data like this it works:

..
  <xsl:variable name="a">
    <b>blablabla</b>
  </xsl:variable>
..

I have also tried with xslt 2.0 and skipping the exsl function but i get the same result. Can anyone please explain this. Is copy-of the correct function to use at all here?

Thanks
-Thomas


Reply With Quote
  #2 (permalink)  
Old February 28th, 2006, 05:16 AM
Registered User
 
Join Date: Feb 2006
Location: , , .
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default

try it once
<xsl:template match="a">
  <p>
   <xsl:value-of select="b"/>
  </p>
</xsl:template>
Quote:
quote:Originally posted by MrWay
 Hi,

I would be very glad if anyone could explain this to me.

Given this xml data
<a>
<b>blablabla</b>
</a>

and this stylesheet

<xsl:template match="/"/>
<xsl:variable name="a">
    <xsl:copy-of select="/a"/>
</xsl:variable>

<xsl:value-of select="exsl:node-set($a)/b"/>
</xsl:template>

I am aiming to get the output "blablabla" but currently i get nothing.
If I hardcode the variable data like this it works:

..
<xsl:variable name="a">
    <b>blablabla</b>
</xsl:variable>
..

I have also tried with xslt 2.0 and skipping the exsl function but i get the same result. Can anyone please explain this. Is copy-of the correct function to use at all here?

Thanks
-Thomas


Reply With Quote
  #3 (permalink)  
Old February 28th, 2006, 05:54 AM
mhkay's Avatar
Wrox Author
Points: 18,438, Level: 59
Points: 18,438, Level: 59 Points: 18,438, Level: 59 Points: 18,438, Level: 59
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Apr 2004
Location: Reading, Berks, United Kingdom.
Posts: 4,954
Thanks: 0
Thanked 290 Times in 285 Posts
Default

The value of $a is a document node whose only child is an a element. To find the b element, you need exslt:node-set($a)/a/b

Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference
Reply With Quote
  #4 (permalink)  
Old February 28th, 2006, 10:39 AM
Registered User
 
Join Date: Feb 2006
Location: , , .
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks Michael, it works beautifully.

Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
XPath: set operation with a disjoint node set rich_unger XSLT 7 May 6th, 2008 09:24 AM
The reference node is not a child of this node.XSL XMLUser XSLT 2 February 25th, 2008 05:22 AM
xsl using variable on a node Debiprasad XSLT 1 June 22nd, 2006 12:20 PM
Problem using xsl:for-each on a exsl:node-set ballo XSLT 11 March 28th, 2006 10:47 AM
Retrieve the escaped node content carlos.bravo XSLT 4 September 16th, 2005 03:23 PM



All times are GMT -4. The time now is 06:25 AM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.