OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.

 


Help: OASIS Mailing Lists Help | MarkMail Help

 


 

   Re: [xml-dev] XPath 2.0 - how much of XQuery should it include?

[ Lists Home | Date Index | Thread Index ]

Hi John,

>> XPath 2.0 incorporates a number of *statements* that are already
>> provided by XSLT 2.0. The for "expression" and the if "expression"
>> would be classed as statements in any other language.
>
> That turns out not to be the case.
>
> There are many languages in which everything is an expression
> returning a value, including conditionals and loops, and even good
> ol' C has a conditional expression (with funky syntax, but
> semantically the same as if-then-else).

OK, I can see that argument. Let me put it another way. An XPath is an
expression that returns a value. A piece of XSLT code is an expression
that returns a value. Together, they are a language in which
everything is an expression returning a value. Some of this language
is in XML-based syntax, and some of it is in text-based syntax.

In XSLT+XPath 1.0, the two syntaxes are complementary. Generally, if
you want to work over a set of nodes, you use XSLT; if you want to
work over strings, numbers or booleans, you use XPath. There are a few
important exceptions, notably path expressions, which are primarily
made for the sake of conciseness. You could use recursive templates to
step through a path, but since this is a much-used operation, there's
a simple text-based syntax for doing it as well. You can still use
recursive templates when the text-based version isn't sufficient, for
example because you want to keep track of information from further up
the hierarchy as you step down.

In XSLT+XPath 2.0, the principal difference between the text-based
syntax and the XML-based syntax is that the text-based syntax can't be
used to return values that include newly-created nodes, whereas the
XML-based syntax can only be used to return newly-created nodes.
Rather than being complementary, the two languages are operating in
parallel.

There are roughly the same features in both: XSLT uses xsl:for-each,
XPath uses for; XSLT uses xsl:choose, XPath uses if; XSLT uses
xsl:sort, XPath uses sort-by(); XSLT has xsl:variable, XPath has to be
twisted so that you can use the pseudo-variable-assignment of the for
expression, or you have to bug out to a user-defined function so that
you can use XSLT's variable assignment mechanisms.

My argument is that it would be perfectly possible for XSLT and XPath
2.0 to work in a complementary way again. We could redraw the line
where it was before, but allow a couple of extra shorthand features in
the text-based syntax, namely conditional expressions and a simple
mapping operator. But these should be shorthand features that are used
for the most common kinds of looping and conditional expressions, not
mirrors of the full functionality of XSLT.

Cheers,

Jeni

---
Jeni Tennison
http://www.jenitennison.com/





 

News | XML in Industry | Calendar | XML Registry
Marketplace | Resources | MyXML.org | Sponsors | Privacy Statement

Copyright 2001 XML.org. This site is hosted by OASIS