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

RE: getting the text nodes from a set of attribute nod

Subject: RE: getting the text nodes from a set of attribute nodes
From: Wendell Piez <wapiez@xxxxxxxxxxxxxxxx>
Date: Thu, 04 Sep 2003 15:20:44 -0400
xpath getting text node
Robert,

At 02:53 PM 9/4/2003, you wrote:
but that was my point.  the sample XSL i showed for calculating the
minimum value was *treating* a node-set as if the individual elements
were numbers, and was comparing them numerically.

<xsl:value-of select="$nodes[not($nodes &lt; .)]"/>

how would this be interpreted?

As in plenty of other cases in XSLT (1.0), the processor is performing a bit of data type casting for you -- turning nodes into numbers. The rules for this are detailed in the XPath spec. Here, when a node must be construed as a number (required by the less-than operation), it is (a) turned into a string by taking its string value, and (b) then turned into a number following the string-to-number rules you'd expect.


(This particular routine is also relying on a rule of how to compare numerical values with node-sets containing more than one node -- compare each pairing in turn, return true if any are true.)

  the book refers to this as calculating
"the minimum value of a node set", which to my mind is viewing the
"nodes" as numerical values.

Their *values* are numbers (as they are also strings, if we need strings). Any string can be turned into a number ... if it can't, it is anyhow -- the number not-a-number (NaN). And any node can be turned into a string. Ergo, etc.


But really the technique you're citing from the book is robust only in such cases where you know ahead of time the nodes in the set will all cast to numbers cleanly.

  i wasn't trying to suggest that numbers
were actual nodes, only that they were being "treated" that way by
the above expression.

Yes, XPath 1.0 invites this kind of "treat as if" thinking. Most of the time, it's a welcome feature of the language. Sometimes it gets us into tangles.


All of this will change drastically in XPath 2.0, where casts must be made explicitly. Then we get to see what life is like on the other side of the fence.

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


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.