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

RE: Stuck on Name() and variable

Subject: RE: Stuck on Name() and variable
From: "Kimberly Hahn" <Kimberly.Hahn@xxxxxxxxxx>
Date: Tue, 6 Aug 2002 10:33:56 -0500
kimberly hahn
>>   <xsl:for-each
>> select="//Map[@schema]/attribute::*[position() &gt; 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() &gt; 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

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.