[xquery-talk] Implementing XQuery: parsing XQuery *and* XSL-T

Frans Englich frans.englich at telia.com
Thu Feb 16 22:09:17 PST 2006

Hi everyone,

I, as perhaps many others, say that XQuery 1.0 and XSL-T 2.0 are similar. They 
can roughly solve the same problems, although with different syntax. David 
Carlisle's xq2xsl[1] converts XQuery code to XSL-T, and implementations in 
the style of Saxon uses the same internal representation for XQuery and XSL-T 

For those steering towards implementing both host languages from the same code 
base can save development costs by TODO the similarities. That's what 
interests me in this mail. In particular, how far one can use the same code 
for parsing XQuery and XSL-T.

For the sake of this discussion, let's assume that "instantiating" XQuery or 
XSL-T can be divided in two parts: the tokenization/parsing stage(which, can 
be more or less entangled), and creating an AST tree(typically). The latter 
stage is the same for both XQuery and XSL-T. What differs is 
features/properties which have no corresponding part in the other language, 
and syntax.

In order to achieve that, consider this implementation sketch:

* The parser and any scanners(yes, plural) are separated. That is, scanners 
would be a state-driven or two-pass scanners[2], which not requires involving 
a token parser in order to know how to tokenize.

* One has two different scanners, one for XQuery and one for XSL-T, both 
producing tokens for the same parser to consume. For example, the XSL-T 
scanner would validate elements and attributes, perform whitespace 
normalization, but other than that produce tokens for consumption by the 

Of course, it is far from this simple and it is also very much implementation 
dependent. Nevertheless, I think it's worth a shot: has anyone attempted 
anything in this direction? What are people's thoughts and experiences on 
something like this?



As per the terminology defined in:

More information about the talk mailing list