Joe Wicentowski
2012-07-09 18:45:23 UTC
Hi all,
I'm having a problem with query I wrote that makes use of the XQuery
Update Facility. The problem is that unwanted whitespace inserted
into the results of my query. Here is my source XML (a TEI-like
list), the query in question, and the output showing the unwanted
whitespace:
source.xml:
-----------------
<list>
<item>See <ref target="#MIDDLEEAST">Middle East</ref></item>
<item xml:id="MIDDLEEAST">Middle East <ref target="#d68">68</ref></item>
</list>
fix-ids.xq:
--------------
let $doc := doc('source.xml')
for $item-id at $count in $doc//item/@xml:id
let $new-id := concat('in', $count)
let $new-target := concat('#', $new-id)
let $targets := $doc//ref[@target = concat('#', $item-id)]/@target
return
(
(: fix @xml:ids :)
replace value of node $item-id with $new-id
,
(: fix @targets :)
for $target in $targets
return
replace value of node $target with $new-target
)
output:
----------
<list>
<item>See <ref target="#in1">Middle East</ref>
</item>
<item xml:id="in1">Middle East <ref target="#d68">68</ref>
</item>
</list>
Note that while the query only modifies attribute values, the results
of the query are somehow re-indented. (Specifically, in the source,
there was no whitespace between </ref> and </item>, but in the
results, </item> is on a new line.
Is this a serialization issue? Is there a way for me to declare some
options that will prevent the unwanted whitespace from being inserted?
I'm not sure whether this is a general XQuery issue or an
implementation-specific issue, so let me know if this isn't the right
forum for this question. I'm using oXygen 13 in XQuery Debugger mode
with Saxon EE-XQuery 9.3.0.5.
(On a related note, I see that XQuery 3.0 has new support for
serialization options --
http://www.w3.org/TR/xquery-30/#id-serialization -- but oXygen doesn't
seem to allow combining XQuery 3.0 with XQuery Update Facility and
Saxon EE. This forum post instructs users to disable XQuery 1.1/3.0
support in order to use XQUF:
http://www.oxygenxml.com/forum/topic6615.html.)
Thanks,
Joe
I'm having a problem with query I wrote that makes use of the XQuery
Update Facility. The problem is that unwanted whitespace inserted
into the results of my query. Here is my source XML (a TEI-like
list), the query in question, and the output showing the unwanted
whitespace:
source.xml:
-----------------
<list>
<item>See <ref target="#MIDDLEEAST">Middle East</ref></item>
<item xml:id="MIDDLEEAST">Middle East <ref target="#d68">68</ref></item>
</list>
fix-ids.xq:
--------------
let $doc := doc('source.xml')
for $item-id at $count in $doc//item/@xml:id
let $new-id := concat('in', $count)
let $new-target := concat('#', $new-id)
let $targets := $doc//ref[@target = concat('#', $item-id)]/@target
return
(
(: fix @xml:ids :)
replace value of node $item-id with $new-id
,
(: fix @targets :)
for $target in $targets
return
replace value of node $target with $new-target
)
output:
----------
<list>
<item>See <ref target="#in1">Middle East</ref>
</item>
<item xml:id="in1">Middle East <ref target="#d68">68</ref>
</item>
</list>
Note that while the query only modifies attribute values, the results
of the query are somehow re-indented. (Specifically, in the source,
there was no whitespace between </ref> and </item>, but in the
results, </item> is on a new line.
Is this a serialization issue? Is there a way for me to declare some
options that will prevent the unwanted whitespace from being inserted?
I'm not sure whether this is a general XQuery issue or an
implementation-specific issue, so let me know if this isn't the right
forum for this question. I'm using oXygen 13 in XQuery Debugger mode
with Saxon EE-XQuery 9.3.0.5.
(On a related note, I see that XQuery 3.0 has new support for
serialization options --
http://www.w3.org/TR/xquery-30/#id-serialization -- but oXygen doesn't
seem to allow combining XQuery 3.0 with XQuery Update Facility and
Saxon EE. This forum post instructs users to disable XQuery 1.1/3.0
support in order to use XQUF:
http://www.oxygenxml.com/forum/topic6615.html.)
Thanks,
Joe