[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: Context in nested loop

Subject: Re: Context in nested loop
From: "Martin Honnen martin.honnen@xxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Fri, 28 Jul 2017 14:48:23 -0000
Re:  Context in nested loop
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

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.