|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: compute an xpath expression that match a resulted
Majirus,
At 01:26 PM 10/15/2004, you wrote: Hi all, In general, no. In specific cases, you could get away with //*[.=$nodeset] but this depends on every node in your input data having a unique (string) value. (The string value of a node is the concatenation of all its text node descendants.) This is not likely to be the case, though it might be the case for your particular instance of the general question (no two books are likely to have the same author and title, which is what the string value in your example would amount to). To illustrate the problem, what would you want back if $nodeset = <author>Michael Kay</author> and your input data had <book ISBN= "0-7645-6909-0"> <title>XSLT programmer's reference 3e </title> <author>Michael Kay</author> </book> <book ISBN= "0-7645-6909-1"> <title>XSLT programmer's Guide to British Beers and Ales</title> <author>Michael Kay</author> </book> what would you want as an XPath expression? Now, your suggestion of /descendant-or-self::book[@ISBN='0-7645-6909-0'] suggests you want to leverage the fact that you know the values of your ISBN attributes are unique. That's a good idea, except that Result Tree Fragments in XSLT 1.0 are not transparent, and you have no way to reach in and grab that attribute. Most of us would recommend using exslt:node-set() or equivalent to make the fragment a node-set -- or to acquire that ISBN another way altogether so you don't have to get it from a result tree. Or use //*[.=$nodeset] and control somehow against getting false hits (say by catching as an exception cases where more than one node comes back). Good luck, 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 ======================================================================
|
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
|

Cart








