xsl-list
[Top] [All Lists]

Re: [xsl] Help parsing a node

2012-04-26 17:13:35
Michele R Combs wrote:

I didn't write this line of code -- it's in a style sheet I'm attempting to 
comprehend -- so I don't want to change anything until I understand what it's 
doing.  But more to the point, it actually is working 99% of the time.  There's 
just one single case where it's counting something as unique when it shouldn't 
and I have no idea why,, which is why I'm trying to understand precisely what 
it is selecting and how.  The line I cited:

<xsl:variable name="uniqueTypes" 
select="ead/archdesc/dsc/descendant::*/container[not(@type=following::*/container/@type)]/@type"
 />

appears at the very start of the style sheet, at which point yes, there is an 
element<ead>  and yes, it will find something. Hence my first question: what 
precisely is this selecting and how?  I *think* that it is selecting certain @type 
attributes from various<container>  elements but I'm not sure which ones, or how it 
knows that they're unique.

The variable $uniqueTypes is then used later at various places in the code, for 
example:

<xsl:for-each select="$uniqueTypes">

Hence my second question, whether $uniqueTypes  is the same no matter where it 
gets used later.

A variable gets one value and that value never changes, even if the variable is used in different locations.

If the xsl:variable element is a child of the xsl:stylesheet element then it is a global variable and then I think a relative path is evaluated relative to the initial context node which is usually the root node (also called document node).

I don't see why you would get different results with the same variable used in different places unless there is local parameter or variable of the same name hiding the global one.

--

        Martin Honnen --- MVP Data Platform Development
        http://msmvps.com/blogs/martin_honnen/

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--

<Prev in Thread] Current Thread [Next in Thread>