[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: Can a named template return a node list?

Subject: Re: Can a named template return a node list?
From: David Carlisle <davidc@xxxxxxxxx>
Date: Thu, 16 Jun 2005 22:45:57 +0100
template return node set
> I understand that custom:function is basically a method in a .NET class, 
> which does return a pointer/reference to an existing node in the current 
> XML document, and I can reference attributes of that node using 
> $whatever/@attr instead of $whatever/*/@attr.

both syntaxes work, it just depends what you wnat to select.

$whatever/@attr
selects the attr attribute of each node in the node set bound to
$whatever.

$whatever/*/@attr
selects the attr attribute of each element child of each node in the
node set bound to $whatever.

If you use 
<xsl:variable> with content then it generates a result tree fragment
corresponding to a root node (/) with children whatever nodes are
generated by the content of teh xsl:variable. so then if you go
<xsl:variable name="whatever" select="x:node-set($x)"/>
then clealy you would want to use 
$whatever/*/@attr
as root nodes have no attributes so you need to select elements first.
On the other hand if you go
<xsl:variable name="whatever" select="x:node-set($x)/*"/>
Then $whatever is a node set of element nodes and you can go
$whatever/@attr
to select their attributes.

But in your case you don't want to use x:node-set at all, just select
the nodes you want directly using selct on the xsl:variable.

>   I guess this is because  call-template always returns what I would
>   call a string, 

No call-template generates nodes not a string, but it doesn't return
anything it places teh nodes into the current output, witherthe main
result document or a result tree fragment being built in a variable.
A result tree frafgment os very different from a string. (It's almost
exactly the same thing as a node set with a single root node, except for
an essentially artificial restriction that you can not query into it.

> ..

> need to know that they sometimes need to add /* to dereference
> variables.

The /* is nothing to do with it being a variable it is just usual XPath
syntax distinguishing whether you want to find the attribute of this node
or this node's children.

David

________________________________________________________________________
This e-mail has been scanned for all viruses by Star. The
service is powered by MessageLabs. For more information on a proactive
anti-virus service working around the clock, around the globe, visit:
http://www.star.net.uk
________________________________________________________________________

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.