[xquery-talk] Screen-scraping with XQuery
Erik Bruchez
ebruchez at orbeon.com
Thu Mar 31 20:31:43 PST 2005
R. Mark Volkmann wrote:
> I don't think it's too hard to learn either XSLT or XQuery. However, I have a
> strong preference for XQuery syntax over XSLT. The main reason is the
> verbosity of XSLT caused by using XML as a programming language. A good
> example of the verbosity I'm talking about is the difference between defining
> and invoking a user-defined function in XQuery versus defining and invoking a
> named template in XSLT.
I don't like calling named templates as well, but I believe XQuery 1.0
should be compared with XSLT 2.0 in all fairness. XSLT 2.0 introduces
functions, and while the syntax to declare such functions is a little
heavier in XSLT (especially for parameters), calling them from XPath
expressions is much lighter than using XSLT 1.0's named templates.
Compare the declarations:
declare function f:doIt($x as xs:string) as xs:integer {};
<xsl:function name="f:doIt" as="xs:integer">
<xsl:param name="x" as="xs:string"/>
Then calling the function will be done with:
f:doIt('Hello!')
in both cases (within an XPath 2.0 expression for XSLT, of course). To
be fair, you will often write <xsl:copy-of select="f:doIt('Hello!')"/>
in XSLT 2.0, but that remains much lighter than xsl:call-template.
-Erik
More information about the talk
mailing list