This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
Re: sort by attribute text
- From: Wendell Piez <wapiez at mulberrytech dot com>
- To: xsl-list at lists dot mulberrytech dot com
- Date: Tue, 26 Mar 2002 17:23:40 -0500
- Subject: Re: [xsl] sort by attribute text
- References: <5.1.0.14.0.20020326141548.0214d2b0@earthlink.net>
- Reply-to: xsl-list at lists dot mulberrytech dot com
Mike,
At 04:21 PM 3/26/2002, you wrote:
>Nice to know it was not my syntax. I guess I need to take another
>look at the book.
Nope, it's not. It's the same thing as before, understanding how XPath
expressions work, particularly in relation to the context node.
select="*" gets you a different set of nodes depending on what the context
is for the expression. This is a technical way of explaining why it usually
matters what your template has matched on.
At some point all this stuff should click. XPath is really quite simple
once you've assimilated a few basic, but non-obvious facts. According to
the spec (XPath 1), any expression is evaluated in a context, which includes:
* a node (the context node)
* a pair of integers:
1. the context size
i.e. how many nodes were selected with this one
is returned by the last() function
2. the context position
i.e. which node is this one among the ones it was selected with
is returned by the position() function
* variable bindings in scope
* available function library (XPath, XSLT, extension functions, etc.)
* namespaces in scope
In order to evaluate any arbitrary expression, the processor needs to know
what all these are. In order to understand how your own XPath expressions
work, it's helpful for you to know what they are, too. They're not hard to
figure out: the context node, size and position are determined by the
selection of nodes in your apply-templates or for-each instructions (or, in
predicates, by the steps in your location paths). The others are either
predefined, or directly under your control, or (in the case of namespaces
in the source) static with respect to the source document.
But many beginners have not assimilated that even the first one, the
context node, matters -- and it's often downhill from there.
Cheers,
Wendell
======================================================================
Wendell Piez mailto:wapiez@mulberrytech.com
Mulberry Technologies, Inc. http://www.mulberrytech.com
17 West Jefferson Street Direct Phone: 301/315-9635
Suite 207 Phone: 301/315-9631
Rockville, MD 20850 Fax: 301/315-8285
----------------------------------------------------------------------
Mulberry Technologies: A Consultancy Specializing in SGML and XML
======================================================================
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list