You are viewing a plain text version of this content. The canonical link for it is here.
Posted to xindice-dev@xml.apache.org by ks...@apache.org on 2002/02/05 06:38:09 UTC
cvs commit: xml-xindice/java/examples/guide/src/org/apache/xindice/examples AddDocument.java CreateCollection.java DeleteDocument.java Example1.java RetrieveDocument.java XPathQueryInvoke.java XUpdate.java
kstaken 02/02/04 21:38:09
Modified: docs index.html
docs/src DevelopersGuide.xml
java/examples/guide/src/org/apache/xindice/examples
AddDocument.java CreateCollection.java
DeleteDocument.java Example1.java
RetrieveDocument.java XPathQueryInvoke.java
XUpdate.java
Log:
Fixing the examples and adding a little more hand holding to the dev guide.
Revision Changes Path
1.2 +1 -1 xml-xindice/docs/index.html
Index: index.html
===================================================================
RCS file: /home/cvs/xml-xindice/docs/index.html,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- index.html 6 Dec 2001 19:33:45 -0000 1.1
+++ index.html 5 Feb 2002 05:38:08 -0000 1.2
@@ -37,7 +37,7 @@
<a href="FAQ">Frequent Questions</a> <br>
<a href="LICENSE">Public License</a> <br><br>
- <a href="/javadoc/">API Documentation</a> <br>
+ <a href="api/index.html">API Documentation</a> <br>
</font></p>
</td>
</tr>
1.4 +140 -61 xml-xindice/docs/src/DevelopersGuide.xml
Index: DevelopersGuide.xml
===================================================================
RCS file: /home/cvs/xml-xindice/docs/src/DevelopersGuide.xml,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- DevelopersGuide.xml 23 Jan 2002 12:00:50 -0000 1.3
+++ DevelopersGuide.xml 5 Feb 2002 05:38:08 -0000 1.4
@@ -18,7 +18,7 @@
<year>2001</year>
<holder>The Apache Software Foundation</holder>
</copyright>
- <pubdate><![CDATA[$Id: DevelopersGuide.xml,v 1.3 2002/01/23 12:00:50 kstaken Exp $]]></pubdate>
+ <pubdate><![CDATA[$Id: DevelopersGuide.xml,v 1.4 2002/02/05 05:38:08 kstaken Exp $]]></pubdate>
<legalnotice>
<para>
This documentation is a work in progress. Links to the most current
@@ -214,6 +214,109 @@
<filename>Xindice/java/src/org/apache/xindice/tools/command</filename>.
</para>
</sect1>
+
+ <sect1>
+ <title>Setting up Your Build Environment</title>
+ <para>
+ Before you can build applications for Xindice you need to make sure you
+ have your build environment properly setup. This mainly consists of
+ making sure that you have the proper VM version and a properly
+ configured <varname>CLASSPATH</varname>.
+ </para>
+ <para>
+ To build applications for Xindice you must be using JDK 1.3. At this time
+ there appear to be problems with JDK 1.4. JDK 1.2 and below will not
+ work at all. If you have more than one Java VM installed make sure that
+ your <varname>JAVA_HOME</varname> environment variable and
+ <varname>PATH</varname> environment variable both include the correct
+ path.
+ </para>
+ <para>
+ Once you have your Java VM properly configured you need to add a few
+ jar files to your <varname>CLASSPATH</varname>. The following list of
+ jars are required and should be made available on your
+ <varname>CLASSPATH</varname>. All required jars can be found in
+ <filename>Xindice/java/lib</filename>
+ <itemizedlist>
+ <listitem>
+ <para>
+ xindice.jar - contains the main Xindice classes that are used by
+ the client API.
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ xmldb.jar - contains the XML:DB API interfaces.
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ openorb-1.2.0.jar - contains the CORBA ORB implementation used
+ by the client API to communicate with the server.
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ xerces-1.4.3.jar - contains the Xerces XML parser.
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ xalan-2.0.1.jar - contains the Xalan XSL-T engine. This
+ jar isn't absolutely required but you'll probably want it so
+ it's worth adding it.
+ </para>
+ </listitem>
+ </itemizedlist>
+ </para>
+ </sect1>
+
+ <sect1>
+ <title>Preparing the Server For the Examples</title>
+ <para>
+ Before we get to some example code, we need to do a little work to setup the
+ server. Don't worry nothing hard.
+ </para>
+ <para>
+ First we need to make sure the addressbook collection exists. If you followed
+ the install instructions completely you should have already created this,
+ but if not you should do so now. To find out if the collection exists you
+ can run:
+ </para>
+ <screen>
+xindice lc -c /db
+ </screen>
+ <para>
+ If you don't see 'addressbook' listed in the result then you need to create
+ the collection. To create it just run:
+ </para>
+ <screen>
+xindiceadmin ac -c /db -n addressbook
+ </screen>
+ <para>
+ Now that we have the collection, we can add a few example documents
+ so that we have something to play with. You can find the examples in your
+ Xindice installation in the directory
+ <filename>java/examples/guide/xml</filename>. Run these commands to add
+ the documents.
+ </para>
+
+ <screen>
+cd $XINDICE_HOME/java/examples/guide/xml
+xindice ad -c /db/addressbook -f address1.xml -n address1
+xindice ad -c /db/addressbook -f address2.xml -n address2
+ </screen>
+ <para>
+ If you're on Windows you'll need to adjust the path in the cd command
+ for your platform. Most of the examples in the manual will be written for
+ UNIX but will work fine in Windows if you just replace / with \ and
+ $XINDICE_HOME with %XINDICE_HOME%.
+ </para>
+ <para>
+ That wasn't so bad and now we're set to look at some example code.
+ </para>
+ </sect1>
+
<sect1>
<title>Diving in With an Example Program</title>
<example>
@@ -267,6 +370,37 @@
</programlisting>
</example>
<para>
+ Before diving into the gory detail of what this program is doing, let's
+ run it and see what we get back.
+ </para>
+ <para>
+ If you have a binary build of Xindice the examples are already built
+ and you can run this example by typing.
+ </para>
+ <screen>
+cd $XINDICE_HOME/java/examples/guide
+./run org.apache.xindice.examples.Example1
+ </screen>
+ <para>
+ If all goes well, you should see a result that looks something like this.
+ </para>
+ <screen>
+<![CDATA[<?xml version="1.0"?>
+<person xmlns:src="http://xml.apache.org/xindice/Query" src:col="/db/addressbook" src:key="address1">
+ <fname>John</fname>
+ <lname>Smith</lname>
+ <phone type="work">563-456-7890</phone>
+ <phone type="home">534-567-8901</phone>
+ <email type="home">jsmith@somemail.com</email>
+ <email type="work">john@lovesushi.com</email>
+ <address type="home">34 S. Colon St.</address>
+ <address type="work">9967 W. Shrimp Ave.</address>
+</person>]]>
+ </screen>
+
+ <para>
+ Now that we've seen the result, let's dive in and look at the code in
+ detail.
While this isn't the simplest possible example program to start with
it does a nice job of showing all the basic techniques used when
building applications with the XML:DB API.
@@ -433,62 +567,7 @@
close on the collection will result in a
resource leak within the server.
</para>
- </sect1>
-
- <sect1>
- <title>Setting up Your Build Environment</title>
- <para>
- Before you can build applications for Xindice you need to make sure you
- have your build environment properly setup. This mainly consists of
- making sure that you have the proper VM version and a properly
- configured <varname>CLASSPATH</varname>.
- </para>
- <para>
- To build applications for Xindice you must be using JDK 1.3. At this time
- there appear to be problems with JDK 1.4. JDK 1.2 and below will not
- work at all. If you have more than one Java VM installed make sure that
- your <varname>JAVA_HOME</varname> environment variable and
- <varname>PATH</varname> environment variable both include the correct
- path.
- </para>
- <para>
- Once you have your Java VM properly configured you need to add a few
- jar files to your <varname>CLASSPATH</varname>. The following list of
- jars are required and should be made available on your
- <varname>CLASSPATH</varname>. All required jars can be found in
- <filename>Xindice/java/lib</filename>
- <itemizedlist>
- <listitem>
- <para>
- xindice.jar - contains the main Xindice classes that are used by
- the client API.
- </para>
- </listitem>
- <listitem>
- <para>
- xmldb.jar - contains the XML:DB API interfaces.
- </para>
- </listitem>
- <listitem>
- <para>
- openorb-1.2.0.jar - contains the CORBA ORB implementation used
- by the client API to communicate with the server.
- </para>
- </listitem>
- <listitem>
- <para>
- xerces-1.4.3.jar - contains the Xerces XML parser.
- </para>
- </listitem>
- <listitem>
- <para>
- xalan-2.0.1.jar - contains the Xalan XSL-T engine. This
- jar isn't absolutely required but you'll probably want it so
- it's worth adding it.
- </para>
- </listitem>
- </itemizedlist>
- </para>
+
</sect1>
<sect1>
@@ -560,7 +639,7 @@
</para>
<para>
The collection we want to create will be named
- <varname>addressbook</varname> and will be a child of the root
+ <varname>mycollection</varname> and will be a child of the root
collection.
</para>
<example>
@@ -589,7 +668,7 @@
col =
DatabaseManager.getCollection("xmldb:xindice:///db/");
- String collectionName = "addressbook";
+ String collectionName = "mycollection";
CollectionManager service =
(CollectionManager) col.getService("CollectionManager", "1.0");
@@ -1471,7 +1550,7 @@
</sect1>
</chapter>
- <chapter>
+ <!--chapter>
<title>Database properties</title>
<para>
@@ -1527,7 +1606,7 @@
NOTE: These properties are Xindice specific and won't apply to any other
XML:DB implementations.
</para>
- </chapter>
+ </chapter-->
<chapter>
<title>Address Book Example Application</title>
1.2 +2 -2 xml-xindice/java/examples/guide/src/org/apache/xindice/examples/AddDocument.java
Index: AddDocument.java
===================================================================
RCS file: /home/cvs/xml-xindice/java/examples/guide/src/org/apache/xindice/examples/AddDocument.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- AddDocument.java 6 Dec 2001 19:33:52 -0000 1.1
+++ AddDocument.java 5 Feb 2002 05:38:08 -0000 1.2
@@ -56,7 +56,7 @@
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*
- * $Id: AddDocument.java,v 1.1 2001/12/06 19:33:52 bradford Exp $
+ * $Id: AddDocument.java,v 1.2 2002/02/05 05:38:08 kstaken Exp $
*/
import org.xmldb.api.base.*;
@@ -78,7 +78,7 @@
Database database = (Database) c.newInstance();
DatabaseManager.registerDatabase(database);
col =
- DatabaseManager.getCollection("xmldb:dbxml:///db/addressbook");
+ DatabaseManager.getCollection("xmldb:xindice:///db/addressbook");
String data = readFileFromDisk(args[0]);
1.2 +3 -3 xml-xindice/java/examples/guide/src/org/apache/xindice/examples/CreateCollection.java
Index: CreateCollection.java
===================================================================
RCS file: /home/cvs/xml-xindice/java/examples/guide/src/org/apache/xindice/examples/CreateCollection.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- CreateCollection.java 6 Dec 2001 19:33:53 -0000 1.1
+++ CreateCollection.java 5 Feb 2002 05:38:08 -0000 1.2
@@ -56,7 +56,7 @@
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*
- * $Id: CreateCollection.java,v 1.1 2001/12/06 19:33:53 bradford Exp $
+ * $Id: CreateCollection.java,v 1.2 2002/02/05 05:38:08 kstaken Exp $
*/
import org.xmldb.api.base.*;
@@ -81,9 +81,9 @@
Database database = (Database) c.newInstance();
DatabaseManager.registerDatabase(database);
col =
- DatabaseManager.getCollection("xmldb:dbxml:///db/");
+ DatabaseManager.getCollection("xmldb:xindice:///db/");
- String collectionName = "addressbook";
+ String collectionName = "mycollection";
CollectionManager service =
(CollectionManager) col.getService("CollectionManager", "1.0");
1.2 +2 -2 xml-xindice/java/examples/guide/src/org/apache/xindice/examples/DeleteDocument.java
Index: DeleteDocument.java
===================================================================
RCS file: /home/cvs/xml-xindice/java/examples/guide/src/org/apache/xindice/examples/DeleteDocument.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- DeleteDocument.java 6 Dec 2001 19:33:53 -0000 1.1
+++ DeleteDocument.java 5 Feb 2002 05:38:08 -0000 1.2
@@ -56,7 +56,7 @@
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*
- * $Id: DeleteDocument.java,v 1.1 2001/12/06 19:33:53 bradford Exp $
+ * $Id: DeleteDocument.java,v 1.2 2002/02/05 05:38:08 kstaken Exp $
*/
import org.xmldb.api.base.*;
@@ -78,7 +78,7 @@
Database database = (Database) c.newInstance();
DatabaseManager.registerDatabase(database);
col =
- DatabaseManager.getCollection("xmldb:dbxml:///db/addressbook");
+ DatabaseManager.getCollection("xmldb:xindice:///db/addressbook");
Resource document = col.getResource(args[0]);
col.removeResource(document);
1.3 +2 -2 xml-xindice/java/examples/guide/src/org/apache/xindice/examples/Example1.java
Index: Example1.java
===================================================================
RCS file: /home/cvs/xml-xindice/java/examples/guide/src/org/apache/xindice/examples/Example1.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- Example1.java 23 Jan 2002 12:00:50 -0000 1.2
+++ Example1.java 5 Feb 2002 05:38:08 -0000 1.3
@@ -56,7 +56,7 @@
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*
- * $Id: Example1.java,v 1.2 2002/01/23 12:00:50 kstaken Exp $
+ * $Id: Example1.java,v 1.3 2002/02/05 05:38:08 kstaken Exp $
*/
import org.xmldb.api.base.*;
@@ -76,7 +76,7 @@
Database database = (Database) c.newInstance();
DatabaseManager.registerDatabase(database);
col =
- DatabaseManager.getCollection("xmldb:dbxml:///db/addressbook");
+ DatabaseManager.getCollection("xmldb:xindice:///db/addressbook");
String xpath = "//person[fname='John']";
XPathQueryService service =
1.2 +2 -2 xml-xindice/java/examples/guide/src/org/apache/xindice/examples/RetrieveDocument.java
Index: RetrieveDocument.java
===================================================================
RCS file: /home/cvs/xml-xindice/java/examples/guide/src/org/apache/xindice/examples/RetrieveDocument.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- RetrieveDocument.java 6 Dec 2001 19:33:53 -0000 1.1
+++ RetrieveDocument.java 5 Feb 2002 05:38:08 -0000 1.2
@@ -56,7 +56,7 @@
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*
- * $Id: RetrieveDocument.java,v 1.1 2001/12/06 19:33:53 bradford Exp $
+ * $Id: RetrieveDocument.java,v 1.2 2002/02/05 05:38:08 kstaken Exp $
*/
import org.xmldb.api.base.*;
@@ -78,7 +78,7 @@
Database database = (Database) c.newInstance();
DatabaseManager.registerDatabase(database);
col =
- DatabaseManager.getCollection("xmldb:dbxml:///db/addressbook");
+ DatabaseManager.getCollection("xmldb:xindice:///db/addressbook");
XMLResource document = (XMLResource) col.getResource(args[0]);
if (document != null) {
1.2 +2 -2 xml-xindice/java/examples/guide/src/org/apache/xindice/examples/XPathQueryInvoke.java
Index: XPathQueryInvoke.java
===================================================================
RCS file: /home/cvs/xml-xindice/java/examples/guide/src/org/apache/xindice/examples/XPathQueryInvoke.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- XPathQueryInvoke.java 6 Dec 2001 19:33:53 -0000 1.1
+++ XPathQueryInvoke.java 5 Feb 2002 05:38:08 -0000 1.2
@@ -56,7 +56,7 @@
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*
- * $Id: XPathQueryInvoke.java,v 1.1 2001/12/06 19:33:53 bradford Exp $
+ * $Id: XPathQueryInvoke.java,v 1.2 2002/02/05 05:38:08 kstaken Exp $
*/
import org.xmldb.api.base.*;
@@ -80,7 +80,7 @@
Database database = (Database) c.newInstance();
DatabaseManager.registerDatabase(database);
col =
- DatabaseManager.getCollection("xmldb:dbxml:///db/addressbook");
+ DatabaseManager.getCollection("xmldb:xindice:///db/addressbook");
String xpath = "/person/fname";
String key = "address1";
1.3 +2 -2 xml-xindice/java/examples/guide/src/org/apache/xindice/examples/XUpdate.java
Index: XUpdate.java
===================================================================
RCS file: /home/cvs/xml-xindice/java/examples/guide/src/org/apache/xindice/examples/XUpdate.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- XUpdate.java 23 Jan 2002 12:00:50 -0000 1.2
+++ XUpdate.java 5 Feb 2002 05:38:08 -0000 1.3
@@ -56,7 +56,7 @@
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*
- * $Id: XUpdate.java,v 1.2 2002/01/23 12:00:50 kstaken Exp $
+ * $Id: XUpdate.java,v 1.3 2002/02/05 05:38:08 kstaken Exp $
*/
import org.xmldb.api.base.*;
@@ -76,7 +76,7 @@
Database database = (Database) c.newInstance();
DatabaseManager.registerDatabase(database);
col =
- DatabaseManager.getCollection("xmldb:dbxml:///db/addressbook");
+ DatabaseManager.getCollection("xmldb:xindice:///db/addressbook");
String xupdate = "<xu:modifications version=\"1.0\"" +
" xmlns:xu=\"http://www.xmldb.org/xupdate\">" +