hi *,
Uli and me discussed the following idea some days ago and like to share
it here on the list for feedback.
one of the most frequent questions about Chiba is how to parameterize
URIs that are used for loading and sending data.
while this is possible by API with chibaBean.setInstanceURI or
preprocessing we found another solution that might be much more elegant
and flexible.
consider the following example:
<xf:instance
xf:src="http://{context('host')}/{context('path'}/{context('document')}" />
let me explain: the syntax follows the same lines as xslt; whenever a
pair of '{}' are found the contents is evaluated as expression and the
result of this is returned into the attribute value.
let context() be a newly defined xpath function which reads values from
the new ChibaContext class.
so for the imaginary values in ChibaContext
host=myhost
path=somepath
document=sometext
the URI would be resolved to
<xf:instance xf:src="http://myhost/somepath/sometext" />
although this is quite the same as building the string in your app and
pass it with setInstanceURI, this method is more descriptive and offers
other exciting uses.
another example:
<xf:instance
xf:src="http://{instance-value('default-instance',/data/host)}" />
by implementing another xpath function 'instance-value' one might get
access to instance-data values in the URI. so for an instance like this
<xf:instance id="default-instance" xmlns="">
<data>
<host>www.google.com</com>
</data>
</xf:instance>
this function would take an instance id as first argument and the xpath
as second and return the value. the evaluated result would be:
<xf:instance xf:src="http://www.google.com" />
the overall mechanism is simply substituting all occurrences of
bracketed expressions with the xpath evaluated results of whatever is
defined in the brackets. so sure functions can also be mixed:
<xf:instance
xf:src="http://{instance-value('',/data/host)}/login?user={context('user-name')}"
...
/>
of course it must be clearly mentioned that this isn't XForms standard
but nevertheless in our eyes a very interesting one.
implementation could reside in the abstract superclass for all
connectors so every specific protocol would benefit some these
automatically.
interested in your opinions...
Joern
-------------------------------------------------------
The SF.Net email is sponsored by EclipseCon 2004
Premiere Conference on Open Tools Development and Integration
See the breadth of Eclipse activity. February 3-5 in Anaheim, CA.
http://www.eclipsecon.org/osdn
|