Sometimes code is better so here's a junit-Test to see what I mean. Another problem is that I can not run the unit-test directly from within eclipse because the DTD can not be resolved appropriately the LocalEntityResolver.resolveEntity() is never called.
-------------------8<-------------------
SCHWERWIEGEND: Parse Error at line 1 column 23: 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(Unknown
Source)
at
com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.error(Unknown
Source)
-------------------8<-------------------
Tom
Tom Schindl wrote:
> Thomas Dudziak wrote:
>
>>On 4/20/06, Tom Schindl <[EMAIL PROTECTED]> wrote:
>>
>>
>>
>>>yes I understand. Attached is the patch to the questionable missing
>>>break which is when missining intentional strange and should at least be
>>>documented.
>>
>>
>>Thanks, is fixed in SVN
>>
>>
>>
>>>One more question I don't see any code that deals with the situations
>>>where one changes e.g. the name of column/table, removes a column/table,
>>>... which is referenced in indices, foreign keys, ... .
>>
>>
>>I'm not exactly sure what you mean ?
>
>
> Well suppose I'm writing a modelling tool based upon your Model-Classes
> having created 2 tables and foreign key constraint. After that I see
> that I have a typo in the name of the the foreign-key provider table, if
> I now rename the table by setting setName() the ForgeinKey-Reference
> doesn't get informed about this and as result the internal structure is
> broken:
>
> _foreignTableName != _foreignTable.getName()
>
> if i would now write dump the the files to db.xml I could not load it
> the next time.
>
> The same applies when renaming columns ;-) I think all this situations
> can be dealt with easily when adding PropertyChangeSupport to all model
> classes and e.g. the foreignKey-Instance adds itself to the
> PropertyChangeListeners and updates its _foreignTableName-Attribute when
> the table name changes.
>
> Tom
>
>
>>Tom
>>
>>
>>
>
>
package org.apache.ddlutils.model;
import java.io.StringReader;
import org.apache.ddlutils.io.DatabaseIO;
import junit.framework.TestCase;
public class ForeignKeyTest extends TestCase {
private Database readModel(String modelAsXml)
{
DatabaseIO reader = new DatabaseIO();
// NOT WORKING FOR ME
// reader.setValidateXml(false);
return reader.read(new StringReader(modelAsXml));
}
public void testTableRenaming() {
Database model = readModel(
"<database name='test'>\n" +
" <table name='SomeTable'\n" +
" description='Some table'>\n" +
" <column name='ID'\n" +
" type='VARCHAR'\n" +
" size='16'\n" +
" primaryKey='true'\n" +
" required='true'\n" +
" description='The primary key'/>\n" +
" </table>\n" +
" <table name='AnotherTable'\n" +
" description='And another table'>\n" +
" <column name='Some_ID'\n" +
" type='VARCHAR'\n" +
" size='16'\n" +
" description='The foreign key'/>\n" +
" <foreign-key foreignTable='SomeTable'>\n" +
" <reference local='Some_ID' foreign='ID'/>\n" +
" </foreign-key>\n" +
" </table>\n" +
"</database>");
model.getTable(0).setName("SomeNewName");
model.initialize();
assertEquals("SomeNewName",
model.getTable(1).getForeignKey(0).getForeignTableName());
}
}
signature.asc
Description: OpenPGP digital signature
