|
Subject: Re: [xsl] XSLT 4 xsl:with From: "Imsieke, Gerrit, le-tex gerrit.imsieke@xxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> Date: Tue, 19 May 2020 14:29:10 -0000 |
<xsl:variable name="baz" as="element(baz)">
<baz>
<bar>
<foo n="1"/>
<foo n="2"/>
</bar>
</baz>
</xsl:variable><xsl:for-each select="$baz/bar">
<td>
Count of foo elements in {path()}:
<xsl:value-of select="count(foo)"/>
</td>
</xsl:for-each><td xsl:context-item="$baz/bar">
Count of foo elements in {path()}:
<xsl:value-of select="count(foo)"/>
</td><xsl:message context-item="$baz/bar">
Count of foo elements in {path()}:
<xsl:value-of select="count(foo)"/>
</xsl:message><xsl:choose context-item="$baz/bar"> <xsl:when test="count(foo) = 2">...</xsl:when> <xsl:otherwise>...</xsl:otherwise> </xsl:choose>
<xsl:choose>
<xsl:when context-item="$baz/bar"
test="count(foo) = 2" select="'two'"/>
<xsl:when test="count($baz/bar/foo) = 1">
<xsl:sequence select="'one'"/>
</xsl:when>
<xsl:otherwise>...</xsl:otherwise>
</xsl:choose>On Tue, May 19, 2020 at 08:53:54AM -0000, Pieter Masereeuw pieter@xxxxxxxxxxxx scripsit:I would be very happy if I could make my intentions clearer by using a real XSLT construct in this situation, such as *<xsl:with select="...">*. The semantics could also help as an assertion that, indeed, the selection has exactly length 1.
Despite a certain mad temptation to xsl:each-with, I think this might be better as xsl:with-context.
I agree that the clarity would be an improvement. I wouldn't want to see it force a single member sequence on the select, though.
-- Graydon
| Current Thread |
|---|
|
| <- Previous | Index | Next -> |
|---|---|---|
| Re: [xsl] XSLT 4 xsl:with, Graydon graydon@xxxx | Thread | Re: [xsl] XSLT 4 xsl:with, Imsieke, Gerrit, le- |
| Re: [xsl] XSLT 4: xsl:template/@sel, Alan Painter alan.pa | Date | Re: [xsl] XSLT 4 xsl:with, Imsieke, Gerrit, le- |
| Month |