Hello,
I have a string that I want to parse using fn:parse-xml-fragment (in BaseX 8.4.1). I noticed that there seemed to be a difference when wrapping the string in a string constructor versus plain quotes.
Using the string constructor seems to require a second function call in order to parse the XML.
The following three expressions illustrate the difference. Numbers 2 and 3 return parsed XML, whereas number 1 returns the original, unparsed string. Is this the expected behavior when using string constructors?
1. ``[<span start="" end="3">Sed</span> ut perspiciatis]`` => parse-xml-fragment()
2. ``[<span start="" end="3">Sed</span> ut perspiciatis]`` => parse-xml-fragment() => parse-xml-fragment()
3. '<span start="" end="3">Sed</span> ut perspiciatis' => parse-xml-fragment()
-- Tim A. Thompson Metadata Librarian (Spanish/Portuguese Specialty) Princeton University Library
Hi Tim,
The following three expressions illustrate the difference. Numbers 2 and 3 return parsed XML, whereas number 1 returns the original, unparsed string. Is this the expected behavior when using string constructors?
Yes, this is how it should be. With plain quotes, entities will be resolved. However, this is not the case when using the string constructor:
for $string in ('<', ``[<]``) return <cp>{ string-to-codepoints($string) }</cp>
Does this help? Christian
``[<span start="" end="3">Sed</span> ut perspiciatis]`` => parse-xml-fragment()
``[<span start="" end="3">Sed</span> ut perspiciatis]`` => parse-xml-fragment() => parse-xml-fragment()
'<span start="" end="3">Sed</span> ut perspiciatis' => parse-xml-fragment()
basex-talk@mailman.uni-konstanz.de