Re: [xsl] Algorithm for setting a variable number of attributes

Subject: Re: [xsl] Algorithm for setting a variable number of attributes
From: "rick@xxxxxxxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Wed, 3 Aug 2022 12:25:58 -0000
Thank you Michael. I wasn't aware of the xsl:where-populated instruction.
That solves the problem in a clean way for me.

-----Original Message-----
From: Michael Kay mike@xxxxxxxxxxxx
<xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> 
Sent: Wednesday, August 3, 2022 3:35 AM
To: xsl-list <xsl-list@xxxxxxxxxxxxxxxxxxxxxx>
Subject: Re: [xsl] Algorithm for setting a variable number of attributes

A variant of this is to use xsl:where-populated:

>       <xsl:analyze-string select="." regex="^SUBTASK
(\d+)-(\d+)-(\d+)-((\d+)-(\d+) - \((\d+)\))?$">
>            <xsl:matching-substring>
                <xsl:where-populated>
>                 <xsl:attribute name="chapnbr" select="regex-group(1)"/>
>                 <xsl:attribute name="sectnbr" select="regex-group(2)"/>
>                 <xsl:attribute name="subnbr" select="regex-group(3)"/>
>                 <xsl:attribute name="func" select="regex-group(4)"/>
>                 <xsl:attribute name="seq" select="regex-group(5)"/>
>                 <xsl:attribute name="revdate" select="regex-group(6)"/>
                </xsl:where-populated>
>            </xsl:matching-substring>
>         </xsl:analyze-string>
> 

The xsl:where-populated instruction filters out any attributes whose string
value would be zero-length.

Michael Kay
Saxonica

Current Thread