RE: [xsl] top level params and xsl:attribute magic?

Subject: RE: [xsl] top level params and xsl:attribute magic?
From: "Conal Tuohy" <conalt@xxxxxxxxxxxxxxx>
Date: Thu, 23 Jan 2003 19:16:40 +1300
Simon wrote:

> ... My XSLT
> applies templates to the RNG file until it hits a
> <zeroOrMore> node. At
> that point it spits out the XPath to that node, as the value
> of an HTML
> forms button. The button posts the XPath back to the same
> XSLT. At that
> point, I want to start at the node, given by the xpath, and apply my
> templates again to the descendants of the Xpath.

If you are generating this xpath parameter yourself in XSLT, and it refers
to a single node, then it should also be simple enough to parse as a string,
in XSLT. It's not as if your parser would have to parse any xpath expression
is it?

I assume your generated xpath expression looks something like:

"foo[2]/bar[1]/baz[23]"

You can evaluate this against your document with a recursive named template:
pass it a the xpath string and a root node, and have it parse the string up
to the first slash, extract the number from the square brackets, and select
the matching child node using something like
"node()[name()=$node-name][position()=$position]". This is the first step in
the xpath. Then it can call itself recursively, passing the remainder of the
xpath string and this child node. If there are no more steps in the xpath,
the template can call apply-templates to process the final node.

Cheers!

Con


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


Current Thread