Recursive descent: typeswitch v. XSL's apply-templates (&
was Re: [MarkLogic Dev General] Quirks of generating xhtml with xquery
dsewell at virginia.edu
Thu Aug 28 11:41:03 PDT 2008
Well, I can speak as someone one of whose tasks just today has been to
edit a library file containing about 2000 lines of MarkLogic XQuery code
to perform all of the recursive XML-to-HTML rendering for the version 2
of a publication based on quite complex TEI (Text Encoding Initiative)
XML--definitely comparable to DocBook in complexity.
My brief feedback, based on our several years' experience using ML
Server, would be:
* XSLT 2.0 (I avoid working in 1.0 unless there's no choice) is much
more efficient than XQuery for ad-hoc transforms, quick one-time
modifications of one document structure to another, and uncomplicated
"push" transformation of entire documents (XQuery is of course optimized
for "pull" transformations, pulling bits and pieces out of XML files). I
use it daily for work on my filesystem files.
* But it's entirely possible to write a complex recursive rendering with
dozens of element "templates" via XQuery functions, and
* Once you've done it, the XQuery function library is probably easier to
maintain than one or more XSLT files of similar complexity.
The reason for the last point is twofold: the cleaner/simpler syntax of
XQuery, and the fact that functions, sequences, and flow control are
integrated into the language from the start rather than being to some
extent tacked on as they are with XSLT.
That said, I'd be pleased if an XSLT parser were eventually bundled into
MarkLogic Server (and I've said this at least once a year for the last
four years or so), just because it would provide more flexibility, and
because I don't see either language withering away anytime soon.
On Thu, 28 Aug 2008, Robert Koberg wrote:
> On Aug 28, 2008, at 1:43 PM, Jason Hunter wrote:
> > You may or may not like recursive descent as a style. Our point of view on
> > the MarkMail team is that XQuery with recursive descent lets us do
> > everything XSLT would, and it gets the job done really fast.
> I am sure that is true for highly structured documents like email. But say you
> have complex document schema similar to docbook (or even 25% of its
> complexity) and you want to convert that to XHTML, would that still hold true?
> Would the XQuery be maintainable?
> I'd be curious if there have been discussions and what the results where
> regarding incorporating XSL in the MarkLogic DB. Is this something we can look
> forward to?
> Don't get me wrong, I really like XQuery and think the MarkLogic DB is a great
> product. I would like to see it even better!
> General mailing list
> General at developer.marklogic.com
David Sewell, Editorial and Technical Manager
ROTUNDA, The University of Virginia Press
PO Box 801079, Charlottesville, VA 22904-4318 USA
Courier: 310 Old Ivy Way, Suite 302, Charlottesville VA 22903
Email: dsewell at virginia.edu Tel: +1 434 924 9973
More information about the General