RE: [xsl] Ridiculous XPath expression, can I reduce it?

Subject: RE: [xsl] Ridiculous XPath expression, can I reduce it?
From: Nick Vincent <Nick@xxxxxxxxxxxx>
Date: Tue, 3 Apr 2001 13:59:48 +0100
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
<> 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(] |
.//input.text[count(ancestor::input.form[not(@done)])=1 and
not(@form.prefix) and not(]

Hope this helps,


> -----Original Message-----
> From: David Carlisle [mailto:davidc@xxxxxxxxx]
> Sent: 03 April 2001 13:17
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Subject: Re: [xsl] 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 <> 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(]
> 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
>  XSL-List info and archive:

 XSL-List info and archive:

Current Thread