|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: Stuck on Name() and variable
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() > 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() > 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. 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. 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. Regards, Joerg XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|

Cart








