[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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.

P.S. The above is all from memory, so it's possible I might have made an
error in it.

-- 

*************************************************************************
THIS MESSAGE IS INTENDED ONLY FOR THE USE OF THE INDIVIDUAL OR ENTITY TO
WHICH IT IS ADDRESSED AND MAY CONTAIN INFORMATION THAT IS PRIVILEGED,
CONFIDENTIAL, AND EXEMPT FROM DISCLOSURE UNDER APPLICABLE LAW.
If the reader of this message is not the intended recipient, or the
employee
or agent responsible for delivering the message to the intended
recipient,
you are hereby notified that any dissemination, distribution,
forwarding, or copying of this communication is strictly prohibited.  If
you
have received this communication in error, please notify the sender
immediately by e-mail or telephone, and delete the original message
immediately.
Thank you.
*************************************************************************

DBTool.java

NodeImpl.java

usersessionbeans.xml