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

RE: Ridiculous XPath expression, can I reduce it?

Subject: RE: Ridiculous XPath expression, can I reduce it?
From: Nick Vincent <Nick@xxxxxxxxxxxx>
Date: Tue, 3 Apr 2001 13:59:48 +0100
nick vincent
Hi again,

Sorry I didn't explain that properly, but I wanted to keep the post
relatively short.  Let me explain more thoroughly...

Basically what I'm doing is writing a form handler that can handle nested
forms within a page, and in order to do that I have to find the <input.?>
elements which are under a given <input.form> (the context node), but are
not under an <input.form> beneath that, and also are not beneath an
<input.link> node, which implies a different behaviour.  These items must
also not have a 'form.prefix' attribute as that means they've already been
dealt with.

Once I've processed an <input.form> element I mark it with a 'done'
attribute to stop it being processed again (trust me on that one).

e.g. (asterisks are selected nodes)

  <input.form done='true'> <== Context node
    <input.form name='john'>
     *<input.button name='pete'/>
      <input.form name='steve'>
        <input.button name='clive'/>
     *<input.button name='dudley'/>
     *<input.text name='foo' />
    <input.button name='alan' size='big' color='red'/>

For reference the form of the query is:

.//input.button[count(ancestor::input.form[not(@done)])=1 and
not(@form.prefix) and not(ancestor::input.link)] |
.//input.text[count(ancestor::input.form[not(@done)])=1 and
not(@form.prefix) and not(ancestor::input.link)]

Hope this helps,


> -----Original Message-----
> From: David Carlisle [mailto:davidc@xxxxxxxxx]
> Sent: 03 April 2001 13:17
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Subject: Re:  Ridiculous XPath expression, can I reduce it?
> ^W on emacs (or ^X on a windows-y editor would probably make it
> smaller...)
> > which basically finds all the elements that exist below any given
> > <input.form> tag but not below an <input.link> tag.
> does it?
> If I didn't look at the sample code you'd posted I'd code the 
> requested
> selection as 
> .//*[ancestor::input.form and not(ancestor::input.link)]
> The code you posted seemed to be doing something with @done
> and also checking there was exactly one ancestor.
> Also it restricted * to a fixed list of element names.
> You may change * in the above to
> *[self::input.hidden or self::input.text or ....]
> if you really need this restriction.
> David
> _____________________________________________________________________
> This message has been checked for all known viruses by Star 
> Internet delivered
> through the MessageLabs Virus Control Centre. For further 
> information visit
> http://www.star.net.uk/stats.asp
>  XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list

Current Thread


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.
First Name
Last Name
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.