xsl-list
[Top] [All Lists]

Re: Functions Returning Nodes in XSLT 2.0

2005-05-19 16:40:41
On 5/20/05, Alan Gutierrez <alan-xsl-list(_at_)engrm(_dot_)com> wrote:
   In XSLT 2.0 with Saxon 8.4...

   I've written helper methods that look like so.

   <xsl:function name="fn:user" as="element()">
     <xsl:param name="login"/>
     <xsl:copy-of
       select="document('users.xml')/users/user[login = $login]"/>
   </xsl:function>

   Making it easier to write select attributes.

   <xsl:value-of select="fn:user()/first-name"/>

   Some of my XPath is getting complicated, so I like to wrap it up
   into functions.

   I'm wondering if copy-of is smart enough to forgo copying in
   such cases.

No, xsl:copy-of does what it name says.

 If not, I could see how it could get expensive to
   call fn:user every time I wanted a property.

   Is there a better practice for this sort of thing?

Yes. 

Use:   xsl:sequence



Cheers,
Dimitre Novatchev.

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--