The function returns a shallow copy of the given XML entity, i.e. a root of a new document that consists of only one node that is a copy of the given entity but have no children.
The function returns an XML entity.
The idea of the following sample is from W3C's XQuery Use Cases (case 1.9.4.1.). The query should find all persons whose name is "Marta" and return entities that describes their spouses, with removed information about children.
-- read the document, then... let $doc := document("census.xml") -- for every person named "Martha"... for $m in $doc//person[@name="Martha"] -- for all (i.e. 0 or 1) her spouses... for $s in $m/@spouse => person -- return <person> element with attributes preserved but with children removed return shallow($s)