Database Reference
In-Depth Information
</company>
</xf:instance>
...
</xf:model>
you could instead store your instance document into eXist and construct your
instance like so:
<xf:model>
<xf:instance xmlns= ""
src= "http://localhost:8080/exist/rest/db/companies/exist-solutions.xml" />
...
</xf:model>
While the end result is the same, there are several advantages to be gained from using
the latter approach:
Content reuse
Your instance data can be reused in different applications, and may not necessar‐
ily be exclusive to your XForm.
Security
eXist provides an extensive security system and offers authorization and authen‐
tication for resources in the database. Therefore, you can separately manage the
security constraints of your data and your forms, which may have different
requirements.
Architecture
While referencing the URL of the instance still provides a static instance, it is a
pattern that we can reuse to provide a dynamic instance instead.
Instances and XQuery
We have seen how you may request an instance from eXist's REST Server with
XForms rather than inlining the instance content, but up to this point the instances
have been static. Here we look at generating an instance dynamically using XQuery.
Imagine that in the database we have a collection of XML documents ( /db/weather ),
one for each day, that describes the weather for that day. In our form we may wish to
display some information about today's weather. By sending a small piece of XQuery
to the REST Server as part of an HTTP GET request, we can retrieve the correct
weather document for our instance. Such a request to the REST Server may look like:
http://localhost:8080/exist/rest/db/weather?_query=
/weather[@date eq current-date()]
Search WWH ::




Custom Search