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

Re: template return value

Subject: Re: template return value
From: Jeni Tennison <jeni@xxxxxxxxxxxxxxxx>
Date: Wed, 12 Dec 2001 18:13:30 +0000
xslt template return value
Hi Charly,

> Is it possible to write functions in XSL. If not is there a way
> around . I need to call a template and store the output (or result)
> into a variable.

You can call the template from the body of the xsl:variable, as you've
been shown. The trouble with this method is that the variable gets
assigned a result tree fragment. Usually that doesn't matter (because
result tree fragments are automatically and mostly correctly converted
to strings or numbers when you use them in a context that requires a
string or number). However, you can't return a node set from a
template.

So if the result you want is a node set, you have two options.

Firstly, you can return a result tree fragment containing copies of
the nodes, then convert the result tree fragment to a node using an
extension node-set() function (e.g. exsl:node-set(), xalan:nodeSet(),
msxsl:node-set()). These functions return the root node of the result
tree fragment as a node set, so you usually need to step down to its
child to get the information you want.

Secondly, you can use an extension that allows you to define
extension functions yourself, and return node sets from these
extension functions. For example, you could use func:function (see
http://www.exslt.org/functions) in Saxon, 4XSLT, libxslt or jd.xslt,
msxsl:script in MSXML or xalan:component/xalan:script in Xalan.

Cheers,

Jeni

---
Jeni Tennison
http://www.jenitennison.com/


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread
  • template return value
    • Charly - Wed, 12 Dec 2001 12:38:19 -0500 (EST)
      • Corey Spitzer - Wed, 12 Dec 2001 13:02:15 -0500 (EST)
      • Jeni Tennison - Wed, 12 Dec 2001 13:13:19 -0500 (EST) <=
        • Charly - Wed, 12 Dec 2001 13:50:09 -0500 (EST)
      • <Possible follow-ups>
      • Avula, Raj - Wed, 12 Dec 2001 12:51:10 -0500 (EST)
        • Charly - Wed, 12 Dec 2001 13:18:03 -0500 (EST)

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.