# 22. Virtuoso Functions Guide - shallow

Chapter Contents | Prev | Next
Keyword Search:
www.openlinksw.com
docs.openlinksw.com
Book Home
Contents
Preface
Virtuoso Functions Guide
Administration
Aggregate Functions
Array Manipulation
BPEL APIs
Backup
Compression
Cursor
Date & Time Manipulation
Debug
Dictionary Manipulation
Encoding & Decoding
File Manipulation
Free Text
Hashing / Cryptographic
LDAP
Locale
Mail
Miscellaneous
Number
Remote SQL Data Source
Replication
SOAP
SQL
String
Transaction
Type Mapping
UDDI
User Defined Types & The CLR
Virtuoso Java PL API
Virtuoso Server Extension Interface (VSEI)
Web Server & Internet
XML
XPATH & XQUERY
and
append
assign
avg
boolean
ceiling
concat
contains
count
create-attribute
create-comment
create-element
create-pi
current
distinct
doc
document
document-literal
empty
ends-with
every
except
false
filter
floor
fn:collection
for
format-number
function-available
generate-id
id
if
intersect
is_after()
is_before()
key
lang
last
let
list()
local-name
max
min
name
namespace-uri
normalize-space
not
number
or
position
processxquery
processxslt
processxsql
progn()
replace()
round
serialize
shallow
some
starts-with
string
string-length
substring
substring-after
substring-before
sum
system-property
text_contains()
translate
true
tuple()
union
unordered
unparsed-entity-uri
urlify
xmlview
Functions Index

## shallow

Returns a shallow copy of the given XML entity
entity shallow ( ent entity);
Description

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.

Parameters
ent – The XML entity to copy
Return Types

The function returns an XML entity.

Errors

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.

Examples
Find Martha's spouse

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)

See Also

filter()