db-torque-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Michael Hart <mich...@perceptek.com.au>
Subject Fix for relative XML references
Date Sat, 10 Apr 2004 05:08:44 GMT

I've been using torque-gen 3.1 to generate my DB structure and I ran 
into troubles when trying to reference relative filenames from the 
schema XML (would just get a "org.apache.torque.engine.EngineException 
(The system cannot find the file specified)" while invoking ant with 
build-torque.xml, with torque.useClasspath = true). This occurs with 
both relative DTD references (ie <!DOCTYPE database SYSTEM 
"database_3_1.dtd">) and with entities that I wished to include inline 
(ie <!ENTITY customer SYSTEM "my-schema_customer.xml"> so that 
"&customer;" can be used throughout the schema XML file). It appears the 
system tries to resolve the filenames relative to the dir where the JVM 
was invoked from as opposed to the dir where the referring XML file lives.

I've been able to fix these problems by adding a few lines to some of 
the org.apache.torque.engine.database.transform classes - from what I've 
read (I'm not much of a XML-in-Java guru), adding a setSystemId() call 
to an InputSource will enable relatively addressed files to be resolved 
correctly, so here are the files and lines changed to enable this 
(sorry, I haven't done a diff patch):

org/apache/torque/engine/database/transform/XmlToAppData.java, line 191 
to 196:

                InputSource is = new InputSource(br);

                // Set the system ID for relative file resolution
                is.setSystemId((new File(xmlFile)).toURI().toString());

                parser.parse(is, this);
org/apache/torque/engine/database/transform/XmlToAppData.java, line 119 
to 122:

        dataDTD = new InputSource(dtdFile.toURL().openStream());

        // Set the system ID for relative file resolution

I haven't tested this change in any other circumstances except for my 
own, so YMMV.



To unsubscribe, e-mail: torque-dev-unsubscribe@db.apache.org
For additional commands, e-mail: torque-dev-help@db.apache.org

View raw message