This is the first time I've run into the Xquery (3.1) error Content for update is empty
and a search on Google returns nothing useful.
If I run this simple query to identify nested /tei:p/tei:p
:
for $x in $mycollection//tei:p/tei:p
return $x
I get XML fragments like the following:
<p xmlns="http://www.tei-c.org/ns/1.0"/>
<p xmlns="http://www.tei-c.org/ns/1.0">Histoires qui sont maintenant du passé (Konjaku monogatari shū). Traduction, introduction et
commentaires de Bernard Frank, Paris, Gallimard/UNESCO, 1987 [1re éd. 1968] (Connaissance de
l'Orient, Série japonaise, 17), p. 323. </p>
<p xmlns="http://www.tei-c.org/ns/1.0">Ed. Chavannes, Cinq cents contes et apologues extraits du Tripitaka chinois, Paris, t. 4,
1934, Notes complémentaires..., p. 147.</p>
<p xmlns="http://www.tei-c.org/ns/1.0"/>
<p xmlns="http://www.tei-c.org/ns/1.0">Ed. Chavannes, Cinq cents contes et apologues extraits du Tripitaka chinois, Paris, t. 4,
1934, Notes complémentaires..., p. 129.</p>
i.e. some with text()
and others empty
I am trying to "de-duplicate" the /tei:p/tei:p
, but the following attempts return the same aforementioned error:
for $x in $mycollection//tei:p/tei:p
return update replace $x with $x/(text()|*)
for $x in $mycollection//tei:p/tei:p
let $y := $x/(text()|*)
return update replace $x with $y
I don't understand what the error is trying to tell me in order to correct the query.
Many, many thanks.
edit:
for $x in $mycollection//tei:p[tei:p and count(node()) eq 1]
let $y := $x/tei:p
return update replace $x with $y
I also tried this, replacing parent
with self
axis, which resulted in a very ambiguous error exerr:ERROR node not found
:
for $x in $mycollection//tei:p/tei:p
let $y := $x/self::*
return update replace $x/parent::* with $y
solution:
for $x in $local:COLLECTIONS//tei:p/tei:p
return if ($x/(text()|*))
then update replace $x with $x/(text()|*)
else update delete $x