This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: 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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]