# 22. Virtuoso Functions Guide - xmlview

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

## xmlview

Returns the xml document corresponding to given XML view
xmlview (in view_name varchar);
Description

The function returns the output produced by an XML view as it was a content of some XML document accessed via document() XPath function. The result of the function call may be used as input of some path expression that select interesting parts of the full output of the XML view. The XQuery engine will translate the XPath expression into SQL statement in order to avoid redundant data access and to build whole XML tree.

This function may be used only in the header of FOR operator of XQuery. To specify the list of values of a variable, a path expression may be used that starts with the call of xmlview() function.

Parameters
view_name – The name of xml view
Errors

SQLState | Error Code | Error Text | Description
--- | --- | --- | ---
37000 |  | Unknown view name is passed as argument of xmlview() |

Examples

The XQUERY expressions below are queries to the following XML view:

          create xml view "cat" as
          {
            "Demo"."demo"."Categories" c as "category" ("CategoryID", "Description" as "description")
    	    {
    	          "Demo"."demo"."Products" p as "product"  ("ProductName")
    		      on (p."CategoryID" = c."CategoryID")
    	    }
          };

The first query returns all products with the attribute ProductName starting with "L". The second query returns categories with attribute CategoryID less than 10.

    for $r in xmlview("cat")//product[@ProductName like "L%"] return $r
    for $r in xmlview("cat")/category[@CategoryID<"10"] return $r