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

Re: apply-templates select and current() question

Subject: Re: apply-templates select and current() question
From: Wendell Piez <wapiez@xxxxxxxxxxxxxxxx>
Date: Thu, 19 May 2005 15:48:50 -0400
Re:  apply-templates select and current() question
At 02:43 PM 5/19/2005, you wrote:
I've correct the expression to self::db:footnote. For some reason that's never seemed intuitive to me (obviously).

Yes, it's a little bizarre until you get used to it.


The trick is to remember
(1) that = or equality does *not* test for node type or node identity
(2) node type is easily enough tested with node tests like "*" or "node()" or "name" as long as you know the axis you want to look at. ("Node test" is a formal technical term in XPath; learning what a node test is can be very helpful.) Since XPath will default to the child:: axis if your axis is not named, that means you have to do the extra work of checking on the self:: axis if you want to traverse to the node itself.


Since a node-set, coerced to a Boolean, is false for an empty set and true for a set with any nodes in it, test="self::element" will test true if the context node is an "element" element (since starting from an "element" element there is indeed an "element" element on the self:: axis).

So, it all hangs together ... but it takes practice, since a number of non-obvious design features of XPath combine to get the behavior. Note that while these come to seem normal enough once you're comfortable with the way XPath location paths are put together, they can also combine to result in more weirdness. (Languages seem to be like that: no matter what the design there are always edge cases.)

For example, self::* will return true for elements, but false when the context node is an attribute, comment, processing instruction, text node or the root (because of the way "*" is defined).

Cheers,
Wendell


====================================================================== Wendell Piez mailto:wapiez@xxxxxxxxxxxxxxxx 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 ======================================================================

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.