<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Fouad&#039;s Blog &#187; XML</title>
	<atom:link href="http://www.fouad-saidy.com/archives/category/xml/feed" rel="self" type="application/rss+xml" />
	<link>http://www.fouad-saidy.com</link>
	<description>Select * From World where type=&#34;computing&#34;;</description>
	<lastBuildDate>Thu, 17 Mar 2011 14:20:14 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>How To Use XUpdate In Java With Xindice Database</title>
		<link>http://www.fouad-saidy.com/archives/26</link>
		<comments>http://www.fouad-saidy.com/archives/26#comments</comments>
		<pubDate>Sun, 07 Feb 2010 19:01:20 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[XML]]></category>

		<guid isPermaLink="false">http://fouad-saidy.freehostia.com/?p=26</guid>
		<description><![CDATA[This Tutorial is available in PDF Book  : How To Use XUpdate In Java With Xindice Database
The aim of this tutorial is to show you how to develop a simple java class that use CRUD (Create Read Update Delete ) operations with an xml file stored in a native XML Database.
firstly to begin you  <a href="http://www.fouad-saidy.com/archives/26" class="more-link">More &#62;</a><p><a href="http://sharethis.com/item?&#038;wp=2.8.2&#38;publisher=c52c2557-5007-4da4-b176-d174646fb516&#38;title=How+To+Use+XUpdate+In+Java+With+Xindice+Database&#38;url=http%3A%2F%2Fwww.fouad-saidy.com%2Farchives%2F26">ShareThis</a></p>]]></description>
			<content:encoded><![CDATA[<p>This Tutorial is available in PDF Book  : <a href="http://www.scribd.com/doc/28280460/How-to-use-xupdate-in-java-with-xindice-database">How To Use XUpdate In Java With Xindice Database</a></p>
<p>The aim of this tutorial is to show you how to develop a simple java class that use CRUD (Create Read Update Delete ) operations with an xml file stored in a native XML Database.<br />
firstly to begin you should download those tools:</p>
<ul>
<li><a href="http://www.eclipse.org/downloads/download.php?file=/technology/epp/downloads/release/galileo/SR1/eclipse-jee-galileo-SR1-win32.zip"> Eclipse Galileo </a> </li>
<li><a href="https://olex.openlogic.com/package_versions/download/4788?package_version_id=1065&#038;path=openlogic%2Fxindice%2F1.0%2Fxindice-1.0-windows-bin.zip">Xindice 1.0 DataBase</a> </li>
<li>
<a href="http://www.schatten.info/software/xindice_browser/XIndiceBrowser_bin.zip"> Xindice Browser </a> </li>
</ul>
<ol>
	<font color="blue" >
<li><strong>Launching the server and adding the XML file to the native database :</strong> </li>
<p> </font><br />
let&#8217;s begin our project ,we should create a xml file for example called  <strong>persons.xml</strong> in whish we add some  person elements ,each person has different nodes(first name,last name,email ,age) this is an example of persons.xml :</p>
<div>
<span style="color: red;"> < </span>  <span style="color: blue;"> persons </span> <span style="color: red;"> > </span>
</div>
<div>
<span style="color: red;"> < </span>  <span style="color: blue;"> person id=&#8221;1&#8243; </span> <span style="color: red;"> > </span>
</div>
<div>
<span style="color: red;"> < </span>  <span style="color: blue;"> fname </span> <span style="color: red;">></span> <span style="color:green;">FOUAD </span> <span style="color: red;"> < </span>  <span style="color: blue;"> /fname </span> <span style="color: red;"> > </span>
</div>
<div>
<span style="color: red;"> < </span>  <span style="color: blue;"> lname </span> <span style="color: red;">></span> <span style="color:green;">SAIDY </span> <span style="color: red;"> < </span>  <span style="color: blue;"> /lname </span> <span style="color: red;"> > </span>
</div>
<div>
<span style="color: red;"> < </span>  <span style="color: blue;"> email</span> <span style="color: red;">></span> <span style="color:green;">fouadsaidy@gmail.com</span> <span style="color: red;"> < </span>  <span style="color: blue;"> /email </span> <span style="color: red;"> > </span>
</div>
<div>
<span style="color: red;"> < </span>  <span style="color: blue;"> age</span> <span style="color: red;">></span> <span style="color:green;">22</span> <span style="color: red;"> < </span>  <span style="color: blue;"> /age </span> <span style="color: red;"> > </span>
</div>
<div>
<span style="color: red;"> < </span>  <span style="color: blue;"> /person </span> <span style="color: red;"> > </span>
</div>
<p><!-- Person 2--></p>
<div>
<span style="color: red;"> < </span>  <span style="color: blue;"> person id=&#8221;2&#8243; </span> <span style="color: red;"> > </span>
</div>
<div>
<span style="color: red;"> < </span>  <span style="color: blue;"> fname </span> <span style="color: red;">></span> <span style="color:green;">KEVIN </span> <span style="color: red;"> < </span>  <span style="color: blue;"> /fname </span> <span style="color: red;"> > </span>
</div>
<div>
<span style="color: red;"> < </span>  <span style="color: blue;"> lname </span> <span style="color: red;">></span> <span style="color:green;">MITNICK </span> <span style="color: red;"> < </span>  <span style="color: blue;"> /lname </span> <span style="color: red;"> > </span>
</div>
<div>
<span style="color: red;"> < </span>  <span style="color: blue;"> email</span> <span style="color: red;">></span> <span style="color:green;">kevin.mitnick@gmail.com</span> <span style="color: red;"> < </span>  <span style="color: blue;"> /email </span> <span style="color: red;"> > </span>
</div>
<div>
<span style="color: red;"> < </span>  <span style="color: blue;"> age</span> <span style="color: red;">></span> <span style="color:green;">45</span> <span style="color: red;"> < </span>  <span style="color: blue;"> /age </span> <span style="color: red;"> > </span>
</div>
<div>
<span style="color: red;"> < </span>  <span style="color: blue;"> /person </span> <span style="color: red;"> > </span>
</div>
<p><!-- Person 3--></p>
<div>
<span style="color: red;"> < </span>  <span style="color: blue;"> person id=&#8221;3&#8243; </span> <span style="color: red;"> > </span>
</div>
<div>
<span style="color: red;"> < </span>  <span style="color: blue;"> fname </span> <span style="color: red;">></span> <span style="color:green;">BILL </span> <span style="color: red;"> < </span>  <span style="color: blue;"> /fname </span> <span style="color: red;"> > </span>
</div>
<div>
<span style="color: red;"> < </span>  <span style="color: blue;"> lname </span> <span style="color: red;">></span> <span style="color:green;">GATES </span> <span style="color: red;"> < </span>  <span style="color: blue;"> /lname </span> <span style="color: red;"> > </span>
</div>
<div>
<span style="color: red;"> < </span>  <span style="color: blue;"> email</span> <span style="color: red;">></span> <span style="color:green;">bill.gates@gmail.com</span> <span style="color: red;"> < </span>  <span style="color: blue;"> /email </span> <span style="color: red;"> > </span>
</div>
<div>
<span style="color: red;"> < </span>  <span style="color: blue;"> age</span> <span style="color: red;">></span> <span style="color:green;">55</span> <span style="color: red;"> < </span>  <span style="color: blue;"> /age </span> <span style="color: red;"> > </span>
</div>
<div>
<span style="color: red;"> < </span>  <span style="color: blue;"> /person </span> <span style="color: red;"> > </span>
</div>
<div>
<span style="color: red;"> < </span>  <span style="color: blue;"> /persons </span> <span style="color: red;"> > </span>
</div>
<p>We created the xml file let&#8217;s now store this file in <strong>Xindice database</strong> ,to do that we should start the server, open the  Xindice Folder called xindice-1.0 &#8211;>launch  startup.bat, to verify if the server is executed correctly open your navigator and show <strong>http://localhost:4080/</strong>  page if you saw an xindice page that means the server is launched without errors.</p>
<div id="attachment_97" class="wp-caption aligncenter" style="width: 410px"><a href="http://www.fouad-saidy.com/wp-content/uploads/2010/02/xindice0.jpg"  rel="lightbox-26"><img src="http://www.fouad-saidy.com/wp-content/uploads/2010/02/xindice0.jpg" alt="The Server Is Running" title="xindice0" width="400" height="200" class="size-full wp-image-97" /></a><p class="wp-caption-text">The Server Is Running</p></div>
<div id="attachment_110" class="wp-caption aligncenter" style="width: 410px"><a href="http://www.fouad-saidy.com/wp-content/uploads/2010/02/xindice6.jpg"  rel="lightbox-26"><img src="http://www.fouad-saidy.com/wp-content/uploads/2010/02/xindice6-1024x289.jpg" alt="Apache XIndice Start Page " title="xindice6" width="400" height="200" class="size-large wp-image-110" /></a><p class="wp-caption-text">Apache XIndice Start Page </p></div>
<p>Next step is to launch Xindice Browser which give us many options to look to the database (open XindiceBrowser and execute <strong>XIndiceBrowser.bat</strong><br />
To add the Xml file to the XML database we should create a Collection in whish we will store this  file:</p>
<div id="attachment_123" class="wp-caption aligncenter" style="width: 350px"><a href="http://www.fouad-saidy.com/wp-content/uploads/2010/02/xindice2.jpg"  rel="lightbox-26"> <img src="http://www.fouad-saidy.com/wp-content/uploads/2010/02/xindice2-300x135.jpg" alt="Create a Test Collection" title="xindice2" width="340" height="240" class="size-medium wp-image-123" /></a><p class="wp-caption-text">Create a Test Collection</p></div>
<p>Now let&#8217;s add <strong>persons.xml</strong> file to the new collection :<br />
<div id="attachment_120" class="wp-caption aligncenter" style="width: 410px"><a href="http://www.fouad-saidy.com/wp-content/uploads/2010/02/xindice3.jpg" rel="lightbox-26"> <img src="http://www.fouad-saidy.com/wp-content/uploads/2010/02/xindice3-300x135.jpg" alt="Add XML File To Test Collection" title="xindice3" width="400" height="200" class="size-medium wp-image-120" /></a> <p class="wp-caption-text">Add XML File To Test Collection</p></div></p>
<div id="attachment_141" class="wp-caption aligncenter" style="width: 310px"><a href="http://www.fouad-saidy.com/wp-content/uploads/2010/02/xindice4.jpg"  rel="lightbox-26"><img src="http://www.fouad-saidy.com/wp-content/uploads/2010/02/xindice4-300x89.jpg" alt="Add persons.xml to Test collection" title="xindice4" width="300" height="89" class="size-medium wp-image-141" /></a><p class="wp-caption-text">Add persons.xml to Test collection</p></div>
<div id="attachment_142" class="wp-caption aligncenter" style="width: 310px"><a href="http://www.fouad-saidy.com/wp-content/uploads/2010/02/xindice5.jpg" rel="lightbox-26"><img src="http://www.fouad-saidy.com/wp-content/uploads/2010/02/xindice5-300x112.jpg" alt="show persons.xml in XIndice Browser" title="xindice5" width="300" height="112" class="size-medium wp-image-142" /></a><p class="wp-caption-text">show persons.xml in XIndice Browser</p></div>
<p>we finished the first step of configuration and insertion of XML file in native database,next step is to create a javaa classe wishes manipulate the XML file stored in the database.<br />
     <font color="blue" >
<li>   <strong>Update XML database in java</strong> </li>
<p> </font><br />
open Eclipse Galileo IDE and create a new Java Project called <strong>test_xindice</strong> ,click the right mouse into the project and select Properties , in the properties window select Java Build Path &#8211;> Libraries , then  click the <strong> Add External JARs&#8230;</strong>  Button , select the 5 jar&#8217;s in the java&#8211;> lib folder (see the next image) </p>
<div id="attachment_140" class="wp-caption aligncenter" style="width: 310px"><a href="http://www.fouad-saidy.com/wp-content/uploads/2010/02/xindice7.jpg" rel="lightbox-26"><img src="http://www.fouad-saidy.com/wp-content/uploads/2010/02/xindice7-300x200.jpg" alt="Add Jars To Java Project" title="xindice7" width="300" height="200" class="size-medium wp-image-140" /></a><p class="wp-caption-text">Add Jars To Java Project</p></div><br />
<div id="attachment_142" class="wp-caption aligncenter" style="width: 310px"><a href="http://www.fouad-saidy.com/wp-content/uploads/2010/02/xindice5.jpg" rel="lightbox-26"><img src="http://www.fouad-saidy.com/wp-content/uploads/2010/02/xindice5-300x112.jpg" alt="show persons.xml in XIndice Browser" title="xindice5" width="300" height="112" class="size-medium wp-image-142" /></a><p class="wp-caption-text">show persons.xml in XIndice Browser</p></div> classe called xupdate and add this code to your class :<br />
<a href='http://www.fouad-saidy.com/wp-content/uploads/2010/02/xupdate.java'>Download xupdate.java</a><br />
to execute this class we should modify the run configuration of the eclipse IDE to do that select in principal menu run&#8211;>run configuration&#8211;>Arguments , enter one of this arguments:</p>
<ul>
<li> add a new person           : <strong>-A persons farid safiri 25 farid@gmail.com</strong> </li>
<li> Remove the 4th person    :  <strong>-R persons 4</strong></li>
<li>update the second person : <strong> -E persons 2 steve Mcarty 21 sMcarty@gmail.com</strong>
</ul>
<p>after writhing one of those case in the argument section click run, you will see the xupdate code in the eclipse console, for example if we write the first option adding a new person to the <strong>persons.xml</strong> file stored in the database we will see the request like this :</p>
<p><div id="attachment_174" class="wp-caption aligncenter" style="width: 310px"><a href="http://www.fouad-saidy.com/wp-content/uploads/2010/02/xindice8.jpg" rel="lightbox-26"><img src="http://www.fouad-saidy.com/wp-content/uploads/2010/02/xindice8-300x172.jpg" alt="add Arguments to Eclipse run configuration" title="xindice8" width="300" height="172" class="size-medium wp-image-174" /></a><p class="wp-caption-text">add Arguments to Eclipse run configuration</p></div>
<p>The code produced by the program and executed in the server :<br />
<div id="attachment_192" class="wp-caption aligncenter" style="width: 310px"><a href="http://www.fouad-saidy.com/wp-content/uploads/2010/02/xindice9.jpg" rel="lightbox-26"><img src="http://www.fouad-saidy.com/wp-content/uploads/2010/02/xindice9-300x111.jpg" alt="XUpdate code sent to the server " title="xindice9" width="300" height="111" class="size-medium wp-image-192" /></a><p class="wp-caption-text">XUpdate code sent to the server </p></div></p>
<p>for more informations about how to use  <a href="http://www.xmldatabases.org/projects/XUpdate-UseCases/">XUpdate UseCases</a>  </p>
<p>now let&#8217;s see the modification in Xml database, move to XIndice Database Browser click the refresh button and select persons.xml file you will see that the forth person is added to the database :<br />
<div id="attachment_194" class="wp-caption aligncenter" style="width: 310px"><a href="http://www.fouad-saidy.com/wp-content/uploads/2010/02/xindice10.jpg" rel="lightbox-26"><img src="http://www.fouad-saidy.com/wp-content/uploads/2010/02/xindice10-300x176.jpg" alt="XML Database updated" title="xindice10" width="300" height="176" class="size-medium wp-image-194" /></a><p class="wp-caption-text">XML Database updated</p></div></p>
<p>In the same way you can execute author options  of removing or updating an element in the XML database .</p>
<p>	 <font color="blue" >
<li><strong>Execute XPath expression in java</strong> </li>
<p> </font><br />
To learn XPath : <a href="http://www.w3schools.com/XPath/default.asp">XPath Tutorial </a></p>
<p>create a simple java class called show_xml and copy this file to your class:<br />
<a href='http://www.fouad-saidy.com/wp-content/uploads/2010/02/show_xml.java'>show_xml.java</a><br />
execute this file and you will see the result in eclipse console like this :<br />
<div id="attachment_199" class="wp-caption aligncenter" style="width: 310px"><a href="http://www.fouad-saidy.com/wp-content/uploads/2010/02/xindice11.jpg" rel="lightbox-26"><img src="http://www.fouad-saidy.com/wp-content/uploads/2010/02/xindice11-300x73.jpg" alt="XPath Result" title="xindice11" width="300" height="73" class="size-medium wp-image-199" /></a><p class="wp-caption-text">XPath Result</p></div><br />
finally you achieved the mission of updating a XML Database and showing the XPath Result using java and Xindice Database, you can now create more complex application based on XML database .
</ol>
]]></content:encoded>
			<wfw:commentRss>http://www.fouad-saidy.com/archives/26/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

