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 September 1st, 2010, 08:09 AM
Authorized User
 
Join Date: Feb 2008
Posts: 37
Thanks: 0
Thanked 0 Times in 0 Posts
Default How to return a node-Set in XSLT 1.0

The following variable returns a node set

Code:
<xsl:variable name="styleColorLineItemsMovex" select="$lineItemsForManufacturerDeliveryLineItems[(@Color = $color) and (substring(@Style, 1, 9) = $style) and (@Attribute2 = $buyerStyle)]" />



But i want to put the above line in a call-template and pass the value back to a variable in a calling program.But the value returned is not a node set.

Can anyone tell what can be done to get the node-set?

Last edited by LeoMathew; September 1st, 2010 at 08:11 AM.. Reason: i added the [code] identifier
 
Old September 1st, 2010, 08:24 AM
Friend of Wrox
 
Join Date: Nov 2007
Posts: 1,243
Thanks: 0
Thanked 245 Times in 244 Posts
Default

Your named template can do e.g.
Code:
<xsl:copy-of select="$varName"/>
and that way returns a result tree fragment. Then you need to use an extension function like exsl:node-set to turn the result tree fragment into a node-set e.g.
Code:
<xsl:variable name="v2">
  <xsl:call-template name="t1"/>
</xsl:variable>
<xsl:for-each select="exsl:node-set($v2)//*">...</xsl:for-each>
__________________
Martin Honnen
Microsoft MVP (XML, Data Platform Development) 2005/04 - 2013/03
My blog
 
Old September 1st, 2010, 08:25 AM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

It is not possible in XSLT 1.0 for a template to return references to nodes in the source document.

In fact, XSLT 1.0 doesn't speak of templates "returning" anything. It speaks of templates writing to the result tree.

One of the many reasons to move to 2.0...
__________________
Michael Kay
http://www.saxonica.com/
Author, XSLT 2.0 and XPath 2.0 Programmer\'s Reference





Similar Threads
Thread Thread Starter Forum Replies Last Post
Convert substring to node set in XSLT 1.0 JessicaD XSLT 3 July 30th, 2009 02:51 PM
XPath: set operation with a disjoint node set rich_unger XSLT 7 May 6th, 2008 09:24 AM
Filtering out from a node set anothervbaddict XSLT 1 May 22nd, 2007 08:42 AM
node-set function Bernardo Pacheco XSLT 2 June 19th, 2006 10:45 AM
Return a Record set into a table? morpheus Classic ASP Basics 2 November 18th, 2003 11:38 AM





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