Item Separator
Tuesday, 27 February 2024 · 5 messages · last reply 29 Feb 2024
LS
Leo Studer27 Feb 2024 12:03 #
Hello
I am serialising the following expressions on oxygen/saxonEE12.3 as text (item-separator=“”) and wonder why the differente outputs
let $xml:=<xml><element>text1</element><element>text2</element></xml> return $xml/element/text()gives
text1text2
And
let $xml:=<xml><element>text1</element><element>text2</element></xml> return $xml/element/string()text1 text2
When I set the item-separator =“, “ then I get
text1, text2
Or
text1, , text2
Any explanations???
Thanks,
Leo
HR
Hans-Juergen Rennau27 Feb 2024 12:16 #
Dear Leo,
it is important to remember that serialization - the transformation of the logical query result, which is an XDM value, into a sequence of octets - is defined by a W3C spec [1], and this definition is extremely detailed and precise. The item separator parameter is applied when concatenating strings. It is not applied when concatenating text nodes, the contents of which are concatenated without any separator. In one case of your example the logical query result is a sequence of text nodes, in the other case it is a sequence of strings. By the way, extreme standard conformance is a hallmark of BaseX. Kind regards,Hans-Jürgen
[1] https://www.w3.org/TR/xslt-xquery-serialization-31/
Am Dienstag, 27. Februar 2024 um 12:03:55 MEZ hat Leo Studer <leo.studer at varioweb.ch> Folgendes geschrieben:
Hello
I am serialising the following expressions on oxygen/saxonEE12.3 as text (item-separator=“”) and wonder why the differente outputs
let $xml:=<xml><element>text1</element><element>text2</element></xml> return $xml/element/text()gives
text1text2
And
let $xml:=<xml><element>text1</element><element>text2</element></xml> return $xml/element/string()text1 text2
When I set the item-separator =“, “ then I get
text1, text2
Or
text1, , text2
Any explanations???
Thanks,Leo
LS
Leo Studer27 Feb 2024 22:01 #
Thanks Hans-Jürgen
Indeed, with BaseX I get the same output for text nodes and strings. This is also how I understand the serialisation definition. Eventually Saxonica has another take on this???
Warmest,
Leo
Quoted text · Hans-Juergen Rennau · 45 lines
> On 27 Feb 2024, at 12:16, Hans-Juergen Rennau <hrennau at yahoo.de> wrote: > > Dear Leo, > > it is important to remember that serialization - the transformation of the logical query result, which is an XDM value, into a sequence of octets - is defined by a W3C spec [1], and this definition is extremely detailed and precise. > > The item separator parameter is applied when concatenating strings. It is not applied when concatenating text nodes, the contents of which are concatenated without any separator. In one case of your example the logical query result is a sequence of text nodes, in the other case it is a sequence of strings. By the way, extreme standard conformance is a hallmark of BaseX. > > Kind regards, > Hans-Jürgen > > [1] https://www.w3.org/TR/xslt-xquery-serialization-31/ > > Am Dienstag, 27. Februar 2024 um 12:03:55 MEZ hat Leo Studer <leo.studer at varioweb.ch> Folgendes geschrieben: > > > Hello > > I am serialising the following expressions on oxygen/saxonEE12.3 as text (item-separator=“”) and wonder why the differente outputs > > let $xml:=<xml><element>text1</element><element>text2</element></xml> return $xml/element/text() > > gives > text1text2 > > And > > let $xml:=<xml><element>text1</element><element>text2</element></xml> return $xml/element/string() > > text1 text2 > > > When I set the item-separator =“, “ then I get > > text1, text2 > > Or > > text1, , text2 > > > Any explanations??? > > Thanks, > Leo
MH
Martin Honnen27 Feb 2024 22:32 #
Just to be clear:
Is item-separator set as the empty string or is it not set at all for the cases where you don't get the result you expect?
My tests with (the lastest) Saxon HE 12.4:
declare namespace output =
"http://www.w3.org/2010/xslt-xquery-serialization";
declare option output:method 'text';
let $xml:=<xml><element>text1</element><element>text2</element></xml>
return $xml/element/text()gives
text1text2
while
declare namespace output =
"http://www.w3.org/2010/xslt-xquery-serialization";
declare option output:method 'text';
let $xml:=<xml><element>text1</element><element>text2</element></xml>
return $xml/element/string()gives
text1 text2
On the other hand
declare namespace output =
"http://www.w3.org/2010/xslt-xquery-serialization";
declare option output:method 'text';
declare option output:item-separator '';
let $xml:=<xml><element>text1</element><element>text2</element></xml>
return $xml/element/text()gives
text1text2
as does
declare namespace output =
"http://www.w3.org/2010/xslt-xquery-serialization";
declare option output:method 'text';
declare option output:item-separator '';
let $xml:=<xml><element>text1</element><element>text2</element></xml>
return $xml/element/string()I see that as correct reading
https://www.w3.org/TR/xslt-xquery-serialization-31/#serdm, in particular points 3, 4, 5, 6 of the steps in computing a normalized sequence.
Quoted text · Leo Studer · 69 lines
On 27/02/2024 22:01, Leo Studer wrote: > Thanks Hans-Jürgen > > Indeed, with BaseX I get the same output for text nodes and strings. > This is also how I understand the serialisation definition. Eventually > Saxonica has another take on this??? > > Warmest, > Leo > > > > >> On 27 Feb 2024, at 12:16, Hans-Juergen Rennau <hrennau at yahoo.de> wrote: >> >> Dear Leo, >> >> it is important to remember that /serialization/ - the transformation >> of the logical query result, which is an XDM value, into a sequence >> of octets - is defined by a W3C spec [1], and this definition is >> extremely detailed and precise. >> >> The item separator parameter is applied when concatenating strings. >> It is not applied when concatenating text nodes, the contents of >> which are concatenated without any separator. In one case of your >> example the logical query result is a sequence of text nodes, in the >> other case it is a sequence of strings. By the way, extreme standard >> conformance is a hallmark of BaseX. >> >> Kind regards, >> Hans-Jürgen >> >> [1] https://www.w3.org/TR/xslt-xquery-serialization-31/ >> >> Am Dienstag, 27. Februar 2024 um 12:03:55 MEZ hat Leo Studer >> <leo.studer at varioweb.ch> Folgendes geschrieben: >> >> >> Hello >> >> I am serialising the following expressions on oxygen/saxonEE12.3 as >> text (item-separator=“”) and wonder why the differente outputs >> >> *let**$xml*:=<xml><element>text1</element><element>text2</element></xml>*return**$xml*/*element*//text/() >> >> gives >> text1text2 >> >> And >> >> *let**$xml*:=<xml><element>text1</element><element>text2</element></xml>*return**$xml*/*element*//string/() >> >> text1 text2 >> >> >> When I set the item-separator =“, “ then I get >> >> text1, text2 >> >> Or >> >> text1, , text2 >> >> >> Any explanations??? >> >> Thanks, >> Leo >
LS
Leo Studer29 Feb 2024 07:24 #
Dear Martin
Thank you for investigating.
Quoted text · Martin Honnen · 2 lines
> The "text1, , text2" I only see if oXygen shows the result as a sequence in its result viewer; I would suggest to ask the oXygen support why you get that result for that case, it seems like some quirk in their result viewer (it shows two xs:string items but for reasons I can't investigate serializes the two items for the result viewer as "text1, , text2"). >
This is incredible news. I will get to Oxygen about that. Really troubling …
Blessings,
Leo
Written for BaseX 10.7. BaseX may have changed since: please check the current documentation.
⚡Generated with XQuery