[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: Getting a distinct list of node names
Paul,
At 02:47 PM 4/6/2005, you wrote: Hi all, The question is an excellent one; you are thinking along the right lines, but need to take on just a bit more information -- since the actual situation is the reverse of what you're assuming. The test Ken suggested, using generate-id(), is an effective way in XSLT precisely to "compare objects", whereas testing with the equality operator you are only comparing string values. This is because of the peculiar way equality is defined to work with node sets. One node set is not only equal to another if all the nodes in the first set are also in the second, and vice-versa, but rather more broadly, if *any* of the nodes in the first set have the same *string value* as any of the nodes in the second set. What this means in practice is that the equality test is unsafe for establishing node identity. Two node sets that happen to contain the same node always test as equal; they also test as equal if one of the nodes in one set just happens to have the same value as a node in the other. Since generate-id() is defined to return a unique identifier for any given node irrespective of its value, a string comparison between generated ids is one effective workaround to the problem of establishing node identity. Another is by counting nodes in combined sets: count(.|$thisnode)=1 iff . and $thisnode are the same node. Cheers, Wendell Yours sincerely, Paul ====================================================================== 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 ======================================================================
|
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
|