|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: Re: How to do an 'existence' test in XSL? - Simple
Hi Ben,
At 07:28 AM 12/23/2004, you wrote: I wondered if Mukul's suggestion could be generalised to function on cases where the desired tags in the input xsl may be at any level of nesting e.g. with 'alertBox' we might have : It certainly works, and has been used. In fact it might be called the "canonical" solution. (As Mukul remarked, sometimes it also needs to be extended a bit to account for ancestors.) +In what ways might this +not+ be the general solution to the problem?+ It's very general, but commonly avoided simply because of its performance implications. (The simple shift from preceding:: to preceding-sibling::, in cases where the nodes are not scattered, helps with this which may be why Mukul used the latter.) In a naive implementation, the entire tree will be traversed backwards to the beginning for every @type attribute checked. That's pretty serious cycling. It is certainly logical, and elegant. Yes, as XSLT so often is, when you give it a chance. Though admittedly its logic is its own. :-) You also wrote: However, the scenario I outlined was overly simplistic. Expat is a XML parser, not an XSLT processor. I don't know offhand which processor PHP5 is using. But determining whether keys are supported is easy. (Clark's XT processor didn't implement keys but that's a different chunk of code from expat. For one, XT is in Java while Expat is in C.) In this case I wonder which of the various proposed techniques will work! Both my in-between solution, and Dimitre's (which I'll let him explain, but which amounts to a more sophisticated XSLT-2 version of the approach I used, using a sequence instead of a node-set) will both work with scattered nodes, given a tweak or two. So will George's brute-force technique. Cheers, Wendell
|
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








