vgritsenko 2004/02/07 17:19:43
Modified: java/examples build.xml java/examples/guide README java/examples/guide/src/org/apache/xindice/examples AbstractExample.java AddDocument.java CreateCollection.java DeleteDocument.java Example1.java ListCollections.java RetrieveDocument.java XUpdate.java java/examples/guide/xml address1.xml address2.xml Log: Applying the Apache License, Version 2.0 Revision Changes Path 1.4 +23 -4 xml-xindice/java/examples/build.xml Index: build.xml =================================================================== RCS file: /home/cvs/xml-xindice/java/examples/build.xml,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- build.xml 12 Dec 2003 23:37:54 -0000 1.3 +++ build.xml 8 Feb 2004 01:19:43 -0000 1.4 @@ -1,7 +1,26 @@ -<!--+ - | Xindice Addressbook and Guide Ant build file - | CVS $Id$ - +--> +<?xml version="1.0"?> + +<!-- + - Copyright 1999-2004 The Apache Software Foundation. + - + - Licensed under the Apache License, Version 2.0 (the "License"); + - you may not use this file except in compliance with the License. + - You may obtain a copy of the License at + - + - http://www.apache.org/licenses/LICENSE-2.0 + - + - Unless required by applicable law or agreed to in writing, software + - distributed under the License is distributed on an "AS IS" BASIS, + - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + - See the License for the specific language governing permissions and + - limitations under the License. + - + - CVS $Id$ + --> + +<!-- + - Xindice Addressbook and Guide Ant build file + --> <project name="xindice-examples" default="release" basedir="."> 1.3 +5 -1 xml-xindice/java/examples/guide/README Index: README =================================================================== RCS file: /home/cvs/xml-xindice/java/examples/guide/README,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- README 2 Feb 2002 01:22:20 -0000 1.2 +++ README 8 Feb 2004 01:19:43 -0000 1.3 @@ -1,3 +1,7 @@ +CVS $Id$ + + --- Xindice Developer's Guide example --- + This directory contains some example code used in the Xindice Developers Guide. Run: @@ -9,4 +13,4 @@ wish to run. The run script just adds the appropriate jars to the CLASSPATH before - running the program. \ No newline at end of file + running the program. 1.3 +39 -75 xml-xindice/java/examples/guide/src/org/apache/xindice/examples/AbstractExample.java Index: AbstractExample.java =================================================================== RCS file: /home/cvs/xml-xindice/java/examples/guide/src/org/apache/xindice/examples/AbstractExample.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- AbstractExample.java 7 Aug 2003 20:13:20 -0000 1.2 +++ AbstractExample.java 8 Feb 2004 01:19:43 -0000 1.3 @@ -1,63 +1,23 @@ package org.apache.xindice.examples; /* - * The Apache Software License, Version 1.1 + * Copyright 1999-2004 The Apache Software Foundation. * - * - * Copyright (c) 1999 The Apache Software Foundation. All rights - * reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by the - * Apache Software Foundation (http://www.apache.org/)." - * Alternately, this acknowledgment may appear in the software itself, - * if and wherever such third-party acknowledgments normally appear. - * - * 4. The names "Xindice" and "Apache Software Foundation" must - * not be used to endorse or promote products derived from this - * software without prior written permission. For written - * permission, please contact [EMAIL PROTECTED] - * - * 5. Products derived from this software may not be called "Apache", - * nor may "Apache" appear in their name, without prior written - * permission of the Apache Software Foundation. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * ==================================================================== - * - * This software consists of voluntary contributions made by many - * individuals on behalf of the Apache Software Foundation and was - * originally based on software copyright (c) 1999-2001, The dbXML - * Group, L.L.C., http://www.dbxmlgroup.com. For more - * information on the Apache Software Foundation, please see - * <http://www.apache.org/>. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. * * CVS $Id$ */ + import org.apache.xindice.util.XindiceException; import org.xmldb.api.DatabaseManager; import org.xmldb.api.base.Collection; @@ -69,29 +29,33 @@ */ public abstract class AbstractExample { - private static boolean alreadyInitialized = false; - - protected static void ensureInitialized() throws ClassNotFoundException, InstantiationException, IllegalAccessException, XMLDBException { - - if (alreadyInitialized) - return; + private static boolean alreadyInitialized = false; - String driver = "org.apache.xindice.client.xmldb.DatabaseImpl"; - Class driverClass = Class.forName(driver); - Database database = (Database) driverClass.newInstance(); - DatabaseManager.registerDatabase(database); - alreadyInitialized = true; - } - - protected static Collection getCollection(String collectionUri) - throws ClassNotFoundException, InstantiationException, IllegalAccessException, XMLDBException, XindiceException { - - ensureInitialized(); - Collection collection = DatabaseManager.getCollection(collectionUri); - if (collection == null) { - throw new XindiceException("DatabaseManager.getCollection(" + collectionUri + ") returned null."); - } + protected static void ensureInitialized() + throws ClassNotFoundException, InstantiationException, IllegalAccessException, + XMLDBException { + + if (alreadyInitialized) { + return; + } + + String driver = "org.apache.xindice.client.xmldb.DatabaseImpl"; + Class driverClass = Class.forName(driver); + Database database = (Database) driverClass.newInstance(); + DatabaseManager.registerDatabase(database); + alreadyInitialized = true; + } + + protected static Collection getCollection(String collectionUri) + throws ClassNotFoundException, InstantiationException, IllegalAccessException, + XMLDBException, XindiceException { + + ensureInitialized(); + Collection collection = DatabaseManager.getCollection(collectionUri); + if (collection == null) { + throw new XindiceException("DatabaseManager.getCollection(" + collectionUri + ") returned null."); + } - return collection; - } + return collection; + } } 1.6 +43 -84 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.5 retrieving revision 1.6 diff -u -r1.5 -r1.6 --- AddDocument.java 7 Aug 2003 20:13:20 -0000 1.5 +++ AddDocument.java 8 Feb 2004 01:19:43 -0000 1.6 @@ -1,60 +1,19 @@ package org.apache.xindice.examples; /* - * The Apache Software License, Version 1.1 + * Copyright 1999-2004 The Apache Software Foundation. * - * - * Copyright (c) 1999 The Apache Software Foundation. All rights - * reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by the - * Apache Software Foundation (http://www.apache.org/)." - * Alternately, this acknowledgment may appear in the software itself, - * if and wherever such third-party acknowledgments normally appear. - * - * 4. The names "Xindice" and "Apache Software Foundation" must - * not be used to endorse or promote products derived from this - * software without prior written permission. For written - * permission, please contact [EMAIL PROTECTED] - * - * 5. Products derived from this software may not be called "Apache", - * nor may "Apache" appear in their name, without prior written - * permission of the Apache Software Foundation. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * ==================================================================== - * - * This software consists of voluntary contributions made by many - * individuals on behalf of the Apache Software Foundation and was - * originally based on software copyright (c) 1999-2001, The dbXML - * Group, L.L.C., http://www.dbxmlgroup.com. For more - * information on the Apache Software Foundation, please see - * <http://www.apache.org/>. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. * * CVS $Id$ */ @@ -70,36 +29,36 @@ * Simple XML:DB API Example to insert a new document into the database. */ public class AddDocument extends AbstractExample { - - public static void main(String[] args) throws Exception { - Collection collection = null; - try { - - collection = getCollection("xmldb:xindice:///db/addressbook"); - - String data = readFileFromDisk(args[0]); - - XMLResource document = (XMLResource) collection.createResource(null, "XMLResource"); - document.setContent(data); - collection.storeResource(document); - System.out.println("Document " + args[0] + " inserted as " + document.getId()); - } - catch (XMLDBException e) { - System.err.println("XML:DB Exception occured " + e.errorCode + " " + e.getMessage()); - } - finally { - if (collection != null) { - collection.close(); - } - } - } - - public static String readFileFromDisk(String fileName) throws Exception { - File file = new File(fileName); - FileInputStream insr = new FileInputStream(file); - byte[] fileBuffer = new byte[(int) file.length()]; - insr.read(fileBuffer); - insr.close(); - return new String(fileBuffer); - } + + public static void main(String[] args) throws Exception { + Collection collection = null; + try { + + collection = getCollection("xmldb:xindice:///db/addressbook"); + + String data = readFileFromDisk(args[0]); + + XMLResource document = (XMLResource) collection.createResource(null, "XMLResource"); + document.setContent(data); + collection.storeResource(document); + System.out.println("Document " + args[0] + " inserted as " + document.getId()); + } + catch (XMLDBException e) { + System.err.println("XML:DB Exception occured " + e.errorCode + " " + e.getMessage()); + } + finally { + if (collection != null) { + collection.close(); + } + } + } + + public static String readFileFromDisk(String fileName) throws Exception { + File file = new File(fileName); + FileInputStream insr = new FileInputStream(file); + byte[] fileBuffer = new byte[(int) file.length()]; + insr.read(fileBuffer); + insr.close(); + return new String(fileBuffer); + } } 1.8 +45 -87 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.7 retrieving revision 1.8 diff -u -r1.7 -r1.8 --- CreateCollection.java 31 Jan 2004 13:24:50 -0000 1.7 +++ CreateCollection.java 8 Feb 2004 01:19:43 -0000 1.8 @@ -1,63 +1,23 @@ package org.apache.xindice.examples; /* - * The Apache Software License, Version 1.1 + * Copyright 1999-2004 The Apache Software Foundation. * - * - * Copyright (c) 1999 The Apache Software Foundation. All rights - * reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by the - * Apache Software Foundation (http://www.apache.org/)." - * Alternately, this acknowledgment may appear in the software itself, - * if and wherever such third-party acknowledgments normally appear. - * - * 4. The names "Xindice" and "Apache Software Foundation" must - * not be used to endorse or promote products derived from this - * software without prior written permission. For written - * permission, please contact [EMAIL PROTECTED] - * - * 5. Products derived from this software may not be called "Apache", - * nor may "Apache" appear in their name, without prior written - * permission of the Apache Software Foundation. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * ==================================================================== - * - * This software consists of voluntary contributions made by many - * individuals on behalf of the Apache Software Foundation and was - * originally based on software copyright (c) 1999-2001, The dbXML - * Group, L.L.C., http://www.dbxmlgroup.com. For more - * information on the Apache Software Foundation, please see - * <http://www.apache.org/>. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. * * CVS $Id$ */ + import org.apache.xindice.client.xmldb.services.CollectionManager; import org.apache.xindice.xml.dom.DOMParser; import org.xmldb.api.base.Collection; @@ -68,43 +28,41 @@ */ public class CreateCollection extends AbstractExample { - private static final String COLLECTION_NAME = "mycollection"; + private static final String COLLECTION_NAME = "mycollection"; + + public static void main(String[] args) throws Exception { + Collection collection = null; + try { + +// collection = getCollection("xmldb:xindice:///db/"); + collection = getCollection("xmldb:xindice://localhost:8888/db/"); +// collection = getCollection("xmldb:xindice-embed:///db/"); - public static void main(String[] args) throws Exception { - Collection collection = null; - try { - -// collection = getCollection("xmldb:xindice:///db/"); - collection = getCollection("xmldb:xindice://localhost:8888/db/"); -// collection = getCollection("xmldb:xindice-embed:///db/"); - - CollectionManager service = (CollectionManager) collection.getService("CollectionManager", "1.0"); - - try{ - service.dropCollection(COLLECTION_NAME); - System.out.println("Dropped existing collection with name: " + COLLECTION_NAME); - } - catch (Exception e) { + CollectionManager service = (CollectionManager) collection.getService("CollectionManager", "1.0"); + + try{ + service.dropCollection(COLLECTION_NAME); + System.out.println("Dropped existing collection with name: " + COLLECTION_NAME); + } + catch (Exception e) { ; // nothing, this may be the first pass. } - // Build up the Collection XML configuration. - String collectionConfig = - "<collection compressed=\"true\" name=\"" + COLLECTION_NAME + "\">" - + " <filer class=\"org.apache.xindice.core.filer.BTreeFiler\"/>" - + "</collection>"; - - service.createCollection(COLLECTION_NAME, DOMParser.toDocument(collectionConfig)); - - System.out.println("Collection " + COLLECTION_NAME + " created."); - } - catch (XMLDBException e) { - System.err.println("XML:DB Exception occured " + e.errorCode + " " + e.getMessage()); - } - finally { - if (collection != null) { - collection.close(); - } - } - } + // Build up the Collection XML configuration. + String collectionConfig = + "<collection compressed=\"true\" name=\"" + COLLECTION_NAME + "\">" + + " <filer class=\"org.apache.xindice.core.filer.BTreeFiler\"/>" + + "</collection>"; + + service.createCollection(COLLECTION_NAME, DOMParser.toDocument(collectionConfig)); + + System.out.println("Collection " + COLLECTION_NAME + " created."); + } catch (XMLDBException e) { + System.err.println("XML:DB Exception occured " + e.errorCode + " " + e.getMessage()); + } finally { + if (collection != null) { + collection.close(); + } + } + } } 1.6 +27 -69 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.5 retrieving revision 1.6 diff -u -r1.5 -r1.6 --- DeleteDocument.java 7 Aug 2003 20:13:20 -0000 1.5 +++ DeleteDocument.java 8 Feb 2004 01:19:43 -0000 1.6 @@ -1,63 +1,23 @@ package org.apache.xindice.examples; /* - * The Apache Software License, Version 1.1 + * Copyright 1999-2004 The Apache Software Foundation. * - * - * Copyright (c) 1999 The Apache Software Foundation. All rights - * reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by the - * Apache Software Foundation (http://www.apache.org/)." - * Alternately, this acknowledgment may appear in the software itself, - * if and wherever such third-party acknowledgments normally appear. - * - * 4. The names "Xindice" and "Apache Software Foundation" must - * not be used to endorse or promote products derived from this - * software without prior written permission. For written - * permission, please contact [EMAIL PROTECTED] - * - * 5. Products derived from this software may not be called "Apache", - * nor may "Apache" appear in their name, without prior written - * permission of the Apache Software Foundation. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * ==================================================================== - * - * This software consists of voluntary contributions made by many - * individuals on behalf of the Apache Software Foundation and was - * originally based on software copyright (c) 1999-2001, The dbXML - * Group, L.L.C., http://www.dbxmlgroup.com. For more - * information on the Apache Software Foundation, please see - * <http://www.apache.org/>. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. * * CVS $Id$ */ + import org.xmldb.api.base.Collection; import org.xmldb.api.base.Resource; import org.xmldb.api.base.XMLDBException; @@ -66,23 +26,21 @@ * Simple XML:DB API Example to delete a document from the database. */ public class DeleteDocument extends AbstractExample { - public static void main(String[] args) throws Exception { - Collection collection = null; - try { + public static void main(String[] args) throws Exception { + Collection collection = null; + try { - collection = getCollection("xmldb:xindice:///db/addressbook"); + collection = getCollection("xmldb:xindice:///db/addressbook"); - Resource document = collection.getResource(args[0]); - collection.removeResource(document); - System.out.println("Document " + args[0] + " removed"); - } - catch (XMLDBException e) { - System.err.println("XML:DB Exception occured " + e.errorCode + " " + e.getMessage()); - } - finally { - if (collection != null) { - collection.close(); - } - } - } + Resource document = collection.getResource(args[0]); + collection.removeResource(document); + System.out.println("Document " + args[0] + " removed"); + } catch (XMLDBException e) { + System.err.println("XML:DB Exception occured " + e.errorCode + " " + e.getMessage()); + } finally { + if (collection != null) { + collection.close(); + } + } + } } 1.7 +33 -75 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.6 retrieving revision 1.7 diff -u -r1.6 -r1.7 --- Example1.java 7 Aug 2003 20:13:20 -0000 1.6 +++ Example1.java 8 Feb 2004 01:19:43 -0000 1.7 @@ -1,63 +1,23 @@ package org.apache.xindice.examples; /* - * The Apache Software License, Version 1.1 + * Copyright 1999-2004 The Apache Software Foundation. * - * - * Copyright (c) 1999 The Apache Software Foundation. All rights - * reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by the - * Apache Software Foundation (http://www.apache.org/)." - * Alternately, this acknowledgment may appear in the software itself, - * if and wherever such third-party acknowledgments normally appear. - * - * 4. The names "Xindice" and "Apache Software Foundation" must - * not be used to endorse or promote products derived from this - * software without prior written permission. For written - * permission, please contact [EMAIL PROTECTED] - * - * 5. Products derived from this software may not be called "Apache", - * nor may "Apache" appear in their name, without prior written - * permission of the Apache Software Foundation. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * ==================================================================== - * - * This software consists of voluntary contributions made by many - * individuals on behalf of the Apache Software Foundation and was - * originally based on software copyright (c) 1999-2001, The dbXML - * Group, L.L.C., http://www.dbxmlgroup.com. For more - * information on the Apache Software Foundation, please see - * <http://www.apache.org/>. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. * * CVS $Id$ */ + import org.xmldb.api.base.Collection; import org.xmldb.api.base.Resource; import org.xmldb.api.base.ResourceIterator; @@ -69,30 +29,28 @@ * Simple XML:DB API example to query the database. */ public class Example1 extends AbstractExample { - - public static void main(String[] args) throws Exception { - Collection collection = null; - try { + + public static void main(String[] args) throws Exception { + Collection collection = null; + try { - collection = getCollection("xmldb:xindice:///db/addressbook"); + collection = getCollection("xmldb:xindice:///db/addressbook"); - String xpath = "//person[fname='John']"; - XPathQueryService service = (XPathQueryService) collection.getService("XPathQueryService", "1.0"); - ResourceSet resourceSet = service.query(xpath); - ResourceIterator resourceIterator = resourceSet.getIterator(); + String xpath = "//person[fname='John']"; + XPathQueryService service = (XPathQueryService) collection.getService("XPathQueryService", "1.0"); + ResourceSet resourceSet = service.query(xpath); + ResourceIterator resourceIterator = resourceSet.getIterator(); - while (resourceIterator.hasMoreResources()) { - Resource resource = resourceIterator.nextResource(); - System.out.println((String) resource.getContent()); - } - } - catch (XMLDBException e) { - System.err.println("XML:DB Exception occured " + e.errorCode + " " + e.getMessage()); - } - finally { - if (collection != null) { - collection.close(); - } - } - } + while (resourceIterator.hasMoreResources()) { + Resource resource = resourceIterator.nextResource(); + System.out.println((String) resource.getContent()); + } + } catch (XMLDBException e) { + System.err.println("XML:DB Exception occured " + e.errorCode + " " + e.getMessage()); + } finally { + if (collection != null) { + collection.close(); + } + } + } } 1.4 +11 -52 xml-xindice/java/examples/guide/src/org/apache/xindice/examples/ListCollections.java Index: ListCollections.java =================================================================== RCS file: /home/cvs/xml-xindice/java/examples/guide/src/org/apache/xindice/examples/ListCollections.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- ListCollections.java 15 Aug 2003 03:04:56 -0000 1.3 +++ ListCollections.java 8 Feb 2004 01:19:43 -0000 1.4 @@ -1,60 +1,19 @@ package org.apache.xindice.examples; /* - * The Apache Software License, Version 1.1 + * Copyright 1999-2004 The Apache Software Foundation. * - * - * Copyright (c) 1999 The Apache Software Foundation. All rights - * reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by the - * Apache Software Foundation (http://www.apache.org/)." - * Alternately, this acknowledgment may appear in the software itself, - * if and wherever such third-party acknowledgments normally appear. - * - * 4. The names "Xindice" and "Apache Software Foundation" must - * not be used to endorse or promote products derived from this - * software without prior written permission. For written - * permission, please contact [EMAIL PROTECTED] - * - * 5. Products derived from this software may not be called "Apache", - * nor may "Apache" appear in their name, without prior written - * permission of the Apache Software Foundation. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * ==================================================================== - * - * This software consists of voluntary contributions made by many - * individuals on behalf of the Apache Software Foundation and was - * originally based on software copyright (c) 1999-2001, The dbXML - * Group, L.L.C., http://www.dbxmlgroup.com. For more - * information on the Apache Software Foundation, please see - * <http://www.apache.org/>. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. * * CVS $Id$ */ 1.6 +32 -74 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.5 retrieving revision 1.6 diff -u -r1.5 -r1.6 --- RetrieveDocument.java 7 Aug 2003 20:13:20 -0000 1.5 +++ RetrieveDocument.java 8 Feb 2004 01:19:43 -0000 1.6 @@ -1,63 +1,23 @@ package org.apache.xindice.examples; /* - * The Apache Software License, Version 1.1 + * Copyright 1999-2004 The Apache Software Foundation. * - * - * Copyright (c) 1999 The Apache Software Foundation. All rights - * reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by the - * Apache Software Foundation (http://www.apache.org/)." - * Alternately, this acknowledgment may appear in the software itself, - * if and wherever such third-party acknowledgments normally appear. - * - * 4. The names "Xindice" and "Apache Software Foundation" must - * not be used to endorse or promote products derived from this - * software without prior written permission. For written - * permission, please contact [EMAIL PROTECTED] - * - * 5. Products derived from this software may not be called "Apache", - * nor may "Apache" appear in their name, without prior written - * permission of the Apache Software Foundation. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * ==================================================================== - * - * This software consists of voluntary contributions made by many - * individuals on behalf of the Apache Software Foundation and was - * originally based on software copyright (c) 1999-2001, The dbXML - * Group, L.L.C., http://www.dbxmlgroup.com. For more - * information on the Apache Software Foundation, please see - * <http://www.apache.org/>. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. * * CVS $Id$ */ + import org.xmldb.api.base.Collection; import org.xmldb.api.base.XMLDBException; import org.xmldb.api.modules.XMLResource; @@ -67,28 +27,26 @@ */ public class RetrieveDocument extends AbstractExample { - public static void main(String[] args) throws Exception { - Collection collection = null; - try { + public static void main(String[] args) throws Exception { + Collection collection = null; + try { - collection = getCollection("xmldb:xindice:///db/addressbook"); + collection = getCollection("xmldb:xindice:///db/addressbook"); - XMLResource xmlResource = (XMLResource) collection.getResource(args[0]); - if (xmlResource != null) { - System.out.println("Document " + args[0]); - System.out.println(xmlResource.getContent()); - } - else { - System.out.println("Document not found"); - } - } - catch (XMLDBException e) { - System.err.println("XML:DB Exception occured " + e.errorCode + " " + e.getMessage()); - } - finally { - if (collection != null) { - collection.close(); - } - } - } + XMLResource xmlResource = (XMLResource) collection.getResource(args[0]); + if (xmlResource != null) { + System.out.println("Document " + args[0]); + System.out.println(xmlResource.getContent()); + } + else { + System.out.println("Document not found"); + } + } catch (XMLDBException e) { + System.err.println("XML:DB Exception occured " + e.errorCode + " " + e.getMessage()); + } finally { + if (collection != null) { + collection.close(); + } + } + } } 1.7 +36 -78 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.6 retrieving revision 1.7 diff -u -r1.6 -r1.7 --- XUpdate.java 7 Aug 2003 20:13:20 -0000 1.6 +++ XUpdate.java 8 Feb 2004 01:19:43 -0000 1.7 @@ -1,63 +1,23 @@ package org.apache.xindice.examples; /* - * The Apache Software License, Version 1.1 + * Copyright 1999-2004 The Apache Software Foundation. * - * - * Copyright (c) 1999 The Apache Software Foundation. All rights - * reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by the - * Apache Software Foundation (http://www.apache.org/)." - * Alternately, this acknowledgment may appear in the software itself, - * if and wherever such third-party acknowledgments normally appear. - * - * 4. The names "Xindice" and "Apache Software Foundation" must - * not be used to endorse or promote products derived from this - * software without prior written permission. For written - * permission, please contact [EMAIL PROTECTED] - * - * 5. Products derived from this software may not be called "Apache", - * nor may "Apache" appear in their name, without prior written - * permission of the Apache Software Foundation. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * ==================================================================== - * - * This software consists of voluntary contributions made by many - * individuals on behalf of the Apache Software Foundation and was - * originally based on software copyright (c) 1999-2001, The dbXML - * Group, L.L.C., http://www.dbxmlgroup.com. For more - * information on the Apache Software Foundation, please see - * <http://www.apache.org/>. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. * * CVS $Id$ */ + import org.xmldb.api.base.Collection; import org.xmldb.api.base.XMLDBException; import org.xmldb.api.modules.XUpdateQueryService; @@ -66,33 +26,31 @@ * Simple XML:DB API example to update the database. */ public class XUpdate extends AbstractExample { - - public static void main(String[] args) throws Exception { - Collection collection = null; - try { + + public static void main(String[] args) throws Exception { + Collection collection = null; + try { - collection = getCollection("xmldb:xindice:///db/addressbook"); + collection = getCollection("xmldb:xindice:///db/addressbook"); - String xupdate = - "<xu:modifications version=\"1.0\"" - + " xmlns:xu=\"http://www.xmldb.org/xupdate\">" - + " <xu:remove select=\"/person/[EMAIL PROTECTED] = 'home']\"/>" - + " <xu:update select=\"/person/[EMAIL PROTECTED] = 'work']\">" - + " 480-300-3003" - + " </xu:update>" - + "</xu:modifications>"; + String xupdate = + "<xu:modifications version=\"1.0\"" + + " xmlns:xu=\"http://www.xmldb.org/xupdate\">" + + " <xu:remove select=\"/person/[EMAIL PROTECTED] = 'home']\"/>" + + " <xu:update select=\"/person/[EMAIL PROTECTED] = 'work']\">" + + " 480-300-3003" + + " </xu:update>" + + "</xu:modifications>"; - XUpdateQueryService service = (XUpdateQueryService) collection.getService("XUpdateQueryService", "1.0"); - long count = service.update(xupdate); - System.out.println(count + " entries updated."); - } - catch (XMLDBException e) { - System.err.println("XML:DB Exception occured " + e.errorCode + " " + e.getMessage()); - } - finally { - if (collection != null) { - collection.close(); - } - } - } + XUpdateQueryService service = (XUpdateQueryService) collection.getService("XUpdateQueryService", "1.0"); + long count = service.update(xupdate); + System.out.println(count + " entries updated."); + } catch (XMLDBException e) { + System.err.println("XML:DB Exception occured " + e.errorCode + " " + e.getMessage()); + } finally { + if (collection != null) { + collection.close(); + } + } + } } 1.2 +19 -0 xml-xindice/java/examples/guide/xml/address1.xml Index: address1.xml =================================================================== RCS file: /home/cvs/xml-xindice/java/examples/guide/xml/address1.xml,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- address1.xml 6 Dec 2001 19:33:53 -0000 1.1 +++ address1.xml 8 Feb 2004 01:19:43 -0000 1.2 @@ -1,4 +1,23 @@ <?xml version="1.0"?> + +<!-- + - Copyright 1999-2004 The Apache Software Foundation. + - + - Licensed under the Apache License, Version 2.0 (the "License"); + - you may not use this file except in compliance with the License. + - You may obtain a copy of the License at + - + - http://www.apache.org/licenses/LICENSE-2.0 + - + - Unless required by applicable law or agreed to in writing, software + - distributed under the License is distributed on an "AS IS" BASIS, + - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + - See the License for the specific language governing permissions and + - limitations under the License. + - + - CVS $Id$ + --> + <person> <fname>John</fname> <lname>Smith</lname> 1.2 +19 -0 xml-xindice/java/examples/guide/xml/address2.xml Index: address2.xml =================================================================== RCS file: /home/cvs/xml-xindice/java/examples/guide/xml/address2.xml,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- address2.xml 6 Dec 2001 19:33:53 -0000 1.1 +++ address2.xml 8 Feb 2004 01:19:43 -0000 1.2 @@ -1,4 +1,23 @@ <?xml version="1.0"?> + +<!-- + - Copyright 1999-2004 The Apache Software Foundation. + - + - Licensed under the Apache License, Version 2.0 (the "License"); + - you may not use this file except in compliance with the License. + - You may obtain a copy of the License at + - + - http://www.apache.org/licenses/LICENSE-2.0 + - + - Unless required by applicable law or agreed to in writing, software + - distributed under the License is distributed on an "AS IS" BASIS, + - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + - See the License for the specific language governing permissions and + - limitations under the License. + - + - CVS $Id$ + --> + <person> <fname>SlackJawedLocal</fname> <lname>Cletus</lname>