This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Stuck on Name() and variable


I am having trouble getting an attribute match on name to work.  I'm sure I
am missing something silly here, so I hope someone will see it and point it
out to me!

I have a process where a mapping node tells me the node I need to read (done
through a function call since it uses bit comparison, this works fine).
Once I know the target node I need to read (either MapKey or MapMD), I then
need to get the attribute from that target node that has the same name as
the attribute I am on in the mapping node.  This is where I am stumped.  The
correct value is in the variable $AttrName, and a node of that name exists
in the target (MapKey or MapMD), but the match, attribute::*[name() =
$AttrName], is not doing what I expected it to do.  I get a result of
'4()(col13)  | ' from the sample output I added to try and figure out what
was going on.  So I can see that I have nothing in the $Pos variable.  But I
do have an attribute 'col13' in the MapMD node.

Can I even do a match on the attribute name against a variable?

<MapMD col0="0" col13="3" col14="2" col15="1" col16="4" col17="5" col18="8"
col19="7" col20="6" col21="9" col22="10"></MapMD>


<xsl:attribute name="data">
  <xsl:variable name="Market" select="node()"/>
  <xsl:variable name="Key" select="parent::node()"/>
  <xsl:for-each select="//Map[@schema]/attribute::*[position() &gt; 2]" >
      <xsl:variable name="AttrName" select="name()"/>
      <xsl:choose>
            <xsl:when test="bitmask:DeCode(current(), 2) " >
                  <xsl:variable name="Pos" >
                         <xsl:value-of select="MapKey/@*[name() =
$AttrName]" />
                  </xsl:variable>
                  2 - (<xsl:value-of select="$Pos" />)(<xsl:value-of
select="$AttrName" />) <xsl:value-of select="$Key/attribute::*[$Pos]" />
            </xsl:when>
            <xsl:when test="bitmask:DeCode(current(), 4) " >
                  <xsl:variable name="Pos" >
                        <xsl:value-of select="MapMD/attribute::*[name() =
$AttrName]" />
                  </xsl:variable>
                  4(<xsl:value-of select="$Pos" />)(<xsl:value-of
select="$AttrName" />) <xsl:value-of select="$Market/attribute::*[position()
= $Pos]" />
            </xsl:when>
      </xsl:choose>
      <xsl:if test = "position() != last()"> | </xsl:if>
   </xsl:for-each>
</xsl:attribute>



 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]