RE: [xsl] xsl conditional: finding the right node

Subject: RE: [xsl] xsl conditional: finding the right node
From: "Michael Kay" <mhk@xxxxxxxxx>
Date: Fri, 13 Feb 2004 09:11:44 -0000
> One could explicitly write this down 
> ("needs-table=true|false") as an attribute of each "command", 
> but I would rather automate it.  I'm trying to figure out how 
> XSL can know the answer before it reaches the elements that 
> would need a prior table-start -- and, of course, re-set the 
> answer when the next "command" comes along.

There is no before and after with XSLT. It gets the information you ask
for at a time of its own choosing. And there is certainly no "resetting"
of anything.
> The pseudo-code for what I'm trying to implement is something like:
> Find a "command" element
>   Read ahead to see if a table is wanted (does this node have any
>                      children of a certain sort?)
>     Output basic command info, before table
>     Output table-start if wanted
>       Output table rows if applicable ...
>     Output table-end if wanted
>     Continue processing rest of command node

Try to rewrite the pseudo-code as a description of the desired result
rather than as an algorithm. "The output contains for each command,
basic command info, an optional table which is produced only if the
command has children of a certain sort, followed by remaining command

If you want to know whether the current element has an X child, just

<xsl:if test="child::X">...</xsl:if>

Michael Kay

 XSL-List info and archive:

Current Thread