[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
RE: XML updates
The update syntax is interesting.
The syntax for the updates and insertions could be made
to look like the XML Fragment Interchange spec
http://www.w3.org/TR/WD-xml-fragment
but with a target-location XPath expression, instead of the
sourcelocn given for the existing (read-only) fragments.
It also looks like you assume an insertion is as a child.
But it might be useful to supply an XPath axis, such as
'attribute', 'preceding-sibling', 'following-sibling' or
'child', perhaps augmented with the TreeWalker notion of
'first-child', 'last-child' to specify where the insertion
goes relative to the target-location. This way the attribute
operations can be separated from the node updates, etc.
(e.g. the examples for updating the password or dir
are ambiguous, it could mean add/change the attribute,
or replace the child node with the complete node argument,
overwriting any other existing attributes or sub-elements).
Another possibility is to use a special syntax for specifying
the attribute data, rather than use the element itself as a
context. For example:
<attribute name="dir" value="'/home/fred'"/>
So a complete insertion update might look like this
.. . xmlns:xfu="http://www.ozone-db.org/XML-Fragment-Update" ..
<xfu:fragment-update target-doc="http://..../usersessionbeans.xml">
<xfu:add target-location="//usersessionbeans" axis="first-child">
<usersession id='542325'>
<username>Fred</username>
<password>abc</password>
</usersession>
</xfu:add>
</xfu:fragment-update>
and modifying the password becomes:
<xfu:fragment-update target-doc="http://..../usersessionbeans.xml">
<xfu:replace
target-location="//*/usersession[username='Fred']/password">
abc
</xfu:replace>
</xfu:fragment-update>
and modifying the attribute becomes:
<xfu:fragment-update target-doc="http://..../usersessionbeans.xml">
<xfu:add target-location="//*/usersession[username='Fred']"
axis="attribute">
<usersession dir='/home/fred'/>
</xfu:add>
</xfu:fragment-update>
or perhaps:
<xfu:fragment-update target-doc="http://..../usersessionbeans.xml">
<xfu:add target-location="//*/usersession[username='Fred']"
axis="attribute">
<xfu:attribute name="dir" value="/home/fred"/>
</xfu:add>
</xfu:fragment-update>
It should be possible to devise a mapping from HTML forms
to this fragment update syntax, similar to Donald Ball's
XMLForm:
http://www.webslingerz.com/balld/xmlform/README
and implement this as a pre-processor on the web servlet,
e.g. as a Cocoon Producer (or is it Generator these days?).
Mike
> -----Original Message-----
> From: Tony Gedge [mailto:t.gedge@citr.com.au]
> Sent: Thursday, April 20, 2000 11:13 PM
> To: ozone-users@ozone-db.org
> Subject: Re: XML updates
>
>
> Hi,
>
> This might be of use to you as an example. The 'query', 'store',
> 'remove', 'insert' and 'update' methods will work with Ozone 0.4,
> however, the 'delete' method will not work properly and will
> corrupt the
> database, since Ozone 0.4 has a defect in the 'removeChild'
> implementation of NodeImpl. You will need to build the attached
> NodeImpl.java file and replace the NodeImpl.class in the
> ozone.jar file.
>
> The 'xinsert', 'xupdate' and 'xquery' methods in DBTool.java use some
> custom classes we have added to Ozone, for performance of specific
> things that we want to do. Just remove those functions and the
> associated imports for XPath*String and XPath*StringImpl.
>
> There's no doco, but here's what you can do:
>
> --------------------------------------------------------------
> --------------------------
> ### Store the XML contained in the file 'usersessionbeans.xml' into
> Ozone under the
> ### document name 'usersessionbeans.xml'
> java DBTool store usersessionbeans.xml
>
> ### Remove the XML document named 'usersessionbeans.xml' from Ozone
> java DBTool remove usersessionbeans.xml
>
> ### Query the XML using XPath queries
> # Get all data
> java DBTool query usersessionbeans.xml /
> # Get usersession data for users with username 'Graham'
> java DBTool query usersessionbeans.xml
> "//usersessionbeans/usersession[username='Graham']"
>
> ### Add a new user session
> java DBTool insert usersessionbeans.xml "//usersessionbeans"
> "<usersession
> id='542325'><username>Fred</username><password>abc</password><
> /usersession>"
>
> ### Update 'Fred's user session to change the password
> java DBTool update usersessionbeans.xml
> "//usersessionbeans/usersession[username='Fred']"
> "<usersession><password>def</password></usersession>"
>
> ### Update 'Fred's user session to add a new attribute to the session
> java DBTool update usersessionbeans.xml
> "//usersessionbeans/usersession[username='Fred']" "<usersession
> dir='/home/fred'></usersession>"
>
> ### Delete 'Fred's user session
> java DBTool delete usersessionbeans.xml
> "//usersessionbeans/usersession[username='Fred']"
> --------------------------------------------------------------
> --------------------------
>
> Unfortunately, the code doesn't do deletion of attributes and nodes as
> an update. Oh well.
>
> Hope this helps.
>
> Tony Gedge.
>