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: "Geert Bormans geert@xxxxxxxxxxxxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Tue, 21 Sep 2021 19:20:45 -0000
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 



[ http://www.mulberrytech.com/xsl/xsl-list | 
XSL-List info and archive ] 
[ http://lists.mulberrytech.com/unsub/xsl-list/554170 | EasyUnsubscribe ] ( [  | by email ] ) 

Current Thread