[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: Joerg Heinicke <joerg.heinicke@xxxxxx>
Date: Tue, 06 Aug 2002 02:26:44 +0200
xsl decode
After a quick look on your code, I would suggest, that the error is in this line:

<xsl:value-of select="MapMD/attribute::*[name() = $AttrName]" />

The context node is (from the for-each) an attribute of //Map[@schema], so you are searching for //Map[@schema]/attribute::*[position() &gt; 2]/MapMD/attribute::*[name() = $AttrName]. But an attribute can never have an element as child node.

Maybe in front of the for-each you have to store MapMD in a variable:
(I don't know what's the current context.)

<xsl:variable name="MapMD" select="MapMD"/>

and refer to it in the for-each:

<xsl:value-of select="$MapMD/attribute::*[name() = $AttrName]" />

Some more comments on your code (even it would be interesting to know the context of this code):

<xsl:attribute name="data">
  <xsl:variable name="Market" select="node()"/>

Are you sure you want to store all child nodes of the current context node in this variable?


<xsl:variable name="Key" select="parent::node()"/>

If you can answer the last question with 'yes', then you can shorten this code to <xsl:variable name="Key" select="."/>


<xsl:for-each select="//Map[@schema]/attribute::*[position() &gt; 2]" >

I think it's very dangerous to rely on position() when using on attribute::*. There is no order of attributes, maybe you should exclude some attributes by their name and not their position:


<xsl:for-each select="//Map[@schema]/attribute::*[name() != 'col0']">

Furthermore maybe you can replace '//' with a more explicite XPath expression.

      <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>

Here you are creating a Result Tree Fragment, that later has to be converted into a string. I think it's better to write


<xsl:variable name="Pos" select="MapKey/@*[name() = $AttrName]"/>

to have already a string stored in the 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>

Same here.


                  4(<xsl:value-of select="$Pos" />)(<xsl:value-of
select="$AttrName" />) <xsl:value-of select="$Market/attribute::*[position()
= $Pos]" />

Again attributes and position(). Try to refer to attributes by their name - if possible in any way.


            </xsl:when>
      </xsl:choose>
      <xsl:if test = "position() != last()"> | </xsl:if>
   </xsl:for-each>
</xsl:attribute>

Regards,


Joerg


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.