Re: [xsl] targeting the 'first' instance of the same element in variable structures

Subject: Re: [xsl] targeting the 'first' instance of the same element in variable structures
From: "Jean-Paul Rehr rehrjb@xxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Tue, 2 Jul 2024 11:41:50 -0000
>That sounds as if  match="(body/div//head)[1]" should do as the XSLT
processor should still see the parent (or perhaps not, what is
transform:transform?, BaseX or exist-db, would need to check how their XSLT
function works exactly).

It's eXist-db's XSLT transformation function, that hands off to Saxon. The
fragment is detached from the node when passed into the function. I tested
a variant

<xsl:template match="(div[./parent::body]//head)[1]">

but it also fails.

So, I wrapped the div fragment in a body before passing it to the
transformer and now it works. Thanks for the inspiration!



On Tue, Jul 2, 2024 at 1:32b/PM Martin Honnen martin.honnen@xxxxxx <
xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> wrote:

>
> On 02/07/2024 13:28, Jean-Paul Rehr rehrjb@xxxxxxxxx wrote:
>
> >Or can the outer div appear at any level/with any nesting and parent
> container?
>
> The fragments I pass to the transformer always start with <div>.
>
> But to explain the larger context:
>
> These <div> fragments are all *direct children* of a single <body>, but
> for a few reasons I can't pass the full body to the transformation. These
> fragments are being passed into transformation from Xquery which can be
> reduced to:
>
> for $div in $mydoc//body/div
> return
>       transform:transform($div, $myxsl, ())
>
>
> That sounds as if
>
>   match="(body/div//head)[1]"
>
> should do as the XSLT processor should still see the parent (or perhaps
> not, what is transform:transform?, BaseX or exist-db, would need to check
> how their XSLT function works exactly).
>
>
>
> XSL-List info and archive <http://www.mulberrytech.com/xsl/xsl-list>
> EasyUnsubscribe <http://lists.mulberrytech.com/unsub/xsl-list/3377836> (by
> email <>)

Current Thread