shallow — Returns a shallow copy of the given XML entity


entity shallow ( ent entity );


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 XML entity to copy

Return Types

The function returns an XML entity.


Table24.151.Errors signalled by shallow()

SQLState Error Code Error Text Description
XP001 XPFD6 The argument of XPATH function shallow() is not an entity To match XQuery standard, the function signal an error if ent is not an entity.
XP001 XPFD7 Persistent XML entities are not supported by XPATH function shallow() This is an artificial restriction that is to be removed in future versions of Virtuoso.


Example24.618.Find Martha's spouse

The idea of the following sample is from W3C's XQuery Use Cases (case 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)

See Also