Login | Register   
LinkedIn
Google+
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


advertisement
 

Apache's Xindice Organizes XML Data Without Schema : Page 4

A native XML database can make a lot of sense for organizations that want to store and access XML without all the unsightly schema mapping required to store XML in a traditional relational database system. Several commercial native XML databases exist; now, we take a first look at Apache's open source offering, Xindice.


advertisement
Using XUpdate
Now for a basic example of XUpdate. For more in-depth information on XUpdate check out the specification at www.xmldb.org/xupdate/xupdate-wd.html. An XUpdate XML document is a container of commands to be performed in series. Again, assume I want to update the following XML document.

<?xml version="1.0"?> <product product_id="1" type="widget"> <description>foo</description> </product> <product product_id="2" type="widget"> <description>bar</description> </product> <product product_id="3" type="widget"> <description>foobar</description> </product>

If I want to remove product_id 2 and change the description of product_id 3 I would use the following XUpdate modification block.

<xu:modifications version="1.0" xmlns:xu="http://www.xmldb.org/xupdate"> <xu:remove select="/product[@product_id]="2"/> <xu:update select="/product[@product_id]="3"/description>bar</xu:update> </xu:modifications>

As you can see, my XUpdate modification block is made up of two commands. The first removes product_id 2 and the second updates product_id 3. There are two main points to remember with XUpdate. First, the commands are performed serially (in the order they appear in the modification block). Second, the command is performed on the element represented by the select attribute, which is an XPath query. Thus it is possible to update multiple documents with specific changes in a single XUpdate modification block.



The final method deletes documents from the database.

Resource document = col.getResource(ID); col.removeResource(document);

Having seen all of the most important features Xindice offers, you might agree that it is quite a complete native database implementation. Like many open source projects, Xindice continues to evolve. Two of the more interesting features that may appear in the next major release are versioning and auto-linking. Versioning would be quite a useful feature for developers who use Xindice for their XML configuration documents. Auto-linking on the other hand represents an interesting approach to data redundancy in XML documents. It has the potential to provide the power of relations without the rigid schema requirements found in traditional relational databases.


Matt Liotta has been a software architect for several start-ups in San Francisco and Atlanta. He is now President and CEO of Montara Software, which he founded to further education with technology. He can be reached at .
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap
Thanks for your registration, follow us on our social networks to keep up-to-date