Thanks Martin and Michael for the “sofortige Antoworten”.Forgive my lack of understanding about the particular of whitespace processing and how BASEX deals with them.
To answer Martin’s questions:
1) I stored that xml (as I do all of my email) in the database using this commands in the basex shell:
ADD TO PROSE.test test.xml
after I created the file in vi on my desktop.
I had no xml preamble or any processing instructions about the whitespace.
2) I am also querying in the basex using XQUERY.
In short,I need to get the result with the actual text node after the element I target, even if it is null, not the next element’s non-null text.
Given my storage, is adjusting the XPATH the way Kristian suggested the best way to achieve my goal?
Concretely, how can I adjust how XQUERY executes the path directly to deal with the whitespace issue? I cannot use parse-xml(). Do I add the -w option to the XQUERY that I call from the basex client?
And concretely, how can I store the XML with preamble or processing instruction about whitespace to achieve my result?
On Feb 26, 2019, at 05:50, Michael Seiferle <
ms@basex.org> wrote:
Hi Mark,
Hi Martin,
yes Martin is right, the whitespace will be chopped by default leading to the observed behavior.
If you wanted to preserve whitespace globally, you can do that when creating your database.
If you only want to preserve whitespace for a given element you may do this as well:
let $db :=
'<text id="test">
<clause xml:space="preserve">
<word>A</word>a
<word>B</word>
<word>C</word>c
</clause>
</text>' => parse-xml() (: have to actually parse it for the whitespace preserve to have a an effect :)
return $db//word/concat(text(), ' ', normalize-space(./following-sibling::text()[1]))
Which returns:
Best
Michael
I think the result you get is caused by whitespace chopping during XML parsing, seems to be the default, seehttp://docs.basex.org/wiki/Command-Line_Options
-w | Toggles whitespace chopping of XML text nodes. By default, whitespaces will be chopped. |