[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: "Michael Kay" <mike@xxxxxxxxxxxx>
Date: Thu, 16 Jun 2005 16:53:05 +0100
can xslt template return anything
In XSLT 1.0, templates don't return anything, they write to the current
result tree (which might be the final result tree, or the contents of an RTF
in a variable). This means that if they produce nodes, the nodes are always
copies of nodes in the source, not references to original nodes.

This all changes with 2.0.

Michael Kay
http://www.saxonica.com/

 

> -----Original Message-----
> From: John [mailto:john-xsl-list@xxxxxxxx] 
> Sent: 16 June 2005 15:25
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Subject:  Can a named template return a node list?
> 
> Sorry in advance for my terminology.  Is it possible for a named 
> template to return a node list?  Here is some simplified XML 
> with which 
> I have been experimenting:
> 
> <root>
>    <node1 attr="node1attrval">
>      <node1a>node1atext</node1a>
>    </node1>
>    <node2 attr="node2attrval">
>      <node2a>node2atext</node2a>
>    </node2>
> </root>
> 
> And the XSL I have been trying:
> 
> <xsl:template match="*">
>    <xsl:variable name="somenode">
>      <xsl:call-template name="sometemplate" />
>    </xsl:variable>
>    <xsl:value-of select="$somenode/@attr" />
> </xsl:template>
> 
> <xsl:template name="sometemplate">
>    <xsl:copy-of select="/root/node1" />
> </xsl:template>
> 
> The reference to $somenode/@attr gives an error.  I think the 
> problem is 
> with copy-of - I want it to return a reference to a node, but 
> it seems 
> to return the value of the node.  Is there some other function or 
> approach I should try?  I have tried value-of and copy, and I 
> am hoping 
> to stay away from XSL extensions if possible.  I cannot use XSL 2.
> 
> Thanks,
> 
>     -John

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.