Saxon - XPATH: how to get rid of namespace specification?

I've many simple self-made XML files without namespace specifications (I don't need them, I just want to keep them minimalist).


Open in new window

However every time I want to get an XPath extraction with a XQuery in Saxon I always have to specify "*" namespace, like this:  "/*:root/*:two"

With Basex I can just write  "/root/two" and it works.

How can I use the minimalist "/root/two" in Saxon too, without modifying my XML files?  what command/switch must I write in the XQuery or in the commandline for Saxon?
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Geert BormansInformation ArchitectCommented:
Have you set by any chance a default XPath namespace?
If your XML is really pure, Saxon does not need the *: prefix
So your XML either is less namespace free then you think
or you told saxon the default XPath namespace is something other than the null namespace
Geert BormansInformation ArchitectCommented:
is this one of the projects where you are using tagsoup first?
tagsoup sets a default namespace to the xhtml namespace
lucavillaAuthor Commented:
I tried with and without a default namespace in the XQwery but I fear that I used Tagsoup in these test, I didn't know that it adds a namespace. Thanks for the info!

I'll check again better and report results...
Exploring SQL Server 2016: Fundamentals

Learn the fundamentals of Microsoft SQL Server, a relational database management system that stores and retrieves data when requested by other software applications.

Geert BormansInformation ArchitectCommented:
tagsoup adds the XHTML namespace (unless specified differently)
"Namespaces are suppressed. Normally, all elements are in the XHTML 1.x namespace, and all attributes are in no namespace."

the namespace you are after:

if you are using saxon:parse-html()... I have no idea on how to set the configuation parameter

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
lucavillaAuthor Commented:
I'm using
'-x:"org.ccil.cowan.tagsoup.Parser"'     command line switch for Saxon

"declare option db:parser 'html';"    XQuery line  for Basex

should I use '-x:"org.ccil.cowan.tagsoup.Parser" -nons'   for Saxon?
and do you know for Basex too?
Geert BormansInformation ArchitectCommented:
Ah, you don't do saxon:parse-html() at all, you use Tagsoup as the underlying parser
that area is really not very well documented.
I don't think Saxon simply picks up the command line settings for TagSoup and passes them on
(a few weeks back I made a java integration of TagSoup in an other context and I had a hard time figuring out how some simple command line parameters for TagSoup were to be passed on through the Java parser call, so I would suspect that Saxonica did not bother too much)
Nothing wrong with trying the --nons option (note, 2 dashes!)
But I fear...

However, you know the namespace after TagSoup, just introduce it in your XQuery

For Basex, I have no real clue
lucavillaAuthor Commented:
I tried '-x:"org.ccil.cowan.tagsoup.Parser" --nons'   and   '-x:"org.ccil.cowan.tagsoup.Parser" --nons' but I've got two different errors...   they didn't work.
Anyway thanks for the info!
lucavillaAuthor Commented:
Sorry I meant:
'-x:"org.ccil.cowan.tagsoup.Parser" --nons'  
'-x:"org.ccil.cowan.tagsoup.Parser --nons"'
Geert BormansInformation ArchitectCommented:
well, I did not expect any of the two to work
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.