RE: [xsl] Design question

Subject: RE: [xsl] Design question
From: "Michael Kay" <michael.h.kay@xxxxxxxxxxxx>
Date: Wed, 10 Jul 2002 14:54:06 +0100
> 
> >>The reason Jay couldn't use that is that for some arrangements of 
> >>parameters this would lead to attributes being added after child 
> >>elements have already been added to the da:Positive 
> element, which is 
> >>an error in XSLT.
> >
> > I thought there was no concept of "before" and "after" on XSLT.
> 
> There has to be *some* concept of "before" and "after" in 
> XSLT, otherwise you wouldn't be able to specify the order of 
> elements inside other elements and things like xsl:sort would 
> be pointless. But yes, you're right that in general the order 
> in which parts of the result tree are generated by the 
> processor doesn't matter; however in this case it does. I 
> imagine that this was to make it easier for processors that 
> don't do any funky parallel processing of templates to create a
> (SAX) event stream of the result.

Actually the XSLT 1.0 spec is really badly worded here, because it does
make it sound as if the order of execution matters. What it's really
saying is that in the sequence of nodes generated by a template [renamed
a "content constructor" in XSLT 2.0], attribute nodes must come before
child nodes. It's the order of nodes in the result sequence that counts,
not the chronological order of execution. If you processed the
instructions in reverse order, the attributes would have to be generated
last.

Of course the reason for the rule is indeed to allow implementations to
process instructions sequentially if they wish.

I've always thought it might be fun to process a stylesheet starting at
the end, just to see what happens. I did once think quite seriously
about parsing XPath expressions from right to left, but I got myself too
confused. Perhaps if I read Hebrew I would find it easier.

Michael Kay
Software AG
home: Michael.H.Kay@xxxxxxxxxxxx
work: Michael.Kay@xxxxxxxxxxxxxx 


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread