Re: [xsl] Context in nested loop

Subject: Re: [xsl] Context in nested loop
From: "Martin Honnen martin.honnen@xxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Fri, 28 Jul 2017 14:48:23 -0000
On 28.07.2017 16:30, Joseph L. Casale jcasale@xxxxxxxxxxxxxxxxx wrote:

Its schema is exactly the same as the sample XML, itbs a similar document

with different values. To be honest, I whipped this repro up in vim so in reality

the xpath selection within the message should correspond to the same element

path I am iterating over but in the alternate document. In that case it should be



<xsl:value-of select="$document/root/nodeA/nodeB[@name=$name]/@*[local-name()=$attr]" />


So you have

<xsl:for-each select="/root/nodeA/nodeB">
<xsl:variable name="name" select="@name"/>
<xsl:for-each select="@*">
<xsl:variable name="attr" select="local-name()"/>
<xsl:if test="name()!='name'">
<xsl:message>
<xsl:value-of select="$document/root/nodeA/nodeB[@name=$name]/@*[local-name()=$attr]" />
</xsl:message>
</xsl:if>
</xsl:for-each>
</xsl:for-each>


and of course the inner variable can be avoided with

<xsl:for-each select="/root/nodeA/nodeB">
<xsl:variable name="name" select="@name"/>
<xsl:for-each select="@*">
<xsl:if test="name()!='name'">
<xsl:message>
<xsl:value-of select="$document/root/nodeA/nodeB[@name=$name]/@*[local-name()=local-name(current())]" />
</xsl:message>
</xsl:if>
</xsl:for-each>
</xsl:for-each>


and the outer with

<xsl:for-each select="/root/nodeA/nodeB">
<xsl:for-each select="@*">
<xsl:if test="name()!='name'">
<xsl:message>
<xsl:value-of select="$document/root/nodeA/nodeB[@name=current()/../@name]/@*[local-name()=local-name(current())]" />
</xsl:message>
</xsl:if>
</xsl:for-each>
</xsl:for-each>


if I am not mistaken.

Current Thread