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

Context in nested loop

Subject: Context in nested loop
From: "Joseph L. Casale jcasale@xxxxxxxxxxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Fri, 28 Jul 2017 14:11:16 -0000
 Context in nested loop
I am unclear with the correct syntax for the corresponding context of the
$name and $attr
variables in the following repro. For $name, mailto:../@name is what I want,
but I know that is
incorrect and for $attr, "." gets the value and not the name. This is similar
to a question I
had a few days ago, yet in this case I am still unable to figure it out. Does
a way exist to avoid
the variables?

Thanks,
jlc

<root>
  <nodeA>
    <nodeB name="MyName" attrB="2" attrC="3" />
  </nodeA>
</root>

<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0"
                xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                xmlns:wix="http://schemas.microsoft.com/wix/2006/wi"
                xmlns:msxsl="urn:schemas-microsoft-com:xslt"
                exclude-result-prefixes="msxsl">
  <xsl:output encoding="UTF-8" indent="yes" method="xml" />

  <xsl:strip-space elements="*" />

  <xsl:variable name="document" select="document('file.xml')" />

  <xsl:template match="/">
    <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/foo/bar[@name=$name]/@*[local-name()=$attr]" />
          </xsl:message>
        </xsl:if>
      </xsl:for-each>
    </xsl:for-each>
  </xsl:template>
</xsl:stylesheet>

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.