This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: Ridiculous XPath expression, can I reduce it?


>  > I found this XPath expression lurking in some code, and I'm thinking this
>  > *may well* not be the most efficient way of performing this task, which
>  > basically finds all the elements that exist below any given <input.form> 
tag
>  > but not below an <input.link> tag.
>  > 
>  > Here is the horror:
>  > 
>  > .//input.hidden[count(ancestor::input.form[not(@done)])=1 and
>  > not(@form.prefix) and not(ancestor::input.link)] | 
> 
> ...
> 
> using "starts-with(name(.),'input.')" might reduce it somewhat

What about
.//*[self::input.hidden or self::input.text or self::input.textarea or ....]
    [count(ancestor::input.form[not(@done)])=1 and
     not(@form.prefix) and not(ancestor::input.link)]

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

(.... is just my abbreviation)

> personally, I'd let all the elements get processed, but add a
> 
>  <xsl:if test="not(ancester::input.link)">
> ...
>  </xsl:if>
> 
> condition in the template

Vincent didn't tell us, if input.link is an ancestor of the context
node. The original test looks for an ancestor of the input.... elements.

Cheers,
Oliver


/-------------------------------------------------------------------\
|  ob|do        Dipl.Inf. Oliver Becker                             |
|  --+--        E-Mail: obecker@informatik.hu-berlin.de             |
|  op|qo        WWW:    http://www.informatik.hu-berlin.de/~obecker |
\-------------------------------------------------------------------/


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]