Subject: RE: [xsl] Stuck on Name() and variable From: "Kimberly Hahn" <Kimberly.Hahn@xxxxxxxxxx> Date: Tue, 6 Aug 2002 10:33:56 -0500 |
>> <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. I know that this does not follow standards set for XML. The order of attributes in this case is well defined. This is an internal process handling internally generated data. The processes that handle externally generated data do not make any assumptions on attribute order. To the external world the standards are generally followed. Internally, to handle data population and display, attribute order is very tightly controlled. It was a design decision made roughly 2 years ago. I have no worries about attribute order, SQL Server and MSXML don't alter attribute order. I try to make sure all developers on staff are aware that we are making use of a behavior that is not part of a standard. > <xsl:variable name="Market" select="node()"/> Should have been - <xsl:variable name="Market" select="current()"/> The Market variable was not holding the correct node, I discovered that last night. Thank you for the explanation as to why (that was the part I missed). Knowing why means I won't make that mistake again. The Map structure exists in a separate part of the document from the Market or Key information. Sorry for not providing more detail on that structure. <Map schema="" col0="" col1="" .... col31=""> <MapKey col1="" col2="" ... col12=""/> <MapMD col0="" col13="" col14="" ... col22="" /> </Map> MapKey and MapMD are both children of Map. A more simple example of what I need to do would be: <xsl:for-each select="//Map[@schema]/attribute::*[position() > 2]" > <xsl:variable name="AttrName" select="name()"/> <xsl:variable name="Pos" > <xsl:value-of select="MapMD/attribute::*[name() = $AttrName]" /> </xsl:variable> (<xsl:value-of select="$Pos" />)(<xsl:value-of select="$AttrName" />) <xsl:if test = "position() != last()"> | </xsl:if> </xsl:for-each> Which actually brings me to my answer... <xsl:value-of select="../MapMD/attribute::*[name() = $AttrName]" /> I didn't realize I was on an attribute of the Map node, not the Map node itself. I just needed to get to the parent of the current node/attribute to get to the node I needed. Thanks for giving me a reason to drill down on exactly where the problem is! XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
RE: [xsl] Stuck on Name() and varia, Michael Kay | Thread | RE: [xsl] Stuck on Name() and varia, Michael Kay |
RE: [xsl] access of a param, aruniima . chakrabar | Date | Re: [xsl] one xml file + one xsl fi, Charles Knell |
Month |