[xsl] Context in nested loop

Subject: [xsl] Context in nested loop
From: "Joseph L. Casale jcasale@xxxxxxxxxxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Fri, 28 Jul 2017 14:11:16 -0000
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?


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

<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0"
  <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'">
select="$document/foo/bar[@name=$name]/@*[local-name()=$attr]" />

Current Thread