[xquery-talk] Question about xml databse app design and xml file merging (using xquery maybe)

Adam Retter adam.retter at googlemail.com
Fri Jun 3 21:26:20 PDT 2011


Hi Josh,

I think the problem here is not the XQuery but perhaps the approach to
solving the problem that you have taken. You mention that your using
eXist-db, in eXist-db you can do what you want very simply because we
integrate betterForm with eXist-db. betterForm is an XForms engines,
and such engines already do what I think you want transparently. That
is to say that you can have your XForm store your instance at any
point into the db, upon reloading that instance (at some point in the
future) into the XForm model you will be presented with the form in
the state as the user left it, i.e. partially completed.
You can of course also have your XForm load its instance from the
result of an XQuery if you wish to do some pre-processing or have it
POST submit your instance onto an XQuery script if you wish to do some
post-processing of your instance.

As this is now focusing more on eXist-db specifics than XQuery itself,
it may be better to move this discussion to the exist-open mailing
list.

Thanks Adam.

On 4 June 2011 02:38, Josh Story <jcs.lists at gmail.com> wrote:
> Just joined this mailing list so I hope I'm submitting this item correctly.
> I have fairly rudimentary knowledge of xquery, xpath, and xslt and am in the
> process of exploring a XRX implementation of an existing application that
> collects insurance quote information. The current application is about 12
> years old, uses poorly formed html with javascript and a java backend. I'm
> experimenting with the XRX pattern using eXist but am having trouble
> retraining myself to think declaratively rather than procedurally.
>
> Here is my current 'problem'. I'm hoping to get some feedback on whether I'm
> constructing the app in a decent way or if it should be revamped completely
> and also looking for a technical solution to something that I think should
> be possible in xquery but seems to be difficult to implement.
>
> First, imagine you can create multiple quotes which store information about
> the insurance risk (let's say its home insurance so you are storing info on
> the property as well as the person living there). in the xml database I'll
> be storing new instances of quotes as they're created with certain data
> present and other data missing as the user may not have answered all
> questions yet.
>
> So if the user creates a new quote (xml data instance created) and gets
> partway through (xml data instance saved partially complete) and then
> reopens the quote and modifies some info and leaves again (xml data instance
> changed and saved again) and the reopens and completes the quote (xml data
> changed for a final time) the xml goes through a few stages before it is
> final. Now since this takes time (minutes, hours, days, or even weeks) there
> is the possibility that the model of information we need to properly quote
> changes. So let's say I started with this model:
>
> <applicant>
>    <fname />
>    <lname />
>    <hphone />
> </applicant>
>
> and the original quote was created with this xml structure. And let's
> pretend I only have to answer the fname question
>
> <applicant>
>    <fname>Josh</fname>
>    <lname />
>    <hphone />
> </applicant>
>
>  Now the model changes and I want to capture and store work phone so any new
> quotes are created with the following model:
>
> <applicant>
>    <fname />
>    <lname />
>    <hphone />
>    <wphone />
> </applicant>
>
> I would want any quote that was being edited to include the new field from
> the updated model (this would be to allow an XFroms binding to that node and
> presumably the application forces the user to now answer this new question
> prior to making the submission final)
>
> I would want the xquery to serve up an xml nodeset like
>
> <applicant>
>    <fname>Josh</fname>
>    <lname />
>    <hphone />
>    <wphone />
> </applicant>
>
> So my question is can xquery be used to traverse a 'current state' model and
> try to grab data from a data-instance that looks similar but won't
> necessarily be identical and load it up so that when the user saves their
> quote they're actually saving a representation of the most recent valid
> model but with information remembered from their prior saves? I find it very
> difficult to dynamically traverse an xml in xquery and grab text() from
> atomic elements that match the same xpath as the node I'm currently focused
> on. I've tried declaring a local function that does a recursive loop through
> the model and dynamically evaluates the data instance using xpath pulled
> from each model element using
>
> util:eval(...)
> and
> util:node-xpath(...)
>
> but I can't seem to get it to work.
>
> Ok so back to the beginning. Am I designing this app all wrong (the idea of
> a model that can change and potentially outdated instances of data based on
> whatever model was in use a the last time the quotes was loaded/saved in the
> application)?
>
> And the if this is a decent design is there a relatively easy way to do this
> xml merging or whatever it should be called (xml extrusion maybe?). maybe I
> should be looking to xslt or something else in combination with xquery to
> get this done?
>
> Thanks,
> Josh
>
> _______________________________________________
> talk at x-query.com
> http://x-query.com/mailman/listinfo/talk
>



-- 
Adam Retter

skype: adam.retter
tweet: adamretter
http://www.adamretter.org.uk



More information about the talk mailing list