<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://bugs.webkit.org/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.4.1"
          urlbase="https://bugs.webkit.org/"
          
          maintainer="admin@webkit.org"
>

    <bug>
          <bug_id>12632</bug_id>
          
          <creation_ts>2007-02-06 09:30:15 -0800</creation_ts>
          <short_desc>XPath: Cannot apply predicate to context node.</short_desc>
          <delta_ts>2022-07-25 17:48:53 -0700</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WebKit</product>
          <component>XML</component>
          <version>420+</version>
          <rep_platform>Mac</rep_platform>
          <op_sys>OS X 10.4</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>INVALID</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>P2</priority>
          <bug_severity>Normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="L. Daniel Burr">ldanielburr</reporter>
          <assigned_to name="Nobody">webkit-unassigned</assigned_to>
          <cc>ahmad.saleem792</cc>
    
    <cc>ap</cc>
    
    <cc>bfulgham</cc>
    
    <cc>dialtone</cc>
    
    <cc>rniwa</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>26686</commentid>
    <comment_count>0</comment_count>
    <who name="L. Daniel Burr">ldanielburr</who>
    <bug_when>2007-02-06 09:30:15 -0800</bug_when>
    <thetext>The following expression, which works correctly in Opera and Firefox, throws &quot;INVALID_EXPRESSION_ERR: DOM XPath Exception 51&quot;:

.[@*[]

This is just a simple example, but basically any attempt to apply a predicate to the context node fails with this error.  As noted above, Firefox and Opera both return the context node if the predicate evaluates as true.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>26656</commentid>
    <comment_count>1</comment_count>
      <attachid>12973</attachid>
    <who name="L. Daniel Burr">ldanielburr</who>
    <bug_when>2007-02-06 09:41:02 -0800</bug_when>
    <thetext>Created attachment 12973
Small example for reproducing this bug.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>26657</commentid>
    <comment_count>2</comment_count>
    <who name="L. Daniel Burr">ldanielburr</who>
    <bug_when>2007-02-06 09:45:49 -0800</bug_when>
    <thetext>(In reply to comment #0)
&gt; The following expression, which works correctly in Opera and Firefox, throws
&gt; &quot;INVALID_EXPRESSION_ERR: DOM XPath Exception 51&quot;:
&gt; 
&gt; .[@*[]
&gt;

Argh, somehow that didn&apos;t paste correctly.  It should be &quot;.[@name=&apos;test&apos;]&quot;.  Note that the attached sample is correct, and will reproduce the problem accurately.
 
&gt; This is just a simple example, but basically any attempt to apply a predicate
&gt; to the context node fails with this error.  As noted above, Firefox and Opera
&gt; both return the context node if the predicate evaluates as true.
&gt; 

</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>26638</commentid>
    <comment_count>3</comment_count>
    <who name="Alexey Proskuryakov">ap</who>
    <bug_when>2007-02-06 10:19:04 -0800</bug_when>
    <thetext>A workaround is to use full XPath syntax: &quot;self::*[@class=&apos;test&apos;]&quot;.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>26542</commentid>
    <comment_count>4</comment_count>
    <who name="Alexey Proskuryakov">ap</who>
    <bug_when>2007-02-06 10:33:53 -0800</bug_when>
    <thetext>Better yet, &quot;self::node()[@class=&apos;test&apos;]&quot;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>26548</commentid>
    <comment_count>5</comment_count>
    <who name="Alexey Proskuryakov">ap</who>
    <bug_when>2007-02-06 10:51:53 -0800</bug_when>
    <thetext>I think WebKit is correct here, this syntax is invalid in XPath 1.0. See rule 4 - an abbreviated step cannot have predicates.

[4] Step ::= AxisSpecifier NodeTest Predicate*	
             | AbbreviatedStep

Also, see rule 20 - since &quot;.&quot; is not a PrimaryExpr, it cannot start a FilterExpr either.

[20] FilterExpr ::= PrimaryExpr
                    | FilterExpr Predicate

From rule 20 comes another workaround: &quot;(.)[@class=&apos;test&apos;]&quot;.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>26550</commentid>
    <comment_count>6</comment_count>
    <who name="Alexey Proskuryakov">ap</who>
    <bug_when>2007-02-06 11:17:42 -0800</bug_when>
    <thetext>https://bugzilla.mozilla.org/show_bug.cgi?id=369522</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>71032</commentid>
    <comment_count>7</comment_count>
    <who name="Alexey Proskuryakov">ap</who>
    <bug_when>2008-02-18 02:56:39 -0800</bug_when>
    <thetext>*** Bug 17410 has been marked as a duplicate of this bug. ***</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1886617</commentid>
    <comment_count>8</comment_count>
    <who name="Ahmad Saleem">ahmad.saleem792</who>
    <bug_when>2022-07-25 16:45:19 -0700</bug_when>
    <thetext>I am getting following behavior across all browsers:

*** Safari 15.6 on macOS 12.5 ***

Console errors when clicking link in attached test case - The string did not match the expected pattern.

*** Chrome Canary 106 ****

Console errors when clicking link in attached test case - The string &apos;.[@class=&apos;test&apos;]&apos; is not a valid XPath expression.

*** Firefox Nightly 104 ***

Nothing happens and there is no Console error.

_______

Comment 05 mentions that Webkit is right here, plus Firefox still has the bug open (Comment 06 was duplicate for https://bugzilla.mozilla.org/show_bug.cgi?id=164822). I think this can be considered as &quot;RESOLVED INVALID&quot; or &quot;RESOLVED WONTFIX&quot;? Thanks!</thetext>
  </long_desc>
      
          <attachment
              isobsolete="0"
              ispatch="0"
              isprivate="0"
          >
            <attachid>12973</attachid>
            <date>2007-02-06 09:41:02 -0800</date>
            <delta_ts>2007-02-06 09:41:02 -0800</delta_ts>
            <desc>Small example for reproducing this bug.</desc>
            <filename>webkit-xpath.html</filename>
            <type>text/html</type>
            <size>902</size>
            <attacher name="L. Daniel Burr">ldanielburr</attacher>
            
              <data encoding="base64">PCFET0NUWVBFIGh0bWwKICB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0dXJuIGZhbHNlOyI+
VHJ5IHVzaW5nIFhQYXRoIHRvIGZpbmQgbWUuPC9hPgo8L2JvZHk+CjwvaHRtbD4=
</data>

          </attachment>
      

    </bug>

</bugzilla>