Re: [xsl] Value of variable not appearing in the <xsl:otherwise> of xml:choose

Subject: Re: [xsl] Value of variable not appearing in the <xsl:otherwise> of xml:choose
From: "Terry Ofner tdofner@xxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Tue, 21 Sep 2021 19:27:21 -0000
Geert,

Yep. That solves the problem. Thanks. Should have seen that before.

Terry

> On Sep 21, 2021, at 3:21 PM, Geert Bormans geert@xxxxxxxxxxxxxxxxxxx
<xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> wrote:
>
> I think you need to give the variable a value outside the for-each-group
> @nextExposID
> is not available in all groups
>
> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
>     xmlns:xs="http://www.w3.org/2001/XMLSchema";
>     xmlns:math="http://www.w3.org/2005/xpath-functions/math";
>     exclude-result-prefixes="xs math"
>     version="3.0">
>
>     <xsl:output indent="1"></xsl:output>
>
>     <xsl:template match="div">
>         <xsl:variable name="exploreExposID">
>             <xsl:value-of select="@id"/>
>         </xsl:variable>
>         <xsl:variable name="part3ID">
>             <xsl:value-of
select="div[@class='analyze_visual']/@nextExposID"></xsl:value-of>
>         </xsl:variable>
>         <div>
>             <xsl:copy-of select="@*"/>
>             <xsl:for-each-group select="*"
group-ending-with="div[@class='analyze_visual']">
>                 <xsl:choose>
>                     <xsl:when
test="current-group()[self::div[@class='analyze_visual']]">
>                         <part num="1" globalNumn="{$exploreExposID}">
>                             <xsl:copy-of
select="current-group()[not(self::div[@class='analyze_visual'])][not(self::h9
)]"/>
>                         </part>
>                         <part num="2" globalNum="{$part3ID}">
>                             <xsl:copy-of
select="current-group()[self::div[@class='analyze_visual']]"></xsl:copy-of>
>                         </part>
>                     </xsl:when>
>                     <xsl:otherwise>
>                         <part num="3">
>                             <xsl:attribute name="globalNum">
>                                 <xsl:value-of select="$part3ID"/>
>                             </xsl:attribute>
>                             <xsl:copy-of select="current-group()"/>
>                         </part>
>                     </xsl:otherwise>
>                 </xsl:choose>
>             </xsl:for-each-group>
>         </div>
>     </xsl:template>
>
> </xsl:stylesheet>
>
>
>
> Met vriendelijke groeten,
> Best regards,
>
> Geert Bormans
>
>
>
> XSL-List info and archive <http://www.mulberrytech.com/xsl/xsl-list>
> EasyUnsubscribe <http://lists.mulberrytech.com/unsub/xsl-list/554170> (by
email <applewebdata://6C658FBF-F6F6-4597-A371-E57E34769EA3>)
>
> XSL-List info and archive <http://www.mulberrytech.com/xsl/xsl-list>
> EasyUnsubscribe <http://lists.mulberrytech.com/unsub/xsl-list/723745> (by
email <>)

Current Thread