// You can redistribute this software and/or modify it under the terms of
// the Ozone Library License version 1 published by ozone-db.org.
//
// The original code and portions created by SMB are
// Copyright (C) 1997-@year@ by SMB GmbH. All rights reserved.
//
package test.xmldb.other;
import test.xmldb.*;
import java.io.StringWriter;
import org.ozoneDB.xml.core.XMLCollection;
import org.xmldb.api.modules.XMLResource;
import org.xmldb.api.base.Collection;
import org.xmldb.api.base.Database;
import org.xmldb.api.DatabaseManager;
import org.w3c.dom.Document;
import org.apache.xml.serialize.OutputFormat;
import org.apache.xml.serialize.XMLSerializer;
/**
* @author Per Nyfelt
*/
public class RetrieveDocument implements Constants{
/** Creates new RetrieveDocument */
public RetrieveDocument() {
try {
Class c = Class.forName(driver);
Database database = (Database) c.newInstance();
System.out.println("Registring Database " + database);
DatabaseManager.registerDatabase(database);
Collection col = database.getCollection(collectionURI);
System.out.println("Got Collection " + col);
XMLResource resource = (XMLResource) col.getResource(resourceName);
System.out.println("Got resource " + resource + " for " + resourceName);
Document doc = (Document)resource.getContentAsDOM();
System.out.println("Retrieved the Document with root: " + doc.getDocumentElement().getTagName());
String content = (String)resource.getContent();
System.out.println("here's the content:\n" + content);
col.close();
}
catch (Exception e) {
e.printStackTrace();
}
}
public static void main( String args[] ) {
new RetrieveDocument();
}
}