xpathxquerybasex

BaseX stopped finding anything with XPath


I am a (so far) happy user of BaseX for a few month, but when I wanted to use this tool Today I noticed that for some weird reason the Xpath expressions and Xquery stopped working.

Whatever I type as XPath or Xquery just always returns "0 results" empty result. Not sure if there is any setting that I've set by mistake, but queries are good. I could test them with the same document in other tools - they are selecting things correctly

What is weirder, is that when I type an Xpath it looks like the typeahead suggests correct tags that come next in the tree etc. All the visual-navigation views work correctly but XPath or XQuery just does not work at all.

Anybody had such a problem and maybe found what is causing it?

Thank you

mono


Solution

  • Thank you very much for your help. I have found it in the meantime. Just needed some sleep probably. So. Actually BaseX did not stop working. It was a coincidence related to the fact that I have just started working with different files.

    I will not bore you with the description of trying different things, but here is what was throwing BaseX out of the way (which is weird but still)

    The document that was not working started with this tag:

    <VendorItems xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://RedouteFrance/CAT-EXT-INTG/Product/VendorItems/1.0" xsi:schemaLocation="http://RedouteFrance/CAT-EXT-INTG/Product/VendorItems/1.0 VendorItems_1.0.xsd">
      <VendorItem>
        <EAN>4004758705459</EAN>
    

    ... and down the road it just contained many VendorItem blocks

    So for example, a query like this, should return me all EANs //EAN/text() But the result was always empty. However the same document opened in N++ with XPath plugin worked fine.

    I have luckily found this old SO question and answer -> Querying XML files using BaseX

    So, inspired by this I have just removed the contents of the tag so it looks like this:

    <VendorItems>
      <VendorItem>
        <EAN>4004758705459</EAN>
    

    And, like by magic, BaseX started finding things correctly when queried via Xpath or Xquery...

    I still do not get fully why those namespaces declarations were harmful, but I am glad it works now.

    Best mono