title: XPath ambiguity
body: <p>I am working with the following fragment of an XPath</p>
  
  <pre><code>ancestor::contribution[1]/preceding-sibling::contribution[@speaker-reference][1]
  </code></pre>
  
  <p>My Java application (using JDOM for XPath queries) interprets this differently from our Oracle database (11g).
  I was able to solve the problem by using brackets as follows:</p>
  
  <pre><code> (ancestor::contribution[1]/preceding-sibling::contribution[@speaker-reference])[1]
  </code></pre>
  
  <p>So it seems that JDOM is reading the xpath as "the first of all preceding <code>contributions</code> with an attribute <code>@speaker-reference</code>" while Oracle thinks "the preceding <code>contribution</code> with an attribute <code>@speaker-reference and position()=1</code>".</p>
  
  <p>I had actually intended the first interpretation. I am wondering which of the two interpretations is correct according to the XPath specification (couldn't find the right place to look) or whether the specification allows expressions to be ambiguous.</p>