db-ddlutils-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Laurent ROCHE <laurent_ro...@yahoo.com>
Subject Reading model file with Java API [aka Re : Re : Still one problem when managing schema ... others fixed !]
Date Wed, 21 Nov 2007 15:46:21 GMT
Hi,

OK, at last I have found the problem, I needed to set two flags (setValidateXml, setUseInternalDtd)
on the reader (i.e. DatabaseIO object).
So the code from previous post (see further) becomes :
        Platform  platform = PlatformFactory.createNewPlatformInstance(dataSource);
        final DatabaseDataIO dataIO = new DatabaseDataIO();
        dataIO.setDetermineSchema(true);
        dataIO.setSchemaPattern(XFR_OUT_SCHEMA);
        try {
            FileOutputStream xmlFile = new FileOutputStream(xmlFPN);
++          DatabaseIO reader = new DatabaseIO(); 
++          reader.setValidateXml(false);
++          reader.setUseInternalDtd(true);
+-          Database model = reader.read(getModelFPN(), XFR_OUT_SCHEMA);
            dataIO.writeDataToXML(platform, model, xmlFile, XML_FILE_ENCODING);
            xmlFile.close();
        } catch (IOException e) {
            e.printStackTrace();
            log.error("Error: Could not create " + xmlFPN);
        }


 
Have fun,
L@u
The Computing Froggy

----- Message d'origine ----
De : Laurent ROCHE <laurent_roche@yahoo.com>
À : ddlutils-user@db.apache.org
Envoyé le : Mardi, 20 Novembre 2007, 12h24mn 57s
Objet : Re : Still one problem when managing schema ... others fixed !

Hi,

I am still having the problem described below.

Has anyone succeeded in reading a model from a XML file using the Java
 API (DatabaseIO.read() ) without any errors ?
If so could he/she publish the piece of code reading the model and the
 XML file of the model, so I can see what I am doing wrong !

 
Thanks in advance,
L@u
The Computing Froggy

----- Message d'origine ----
De : Laurent ROCHE <laurent_roche@yahoo.com>
À : ddlutils-user@db.apache.org
Envoyé le : Mercredi, 14 Novembre 2007, 16h25mn 45s
Objet : Still one problem when managing schema ... others fixed !

Hi,

I have made a few fixes to be able to export/import data using schemas
 (on PostgreSQL), see files included at the end of the post.
Most of them are quite ugly fixes but that works for me  ... and still,
 they should not interfere with other people usage.

I still have one problem though, when running the following code:
      ...
        Platform  platform =
 PlatformFactory.createNewPlatformInstance(dataSource);
        final DatabaseDataIO dataIO = new DatabaseDataIO();
        dataIO.setDetermineSchema(true);
        dataIO.setSchemaPattern(XFR_OUT_SCHEMA);
        try {
            FileOutputStream xmlFile = new FileOutputStream(xmlFPN);
            DatabaseIO reader = new DatabaseIO();
            Database model = reader.read(getModelFPN(),
 XFR_OUT_SCHEMA);
            dataIO.writeDataToXML(platform, model, xmlFile,
 XML_FILE_ENCODING);
            xmlFile.close();
        } catch (IOException e) {
            e.printStackTrace();
            log.error("Error: Could not create " + xmlFPN);
        }
     ...

I get the following errors:
[fims] ERROR [http-80-Processor24]
 Digester.error(1538) | Parse Error at line 2 column 32: Document root
 element "database", must match DOCTYPE root "null".
org.xml.sax.SAXParseException: Document root element "database", must
 match DOCTYPE root "null".
    at
 com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(ErrorHandlerWrapper.java:236)
    at
 com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.error(ErrorHandlerWrapper.java:172)
...
[fims] ERROR [http-80-Processor24] Digester.error(1538) | Parse Error
 at line 2 column 32: Document is invalid: no grammar found.
org.xml.sax.SAXParseException: Document is invalid: no grammar found.
    at
 com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(ErrorHandlerWrapper.java:236)
...
The file is created OK though ! ? ! ?
What
 should I do, to get rid of this error messages ?
I understand they come from the parser going through the XML ... but
 why don't I get these when using the Ant tasks ?
I must do something wrong somewhere !
Let me know.

...









    
  _____________________________________________________________________________ 
Ne gardez plus qu'une seule adresse mail ! Copiez vos mails vers Yahoo!
 Mail 





      _____________________________________________________________________________ 
Ne gardez plus qu'une seule adresse mail ! Copiez vos mails vers Yahoo! Mail 
Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message