[xquery-talk] Screen-scraping with XQuery

Michael Kay mhk at mhk.me.uk
Thu Mar 31 22:20:00 PST 2005


The XSLT 2.0 and XQuery versions are both in the samples directory of the
Saxon product (tour.xsl, tour.xq). 

The XSLT 2.0 and XSLT 1.0 versions (and indeed an XSLT 1.1 version) are both
in the downloadable code for my book XSLT 2.0 Programmers' Reference, which
you can download from www.wrox.com whether or not you have bought the book.

The program is essentially written using recursive functions, XPath
expressions, and element constructors, so there are only trivial syntactic
differences between the XQuery 1.0 and XSLT 2.0 versions. I think there was
only one feature used that was in one of the languages and not the other:
XSLT allows you to specify a default value for an external parameter (the
square where the tour starts), XQuery doesn't.

Michael Kay


> -----Original Message-----
> From: R. Mark Volkmann [mailto:mark at ociweb.com] 
> Sent: 31 March 2005 20:58
> To: Michael Kay
> Cc: 'Erik Bruchez'; talk at xquery.com
> Subject: RE: [xquery-talk] Screen-scraping with XQuery
> 
> Quoting Michael Kay <mhk at mhk.me.uk>:
> 
> > > 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.
> > >
> >
> > Getting the syntax more concise was certainly one of the 
> things that was on
> > my personal agenda for XSLT 2.0, though there was a 
> surprising amount of
> > resistance from people who liked it the way it was. A 
> little comparison is
> > interesting: my "knight's tour" program (which computes a 
> knight's tour of
> > the chessboard) was 276 non-comment lines in XSLT 1.0, 159 
> non-comment lines
> > in XSLT 2.0, and 155 non-comment lines in XQuery. I think 
> most people would
> > find the XSLT and XQuery versions equally mind-blowing, 
> unless they have
> > spent six months learning functional programming.
> 
> Is there a place on the web where we can look at the three 
> versions of that
> code?  I admit I'm surprised that the XSLT 2.0 code is so 
> close in number of
> lines to the XQuery code.  I'd like to see that.
> 
> --
> R. Mark Volkmann
> Partner, Object Computing, Inc.
> 




More information about the talk mailing list