diff --git a/src/net/sourceforge/schemaspy/model/xml/ForeignKeyMeta.java b/src/net/sourceforge/schemaspy/model/xml/ForeignKeyMeta.java index 63f487c..c9b0257 100644 --- a/src/net/sourceforge/schemaspy/model/xml/ForeignKeyMeta.java +++ b/src/net/sourceforge/schemaspy/model/xml/ForeignKeyMeta.java @@ -13,10 +13,27 @@ public class ForeignKeyMeta { ForeignKeyMeta(Node foreignKeyNode) { NamedNodeMap attribs = foreignKeyNode.getAttributes(); + Node node = attribs.getNamedItem("table"); + if (node == null) + throw new IllegalStateException("XML foreignKey definition requires 'table' attribute"); + tableName = node.getNodeValue(); + attribs.removeNamedItem("table"); + node = attribs.getNamedItem("column"); + if (node == null) + throw new IllegalStateException("XML foreignKey definition requires 'column' attribute"); + columnName = node.getNodeValue(); + attribs.removeNamedItem("column"); + node = attribs.getNamedItem("remoteSchema"); + if (node != null) { + remoteSchema = node.getNodeValue(); + attribs.removeNamedItem("remoteSchema"); + } else { + remoteSchema = null; + } - tableName = attribs.getNamedItem("table").getNodeValue(); - columnName = attribs.getNamedItem("column").getNodeValue(); - remoteSchema = attribs.getNamedItem("remoteSchema") == null ? null : attribs.getNamedItem("remoteSchema").getNodeValue(); + for (int i = 0; i < attribs.getLength(); ++i) { + System.err.println("Unrecognized attribute '" + attribs.item(i).getNodeName() + "' in XML definition of foreignKey"); + } } public String getTableName() { diff --git a/src/net/sourceforge/schemaspy/model/xml/TableColumnMeta.java b/src/net/sourceforge/schemaspy/model/xml/TableColumnMeta.java index af6190b..fa39a50 100644 --- a/src/net/sourceforge/schemaspy/model/xml/TableColumnMeta.java +++ b/src/net/sourceforge/schemaspy/model/xml/TableColumnMeta.java @@ -24,16 +24,23 @@ public class TableColumnMeta { String tmp; name = attribs.getNamedItem("name").getNodeValue(); + attribs.removeNamedItem("name"); Node node = attribs.getNamedItem("comments"); if (node != null) { tmp = node.getNodeValue().trim(); comments = tmp.length() == 0 ? null : tmp; + attribs.removeNamedItem("comments"); } else { comments = null; } node = attribs.getNamedItem("primaryKey"); - isPrimary = node != null && evalBoolean(node.getNodeValue()); + if (node != null) { + isPrimary = evalBoolean(node.getNodeValue()); + attribs.removeNamedItem("primaryKey"); + } else { + isPrimary = false; + } node = attribs.getNamedItem("disableImpliedKeys"); if (node != null) { @@ -51,12 +58,19 @@ public class TableColumnMeta { System.err.println(" Valid values include 'to', 'from' and 'all'"); isImpliedChildrenDisabled = isImpliedParentsDisabled = false; } + + attribs.removeNamedItem("disableImpliedKeys"); } else { isImpliedChildrenDisabled = isImpliedParentsDisabled = false; } node = attribs.getNamedItem("disableDiagramAssociations"); - isExcluded = node != null && evalBoolean(node.getNodeValue()); + if (node != null) { + isExcluded = evalBoolean(node.getNodeValue()); + attribs.removeNamedItem("disableDiagramAssociations"); + } else { + isExcluded = false; + } NodeList fkNodes = ((Element)colNode.getChildNodes()).getElementsByTagName("foreignKey"); @@ -64,6 +78,10 @@ public class TableColumnMeta { Node fkNode = fkNodes.item(i); foreignKeys.add(new ForeignKeyMeta(fkNode)); } + + for (int i = 0; i < attribs.getLength(); ++i) { + System.err.println("Unrecognized attribute '" + attribs.item(i).getNodeName() + "' in XML definition of column '" + name + '\''); + } } private boolean evalBoolean(String exp) { diff --git a/src/net/sourceforge/schemaspy/model/xml/TableMeta.java b/src/net/sourceforge/schemaspy/model/xml/TableMeta.java index 182bfac..10cbdbf 100644 --- a/src/net/sourceforge/schemaspy/model/xml/TableMeta.java +++ b/src/net/sourceforge/schemaspy/model/xml/TableMeta.java @@ -20,15 +20,24 @@ public class TableMeta { NamedNodeMap attribs = tableNode.getAttributes(); name = attribs.getNamedItem("name").getNodeValue(); + attribs.removeNamedItem("name"); + Node commentNode = attribs.getNamedItem("comments"); if (commentNode != null) { String tmp = commentNode.getNodeValue().trim(); comments = tmp.length() == 0 ? null : tmp; + attribs.removeNamedItem("comments"); } else { comments = null; } + Node remoteSchemaNode = attribs.getNamedItem("remoteSchema"); - remoteSchema = remoteSchemaNode == null ? null : remoteSchemaNode.getNodeValue().trim(); + if (remoteSchemaNode != null) { + attribs.removeNamedItem("remoteSchema"); + remoteSchema = remoteSchemaNode.getNodeValue().trim(); + } else { + remoteSchema = null; + } NodeList columnNodes = ((Element)tableNode.getChildNodes()).getElementsByTagName("column"); @@ -36,6 +45,10 @@ public class TableMeta { Node colNode = columnNodes.item(i); columns.add(new TableColumnMeta(colNode)); } + + for (int i = 0; i < attribs.getLength(); ++i) { + System.err.println("Unrecognized attribute '" + attribs.item(i).getNodeName() + "' in XML definition of table '" + name + '\''); + } } public String getName() {