Re: [xsl] Re: Add element at the end of a variable group of elements

Subject: Re: [xsl] Re: Add element at the end of a variable group of elements
From: "Wendell Piez wapiez@xxxxxxxxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Wed, 3 Mar 2021 22:55:13 -0000
NB also Liam's variable could be recast as a function, to be namespace-safe:

<xsl:function name="z:is-early" as="xs:boolean">
  <xsl:param name="who" as="element()"/>
  <xsl:sequence
select="exists($who/(self::bar|self::foo|self::mercury|self::venus"/>
</xsl:function>

<xsl:template match="*[z:is-early(.)][last()]" priority="10">
  <xsl:next-match/> <!--* built-in template copies the element *-->
  <moon>Now with more craters!</moon>
</xsl:template>

Mind you, to drop a moon in where there is no planet at all would still
need a little 'pull' logic.

This is where a schema is quite useful, since a required element in a
sequence can provide a hook to hang things on.

Cheers, Wendell


On Wed, Mar 3, 2021 at 2:59 PM Liam R. E. Quin liam@xxxxxxxxxxxxxxxx <
xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> wrote:

> On Wed, 2021-03-03 at 16:22 +0000, Charles O'Connor
> coconnor@xxxxxxxxxxxx wrote:
> >
> > Liam, I will continue to annoy my IT/Engineering group to upgrade to
> > a 3.0 processor. I suspect I'll get the same response.
>
> Haha! note that i included an XSLT 2 approach that may be slightly
> easier to maintain than some of the others.
>
> And i continue to offer XSLT 3 training for XSLT 2 people! :)
>
> --
> Liam Quin, https://www.delightfulcomputing.com/
> Available for XML/Document/Information Architecture/XSLT/
> XSL/XQuery/Web/Text Processing/A11Y training, work & consulting.
> Barefoot Web-slave, antique illustrations:  http://www.fromoldbooks.org
> 
>
>

-- 
...Wendell Piez... ...wendell -at- nist -dot- gov...
...wendellpiez.com... ...pellucidliterature.org... ...pausepress.org...
...github.com/wendellpiez... ...gitlab.coko.foundation/wendell...

Current Thread