Database Reference
In-Depth Information
<xi:include href= "includethisxml.xml" xpointer= "xpointer(//Line[1])" />
<xi:include href= "file:///file/from/filesystem.xml"
xpointer= "xpointer(//customer[@id eq '123'])" />
Including Query Results
If the href attribute references an XQuery script stored in the database, the script will
be executed and the results included.
The executing script can get information about the master document with two vari‐
ables (you don't have to explicitly declare them as external unless you wish to):
$xinclude:current-doc
The name of master document without the collection path
$xinclude:current-collection
The collection for the master document
These variables are implicitly declared by the XInclude processor.
This means that if you want to use the same script outside of the
XInclude context, you can't use (reference) them!
Passing your own parameters is also possible. For instance, when you have an XIn‐
clude that looks like this:
<xi:include href= "script.xq?par1=abcdef" />
you can reference the par1 parameter in your script as $par1 by declaring it as an
external variable:
declare variable $ par1 external ;
Limiting the output by using XPointer, as when including documents, is not possible
for XQuery results.
Error Handling and Fallback
If you try to include a resource that doesn't exist, an error will be generated. You can
prevent this by specifying an xi:fallback element:
<xi:include href= "includethisxml.xml" >
<xi:fallback><p> XML not found! </p></xi:fallback>
</xi:include>
Search WWH ::




Custom Search