|
Subject: RE: [xsl]: Context inside nested for-eaches from different document()s From: "Michael Kay" <michael.h.kay@xxxxxxxxxxxx> Date: Mon, 28 Jan 2002 16:23:08 -0000 |
> I have something like this:
>
> <xsl:variable name="a" select="document('a.xml')/TopNode"/>
> ...
>
> <xsl:template match="elementX">
> <xsl:for-each select="$a">
> <xsl:value-of select="./@AnAttribute[../@DifferentAttribute=
> <<here I want
> to refer to an attribute from an elementX>>]"/>
>
> My problem is that normally the for-each would be iterating
> over a node
> inside the current document, so to get up out of the loop to
> the current
> match would involve moving up the document structure.
> In this case, where the loop is iterating over nodes from a different
> document held in a variable, the matched node seems to be
> inaccessible. How
> can I get at my elementX?
Assign it to a variable before going into the <xsl:for-each>
<xsl:variable name="elementX" select="."/>
Mike Kay
>
> Hypothetically, this situation could be even further nested.
> Would it be
> useful if you could navigate up and down the nested levels to
> get at the
> current node of each? This would be a new axis, with less to do with
> document structure than the logical structure of the stylesheet.
>
An early draft of XSLT had something like this, partially preserved in the
context() function of WD-xsl. I think that peeking down the stack is
intrinsically error-prone, and that using explicit variables is far safer.
Mike Kay
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
| Current Thread |
|---|
|
| <- Previous | Index | Next -> |
|---|---|---|
| Re: [xsl]: Context inside nested fo, Trevor Nash | Thread | [xsl] rewriting xslt 1 to xslt 2.0, Bryan Rasmussen |
| RE: [xsl] RE:read-write same url in, Michael Kay | Date | RE: [xsl] How to select elements ba, Michael Kay |
| Month |