At 6:00 PM -0500 3/18/02, bob mcwhirter wrote: > >Are you looking at these aspects of the code because you want to >use them directly, or because you're just checking out the general >quality (or lack thereof) of it? The AverageUser(tm) will never >look at this stuff. Of course, that's no excuse for it to be >confusing, but... >
I do want to use them. I see a lot of use cases for doing things like passing a DOM or JDOM node to one of these functions, particularly normalize-space() and string(). I suspect as I experiment more I'll find use-cases for other functions as well. I very naturally fell right into this with my standard XPaths sample app I'm implementing in about four different APIs so I don't think it's at all out of the way. Let me explain. I evaluate a location path. This gives me a node-set, potentially containing multiple nodes of various types, but especially element nodes. I now want to get the complete text of each of those nodes, i.e. the XPath string-value. I could handle this in DOM or JDOM (indeed I demo exactly this in those chapters) but it's so much easier to rely on XPath. This requires me to iterate through the list and pass each of those nodes to string() (or perhaps normalize-space). I can't just use string(location-path) because that only gives me the string value of the first node in the set. I can't use location-path/text() because the element nodes might contain substructure such as comments and processing instructions so there's potentially more than one text node. XPath 2.0 and sequences and operations on sequences may make all of this a lot easier. However, XPath 2.0 is a long way away and for the time being at least, XPath is not Turing complete, so I often find myself running some XPath, dropping out of XPath into Java to iterate or calculate or some such, and then returning to XPath. -- +-----------------------+------------------------+-------------------+ | Elliotte Rusty Harold | [EMAIL PROTECTED] | Writer/Programmer | +-----------------------+------------------------+-------------------+ | The XML Bible, 2nd Edition (Hungry Minds, 2001) | | http://www.cafeconleche.org/books/bible2/ | | http://www.amazon.com/exec/obidos/ISBN=0764547607/cafeaulaitA/ | +----------------------------------+---------------------------------+ | Read Cafe au Lait for Java News: http://www.cafeaulait.org/ | | Read Cafe con Leche for XML News: http://www.cafeconleche.org/ | +----------------------------------+---------------------------------+ _______________________________________________ Jaxen-interest mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/jaxen-interest