[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: ozone + xerces.DOMWriter



Hi,

Wed, 15 Mar 2000 Thomas Guettler wrote:
>I tried to write out the dom I get from ozone with Xerces DOMWriter.
>I have two questions I couldn't solve by looking at the ozone-documentation:

The documentation is still very poor on this.

>1.Are transaction optional, or must I enclose acces to the proxy-objects in
>transactions

I would say "optional" is not the right word. You have to use transactions
(tx.begin(), tx.commit(), tx.abort()) if you want to ensure that you data
will be synchronised after some kind of error. Especially for writing/updating
database content.

>2. must I convert the DOM from ozone before accessing it?

No, you don't. The DOMConverter is tool to allow "non-persistent" changes to
your current DOM object. Because you only want to print (read) the DOM object
you don't need to convert it to an "in-memory" DOM. This is useful for XML
applications like Cocoon, that will change the Document with deleting PI-tags.

>When I run my little program i get:
>family
><family>
><familyjava.lang.NullPointerException
>              at org.ozoneDB.OzoneObject.self(OzoneObject.java:41)
>              at
>org.ozoneDB.xml.dom.ElementImpl.getAttributes(ElementImpl.java:143)
>              at dom.DOMWriter.print(DOMWriter.java:233)
>              at dom.DOMWriter.print(DOMWriter.java:247)
>              at dom.DOMWriter.print(DOMWriter.java:224)
>              at Ozone2web.main(Ozone2web.java:22)
>in line 233 DOMWriter is just accessing like this
>                      Attr attrs[] = sortAttributes(node.getAttributes());
>
>my prog is:
>        database.open (hostname, 3333);
>        database.reloadClasses();
>        d = (Document) database.objectForName (docName);
>        System.out.println("pDoc");
>        boolean canonical=true;
>        DOMWriter writer = new DOMWriter("ISO-8859-1",canonical);
>        tx.begin();
>        System.out.println(d.getDocumentElement().getTagName());
>        System.out.println("domwriter created");
>        writer.print(d);
>
>Has someone an idear what's wrong?

Hmm, so far I canĀ“t see any error. I tried this piece of code with the DOMWriter
of Xerces 1.0.2 samples package and it worked. I put test.xml into the database
and used the attached code to print the database content back to stdout.

Which Xerces version do you use?

Regards,
Lars
--
________________________________________________________________
Lars Martin                         mailto:lars@softwarebuero.de
softwarebuero m&b (SMB)              http://www.softwarebuero.de
package dom;

import org.w3c.dom.*;
import org.ozoneDB.*;

public class MyWriter {

    public static void main (String argv[]) {
        try {
            RemoteDatabase database = new RemoteDatabase ();
            database.open ("localhost", 3333);
            database.reloadClasses();

            Document d = (Document) database.objectForName ("test.xml");

            System.out.println("pDoc");
            boolean canonical=true;
            DOMWriter writer = new DOMWriter("ISO-8859-1",canonical);

            System.out.println(d.getDocumentElement().getTagName());
            System.out.println("domwriter created");

            writer.print(d);
            }
        catch (Exception except) {
            except.printStackTrace ();
            }
        }

}