Subject: RE: [xsl] Stuck on Name() and variable From: "Michael Kay" <michael.h.kay@xxxxxxxxxxxx> Date: Tue, 6 Aug 2002 09:24:33 +0100 |
> 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> > Presumably the code below is executed with the <MapMD> element as the context node? > > <xsl:attribute name="data"> > <xsl:variable name="Market" select="node()"/> node() means child::node(): your MapMD element has no children. > <xsl:variable name="Key" select="parent::node()"/> We haven't been told what the parent of the MapMD element is. > <xsl:for-each > select="//Map[@schema]/attribute::*[position() > 2]" > Ouch! The order of attributes is undefined. Selecting all attributes after the second will give you a random set of attribute nodes back. You haven't told us anything about the Map element, so it's hard to say anything more... > <xsl:variable name="AttrName" select="name()"/> > <xsl:choose> > <xsl:when test="bitmask:DeCode(current(), 2) " > No idea what this extension function does... > <xsl:variable name="Pos" > > <xsl:value-of > select="MapKey/@*[name() = $AttrName]" /> Your MapMD element doesn't have a child called MapKey... I give up. Show us your whole source document, your whole stylesheet, and explain what your extension function does. Michael Kay Software AG home: Michael.H.Kay@xxxxxxxxxxxx work: Michael.Kay@xxxxxxxxxxxxxx > </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 > > XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] Stuck on Name() and varia, Joerg Heinicke | Thread | RE: [xsl] Stuck on Name() and varia, Kimberly Hahn |
[xsl] RE: iterating through attribu, Michael Kay | Date | RE: [xsl] Grouping examples make my, Michael Kay |
Month |