[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: A beef with XSLT Sometimes too complicated

Subject: Re: A beef with XSLT Sometimes too complicated
From: Wendell Piez <wapiez@xxxxxxxxxxxxxxxx>
Date: Tue, 18 Jul 2006 10:45:29 -0400
Re:  A beef with XSLT Sometimes too complicated
At 05:36 PM 7/17/2006, you wrote:
> So -- if I follow you -- nesting a for expression is a workaround for
> this gap only some of the time?

nesting the for never helps, you can use one for if the sequnce being
bound to the variable has exactly one item
let $x :=1 return ...
can be written in xpath as
for $x in 1 return ..


but there is _no_ way in XPath to bind a value to a variable x such that
has any value other than 1.
let $x := () return ...
let $x := (1,2) return ...
have no analogue in XPath.

Ah-hah. I think what's impeding my brain here is simply my inexperience with query languages in general, and in particular with applications of let constructs with variable cardinality (using the word "variable" as English, not XPath :-). (Outside the XSLT context, of course.)

Now, transformations I have experience with....

It does occur to me that what we are facing is a collective coming-to-grips with the question of queries-as-transformations and transformations-as-queries, both in the design choices made by the committees (facing their various requirement sets) and by the user communities who then use those designs. I'm inclined to think of queries as a subset of transformations, but then I would think that. Stepping back I suppose it's probably possible to define each in terms of the other. And it does seem that in the real world, transformations always include some query component (even if implicit as in <xsl:apply-templates/>) while queries mostly include some transformation component (or can be seen as transformations in themselves).

When XPath is used in XSLT it's only a minor inconvenience, you just
drop back into xslt and use
<xsl:variable name="x" select="()"/>
<xsl:variable name="x" select="(1,2)"/>
It might be more of a "problem" in oher XPath API, although less of
a problem than those API for XPath1, which don't let you bind variables
at all, as XPath1 has no binding expressions.

> In line with the question whether to prefer XPath or XSLT logic, can
> we see an example where we'd actually prefer to do it in XPath if we
> could? (I'd welcome entries from anyone.)

So if thinking about this "the xpath way" it's probably not much of a
problem, but increasingly when looking for xpath solutions you're going
to be lead by somone or some search engine to xquery solutions.

I think you mean the "XSLT Way" here, in Carlislese?

The fact that often you can get an xpath solution from an xquery solution by
replacing any let by for means that people will try that, but it's only
safe to do if you know the cardinality of the expression being bound is
always 1 (which you are unlikely to know if it's just some code found on
the web) I feel a faq coming on in this area...



Current Thread


Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
First Name
Last Name
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.