From: <bo...@us...> - 2007-02-05 19:47:45
|
Revision: 147 http://xmlunit.svn.sourceforge.net/xmlunit/?rev=147&view=rev Author: bodewig Date: 2007-02-05 11:47:29 -0800 (Mon, 05 Feb 2007) Log Message: ----------- Fix indentation and remove tabs: (defun fixup-file () (interactive) (save-excursion (let ((start (or (re-search-forward "package") (point-min)))) (indent-region start (point-max) nil) (untabify (point-min) (point-max))))) Modified Paths: -------------- trunk/xmlunit/src/java/org/custommonkey/xmlunit/AbstractNodeTester.java trunk/xmlunit/src/java/org/custommonkey/xmlunit/CountingNodeTester.java trunk/xmlunit/src/java/org/custommonkey/xmlunit/DetailedDiff.java trunk/xmlunit/src/java/org/custommonkey/xmlunit/Diff.java trunk/xmlunit/src/java/org/custommonkey/xmlunit/Difference.java trunk/xmlunit/src/java/org/custommonkey/xmlunit/DifferenceConstants.java trunk/xmlunit/src/java/org/custommonkey/xmlunit/DifferenceEngine.java trunk/xmlunit/src/java/org/custommonkey/xmlunit/DoctypeReader.java trunk/xmlunit/src/java/org/custommonkey/xmlunit/ElementNameAndAttributeQualifier.java trunk/xmlunit/src/java/org/custommonkey/xmlunit/ElementNameAndTextQualifier.java trunk/xmlunit/src/java/org/custommonkey/xmlunit/ElementNameQualifier.java trunk/xmlunit/src/java/org/custommonkey/xmlunit/ElementQualifier.java trunk/xmlunit/src/java/org/custommonkey/xmlunit/HTMLDocumentBuilder.java trunk/xmlunit/src/java/org/custommonkey/xmlunit/IgnoreTextAndAttributeValuesDifferenceListener.java trunk/xmlunit/src/java/org/custommonkey/xmlunit/NodeDescriptor.java trunk/xmlunit/src/java/org/custommonkey/xmlunit/NodeDetail.java trunk/xmlunit/src/java/org/custommonkey/xmlunit/NodeInputStream.java trunk/xmlunit/src/java/org/custommonkey/xmlunit/NodeTest.java trunk/xmlunit/src/java/org/custommonkey/xmlunit/NodeTestException.java trunk/xmlunit/src/java/org/custommonkey/xmlunit/SimpleXpathEngine.java trunk/xmlunit/src/java/org/custommonkey/xmlunit/TolerantSaxDocumentBuilder.java trunk/xmlunit/src/java/org/custommonkey/xmlunit/Transform.java trunk/xmlunit/src/java/org/custommonkey/xmlunit/Validator.java trunk/xmlunit/src/java/org/custommonkey/xmlunit/XMLAssert.java trunk/xmlunit/src/java/org/custommonkey/xmlunit/XMLTestCase.java trunk/xmlunit/src/java/org/custommonkey/xmlunit/XMLUnit.java trunk/xmlunit/src/java/org/custommonkey/xmlunit/XpathNodeTracker.java trunk/xmlunit/src/java/org/custommonkey/xmlunit/examples/MultiLevelElementNameAndTextQualifier.java trunk/xmlunit/tests/java/org/custommonkey/xmlunit/Replacement.java trunk/xmlunit/tests/java/org/custommonkey/xmlunit/SimpleSerializer.java trunk/xmlunit/tests/java/org/custommonkey/xmlunit/examples/test_MultiLevelElementNameAndTextQualifier.java trunk/xmlunit/tests/java/org/custommonkey/xmlunit/jaxp13/test_Jaxp13XpathEngine.java trunk/xmlunit/tests/java/org/custommonkey/xmlunit/test_BugFixes.java trunk/xmlunit/tests/java/org/custommonkey/xmlunit/test_Constants.java trunk/xmlunit/tests/java/org/custommonkey/xmlunit/test_CountingNodeTester.java trunk/xmlunit/tests/java/org/custommonkey/xmlunit/test_DetailedDiff.java trunk/xmlunit/tests/java/org/custommonkey/xmlunit/test_Diff.java trunk/xmlunit/tests/java/org/custommonkey/xmlunit/test_Difference.java trunk/xmlunit/tests/java/org/custommonkey/xmlunit/test_DifferenceEngine.java trunk/xmlunit/tests/java/org/custommonkey/xmlunit/test_DoctypeReader.java trunk/xmlunit/tests/java/org/custommonkey/xmlunit/test_ElementNameAndAttributeQualifier.java trunk/xmlunit/tests/java/org/custommonkey/xmlunit/test_ElementNameAndTextQualifier.java trunk/xmlunit/tests/java/org/custommonkey/xmlunit/test_ElementNameQualifier.java trunk/xmlunit/tests/java/org/custommonkey/xmlunit/test_HTMLDocumentBuilder.java trunk/xmlunit/tests/java/org/custommonkey/xmlunit/test_IgnoreTextAndAttributeValuesDifferenceListener.java trunk/xmlunit/tests/java/org/custommonkey/xmlunit/test_JAXP_1_2_Schema_Validation.java trunk/xmlunit/tests/java/org/custommonkey/xmlunit/test_NodeDescriptor.java trunk/xmlunit/tests/java/org/custommonkey/xmlunit/test_NodeTest.java trunk/xmlunit/tests/java/org/custommonkey/xmlunit/test_Replacement.java trunk/xmlunit/tests/java/org/custommonkey/xmlunit/test_SimpleXpathEngine.java trunk/xmlunit/tests/java/org/custommonkey/xmlunit/test_TolerantSaxDocumentBuilder.java trunk/xmlunit/tests/java/org/custommonkey/xmlunit/test_Transform.java trunk/xmlunit/tests/java/org/custommonkey/xmlunit/test_Validator.java trunk/xmlunit/tests/java/org/custommonkey/xmlunit/test_XMLTestCase.java trunk/xmlunit/tests/java/org/custommonkey/xmlunit/test_XMLUnit.java trunk/xmlunit/tests/java/org/custommonkey/xmlunit/test_XpathNodeTracker.java Modified: trunk/xmlunit/src/java/org/custommonkey/xmlunit/AbstractNodeTester.java =================================================================== --- trunk/xmlunit/src/java/org/custommonkey/xmlunit/AbstractNodeTester.java 2007-02-02 21:36:23 UTC (rev 146) +++ trunk/xmlunit/src/java/org/custommonkey/xmlunit/AbstractNodeTester.java 2007-02-05 19:47:29 UTC (rev 147) @@ -71,41 +71,41 @@ */ public void testNode(Node aNode, NodeTest forTest) throws NodeTestException { switch (aNode.getNodeType()) { - case Node.ATTRIBUTE_NODE: - // should not happen as attributes are not exposed by DOM traversal - testAttribute((Attr)aNode); - break; - case Node.CDATA_SECTION_NODE: - testCDATASection((CDATASection)aNode); - break; - case Node.COMMENT_NODE: - testComment((Comment)aNode); - break; - case Node.DOCUMENT_TYPE_NODE: - testDocumentType((DocumentType)aNode); - break; - case Node.ELEMENT_NODE: - testElement((Element)aNode); - break; - case Node.ENTITY_NODE: - testEntity((Entity)aNode); - break; - case Node.ENTITY_REFERENCE_NODE: - testEntityReference((EntityReference)aNode); - break; - case Node.NOTATION_NODE: - testNotation((Notation)aNode); - break; - case Node.PROCESSING_INSTRUCTION_NODE: - testProcessingInstruction( - (ProcessingInstruction) aNode); - break; - case Node.TEXT_NODE: - testText((Text)aNode); - break; - default: - throw new NodeTestException("No delegate method for Node type", - aNode); + case Node.ATTRIBUTE_NODE: + // should not happen as attributes are not exposed by DOM traversal + testAttribute((Attr)aNode); + break; + case Node.CDATA_SECTION_NODE: + testCDATASection((CDATASection)aNode); + break; + case Node.COMMENT_NODE: + testComment((Comment)aNode); + break; + case Node.DOCUMENT_TYPE_NODE: + testDocumentType((DocumentType)aNode); + break; + case Node.ELEMENT_NODE: + testElement((Element)aNode); + break; + case Node.ENTITY_NODE: + testEntity((Entity)aNode); + break; + case Node.ENTITY_REFERENCE_NODE: + testEntityReference((EntityReference)aNode); + break; + case Node.NOTATION_NODE: + testNotation((Notation)aNode); + break; + case Node.PROCESSING_INSTRUCTION_NODE: + testProcessingInstruction( + (ProcessingInstruction) aNode); + break; + case Node.TEXT_NODE: + testText((Text)aNode); + break; + default: + throw new NodeTestException("No delegate method for Node type", + aNode); } } @@ -191,7 +191,7 @@ } private void unhandled(Node aNode) throws NodeTestException { - throw new NodeTestException("Test fails by default in AbstractNodeTester", aNode); + throw new NodeTestException("Test fails by default in AbstractNodeTester", aNode); } /** @@ -201,7 +201,7 @@ * @exception NodeTestException if mode Nodes were expected */ public void noMoreNodes(NodeTest forTest) throws NodeTestException { - //by default do nothing + //by default do nothing } } Modified: trunk/xmlunit/src/java/org/custommonkey/xmlunit/CountingNodeTester.java =================================================================== --- trunk/xmlunit/src/java/org/custommonkey/xmlunit/CountingNodeTester.java 2007-02-02 21:36:23 UTC (rev 146) +++ trunk/xmlunit/src/java/org/custommonkey/xmlunit/CountingNodeTester.java 2007-02-05 19:47:29 UTC (rev 147) @@ -74,7 +74,7 @@ resetCounter(); if (testedNodes != expectedNumNodes) { throw new NodeTestException("Counted " + testedNodes - + " node(s) but expected " + expectedNumNodes); + + " node(s) but expected " + expectedNumNodes); } } Modified: trunk/xmlunit/src/java/org/custommonkey/xmlunit/DetailedDiff.java =================================================================== --- trunk/xmlunit/src/java/org/custommonkey/xmlunit/DetailedDiff.java 2007-02-02 21:36:23 UTC (rev 146) +++ trunk/xmlunit/src/java/org/custommonkey/xmlunit/DetailedDiff.java 2007-02-05 19:47:29 UTC (rev 147) @@ -75,13 +75,13 @@ final int returnValue = super.differenceFound(difference); Difference localDifference = null; switch (returnValue) { - case RETURN_IGNORE_DIFFERENCE_NODES_IDENTICAL: - return returnValue; - case RETURN_ACCEPT_DIFFERENCE: - break; - case RETURN_IGNORE_DIFFERENCE_NODES_SIMILAR: - difference.setRecoverable(true); - break; + case RETURN_IGNORE_DIFFERENCE_NODES_IDENTICAL: + return returnValue; + case RETURN_ACCEPT_DIFFERENCE: + break; + case RETURN_IGNORE_DIFFERENCE_NODES_SIMILAR: + difference.setRecoverable(true); + break; } allDifferences.add(difference); return returnValue; Modified: trunk/xmlunit/src/java/org/custommonkey/xmlunit/Diff.java =================================================================== --- trunk/xmlunit/src/java/org/custommonkey/xmlunit/Diff.java 2007-02-02 21:36:23 UTC (rev 146) +++ trunk/xmlunit/src/java/org/custommonkey/xmlunit/Diff.java 2007-02-05 19:47:29 UTC (rev 147) @@ -72,7 +72,7 @@ * <br />Examples and more at <a href="http://xmlunit.sourceforge.net"/>xmlunit.sourceforge.net</a> */ public class Diff -implements DifferenceListener, ComparisonController { + implements DifferenceListener, ComparisonController { private final Document controlDoc; private final Document testDoc; private boolean similar = true; @@ -98,7 +98,7 @@ public Diff(Reader control, Reader test) throws SAXException, IOException { this(XMLUnit.buildDocument(XMLUnit.newControlParser(), control), - XMLUnit.buildDocument(XMLUnit.newTestParser(), test)); + XMLUnit.buildDocument(XMLUnit.newTestParser(), test)); } /** @@ -115,17 +115,17 @@ public Diff(String control, Transform testTransform) throws IOException, TransformerException, SAXException { this(XMLUnit.buildControlDocument(control), - testTransform.getResultDocument()); + testTransform.getResultDocument()); } - /** - * Construct a Diff that compares the XML read from two JAXP InputSources - */ + /** + * Construct a Diff that compares the XML read from two JAXP InputSources + */ public Diff(InputSource control, InputSource test) throws SAXException, IOException { - this(XMLUnit.buildDocument(XMLUnit.newControlParser(), control), - XMLUnit.buildDocument(XMLUnit.newTestParser(), test)); - } + this(XMLUnit.buildDocument(XMLUnit.newControlParser(), control), + XMLUnit.buildDocument(XMLUnit.newTestParser(), test)); + } /** * Construct a Diff that compares the XML in two JAXP DOMSources @@ -155,9 +155,9 @@ this.testDoc = getManipulatedDocument(testDoc); this.elementQualifierDelegate = elementQualifier; if (comparator == null) { - this.differenceEngine = new DifferenceEngine(this); + this.differenceEngine = new DifferenceEngine(this); } else { - this.differenceEngine = comparator; + this.differenceEngine = comparator; } this.messages = new StringBuffer(); } @@ -168,8 +168,8 @@ * @param prototype a prototypical instance */ protected Diff(Diff prototype) { - this(prototype.controlDoc, prototype.testDoc, prototype.differenceEngine, - prototype.elementQualifierDelegate); + this(prototype.controlDoc, prototype.testDoc, prototype.differenceEngine, + prototype.elementQualifierDelegate); } /** @@ -186,7 +186,7 @@ } try { Transform whitespaceStripper = XMLUnit.getStripWhitespaceTransform( - originalDoc); + originalDoc); return whitespaceStripper.getResultDocument(); } catch (TransformerException e) { throw new XMLUnitRuntimeException(e.getMessage(), e.getCause()); @@ -301,24 +301,24 @@ } switch (returnValue) { - case RETURN_IGNORE_DIFFERENCE_NODES_IDENTICAL: - return returnValue; - case RETURN_IGNORE_DIFFERENCE_NODES_SIMILAR: - identical = false; + case RETURN_IGNORE_DIFFERENCE_NODES_IDENTICAL: + return returnValue; + case RETURN_IGNORE_DIFFERENCE_NODES_SIMILAR: + identical = false; + haltComparison = false; + break; + case RETURN_ACCEPT_DIFFERENCE: + identical = false; + if (difference.isRecoverable()) { haltComparison = false; - break; - case RETURN_ACCEPT_DIFFERENCE: - identical = false; - if (difference.isRecoverable()) { - haltComparison = false; - } else { - similar = false; - haltComparison = true; - } - break; - default: - throw new IllegalArgumentException(returnValue - + " is not a defined DifferenceListener.RETURN_... value"); + } else { + similar = false; + haltComparison = true; + } + break; + default: + throw new IllegalArgumentException(returnValue + + " is not a defined DifferenceListener.RETURN_... value"); } if (haltComparison) { messages.append("\n[different]"); @@ -342,8 +342,8 @@ differenceListenerDelegate.skippedComparison(control, test); } else { System.err.println("DifferenceListener.skippedComparison: " - + "unhandled control node type=" + control - + ", unhandled test node type=" + test); + + "unhandled control node type=" + control + + ", unhandled test node type=" + test); } } @@ -392,13 +392,13 @@ this.differenceListenerDelegate = delegate; } - /** - * Override the <code>ElementQualifier</code> used to determine which - * control and test nodes are comparable for this difference comparison. - * @param delegate the ElementQualifier instance to delegate to. - */ - public void overrideElementQualifier(ElementQualifier delegate) { - this.elementQualifierDelegate = delegate; - } + /** + * Override the <code>ElementQualifier</code> used to determine which + * control and test nodes are comparable for this difference comparison. + * @param delegate the ElementQualifier instance to delegate to. + */ + public void overrideElementQualifier(ElementQualifier delegate) { + this.elementQualifierDelegate = delegate; + } } Modified: trunk/xmlunit/src/java/org/custommonkey/xmlunit/Difference.java =================================================================== --- trunk/xmlunit/src/java/org/custommonkey/xmlunit/Difference.java 2007-02-02 21:36:23 UTC (rev 146) +++ trunk/xmlunit/src/java/org/custommonkey/xmlunit/Difference.java 2007-02-05 19:47:29 UTC (rev 147) @@ -80,7 +80,7 @@ * encountered NodeDetails */ protected Difference(Difference prototype, NodeDetail controlNodeDetail, - NodeDetail testNodeDetail) { + NodeDetail testNodeDetail) { this(prototype.getId(), prototype.getDescription(), prototype.isRecoverable()); this.controlNodeDetail = controlNodeDetail; this.testNodeDetail = testNodeDetail; @@ -113,7 +113,7 @@ * a DetailedDiff. */ protected void setRecoverable(boolean overrideValue) { - recoverable = overrideValue; + recoverable = overrideValue; } /** @@ -121,7 +121,7 @@ * at the Node where this difference was encountered */ public NodeDetail getControlNodeDetail() { - return controlNodeDetail; + return controlNodeDetail; } /** @@ -129,7 +129,7 @@ * at the Node where this difference was encountered */ public NodeDetail getTestNodeDetail() { - return testNodeDetail; + return testNodeDetail; } /** @@ -153,22 +153,22 @@ * their details also */ public String toString() { - StringBuffer buf = new StringBuffer(); - if (controlNodeDetail == null || testNodeDetail == null) { - appendBasicRepresentation(buf); - } else { - appendDetailedRepresentation(buf); - } + StringBuffer buf = new StringBuffer(); + if (controlNodeDetail == null || testNodeDetail == null) { + appendBasicRepresentation(buf); + } else { + appendDetailedRepresentation(buf); + } return buf.toString(); } private void appendBasicRepresentation(StringBuffer buf) { buf.append("Difference (#").append(id). - append(") ").append(description); + append(") ").append(description); } private void appendDetailedRepresentation(StringBuffer buf) { - buf.append("Expected ").append(getDescription()) + buf.append("Expected ").append(getDescription()) .append(" '").append(controlNodeDetail.getValue()) .append("' but was '").append(testNodeDetail.getValue()) .append("' - comparing "); Modified: trunk/xmlunit/src/java/org/custommonkey/xmlunit/DifferenceConstants.java =================================================================== --- trunk/xmlunit/src/java/org/custommonkey/xmlunit/DifferenceConstants.java 2007-02-02 21:36:23 UTC (rev 146) +++ trunk/xmlunit/src/java/org/custommonkey/xmlunit/DifferenceConstants.java 2007-02-05 19:47:29 UTC (rev 147) @@ -42,53 +42,53 @@ * <br />Examples and more at <a href="http://xmlunit.sourceforge.net"/>xmlunit.sourceforge.net</a> */ public interface DifferenceConstants { - /** Comparing an implied attribute value against an explicit value */ - int ATTR_VALUE_EXPLICITLY_SPECIFIED_ID = 1; - /** Comparing 2 elements and one has an attribute the other does not */ - int ATTR_NAME_NOT_FOUND_ID = 2; - /** Comparing 2 attributes with the same name but different values */ - int ATTR_VALUE_ID = 3; - /** Comparing 2 attribute lists with the same attributes in different sequence */ - int ATTR_SEQUENCE_ID = 4; - /** Comparing 2 CDATA sections with different values */ - int CDATA_VALUE_ID = 5; - /** Comparing 2 comments with different values */ - int COMMENT_VALUE_ID = 6; - /** Comparing 2 document types with different names */ - int DOCTYPE_NAME_ID = 7; - /** Comparing 2 document types with different public identifiers */ - int DOCTYPE_PUBLIC_ID_ID = 8; - /** Comparing 2 document types with different system identifiers */ - int DOCTYPE_SYSTEM_ID_ID = 9; - /** Comparing 2 elements with different tag names */ - int ELEMENT_TAG_NAME_ID = 10; - /** Comparing 2 elements with different number of attributes */ - int ELEMENT_NUM_ATTRIBUTES_ID = 11; - /** Comparing 2 processing instructions with different targets */ - int PROCESSING_INSTRUCTION_TARGET_ID = 12; - /** Comparing 2 processing instructions with different instructions */ - int PROCESSING_INSTRUCTION_DATA_ID = 13; - /** Comparing 2 different text values */ - int TEXT_VALUE_ID = 14; - /** Comparing 2 nodes with different namespace prefixes */ - int NAMESPACE_PREFIX_ID = 15; - /** Comparing 2 nodes with different namespace URIs */ - int NAMESPACE_URI_ID = 16; - /** Comparing 2 nodes with different node types */ - int NODE_TYPE_ID = 17; - /** Comparing 2 nodes but only one has any children*/ - int HAS_CHILD_NODES_ID = 18; - /** Comparing 2 nodes with different numbers of children */ - int CHILD_NODELIST_LENGTH_ID = 19; - /** Comparing 2 nodes with children whose nodes are in different sequence*/ - int CHILD_NODELIST_SEQUENCE_ID = 20; - /** Comparing 2 Documents only one of which has a doctype */ - int HAS_DOCTYPE_DECLARATION_ID = 21; - /** Comparing an implied attribute value against an explicit value */ - public static final Difference ATTR_VALUE_EXPLICITLY_SPECIFIED = + int ATTR_VALUE_EXPLICITLY_SPECIFIED_ID = 1; + /** Comparing 2 elements and one has an attribute the other does not */ + int ATTR_NAME_NOT_FOUND_ID = 2; + /** Comparing 2 attributes with the same name but different values */ + int ATTR_VALUE_ID = 3; + /** Comparing 2 attribute lists with the same attributes in different sequence */ + int ATTR_SEQUENCE_ID = 4; + /** Comparing 2 CDATA sections with different values */ + int CDATA_VALUE_ID = 5; + /** Comparing 2 comments with different values */ + int COMMENT_VALUE_ID = 6; + /** Comparing 2 document types with different names */ + int DOCTYPE_NAME_ID = 7; + /** Comparing 2 document types with different public identifiers */ + int DOCTYPE_PUBLIC_ID_ID = 8; + /** Comparing 2 document types with different system identifiers */ + int DOCTYPE_SYSTEM_ID_ID = 9; + /** Comparing 2 elements with different tag names */ + int ELEMENT_TAG_NAME_ID = 10; + /** Comparing 2 elements with different number of attributes */ + int ELEMENT_NUM_ATTRIBUTES_ID = 11; + /** Comparing 2 processing instructions with different targets */ + int PROCESSING_INSTRUCTION_TARGET_ID = 12; + /** Comparing 2 processing instructions with different instructions */ + int PROCESSING_INSTRUCTION_DATA_ID = 13; + /** Comparing 2 different text values */ + int TEXT_VALUE_ID = 14; + /** Comparing 2 nodes with different namespace prefixes */ + int NAMESPACE_PREFIX_ID = 15; + /** Comparing 2 nodes with different namespace URIs */ + int NAMESPACE_URI_ID = 16; + /** Comparing 2 nodes with different node types */ + int NODE_TYPE_ID = 17; + /** Comparing 2 nodes but only one has any children*/ + int HAS_CHILD_NODES_ID = 18; + /** Comparing 2 nodes with different numbers of children */ + int CHILD_NODELIST_LENGTH_ID = 19; + /** Comparing 2 nodes with children whose nodes are in different sequence*/ + int CHILD_NODELIST_SEQUENCE_ID = 20; + /** Comparing 2 Documents only one of which has a doctype */ + int HAS_DOCTYPE_DECLARATION_ID = 21; + + /** Comparing an implied attribute value against an explicit value */ + public static final Difference ATTR_VALUE_EXPLICITLY_SPECIFIED = new Difference(ATTR_VALUE_EXPLICITLY_SPECIFIED_ID, - "attribute value explicitly specified", true); + "attribute value explicitly specified", true); /** Comparing 2 elements and one has an attribute the other does not */ public static final Difference ATTR_NAME_NOT_FOUND = @@ -133,12 +133,12 @@ /** Comparing 2 processing instructions with different targets */ public static final Difference PROCESSING_INSTRUCTION_TARGET = new Difference(PROCESSING_INSTRUCTION_TARGET_ID, - "processing instruction target"); + "processing instruction target"); /** Comparing 2 processing instructions with different instructions */ public static final Difference PROCESSING_INSTRUCTION_DATA = new Difference(PROCESSING_INSTRUCTION_DATA_ID, - "processing instruction data"); + "processing instruction data"); /** Comparing 2 different text values */ public static final Difference TEXT_VALUE = @@ -167,10 +167,10 @@ /** Comparing 2 nodes with children whose nodes are in different sequence*/ public static final Difference CHILD_NODELIST_SEQUENCE = new Difference(CHILD_NODELIST_SEQUENCE_ID, - "sequence of child nodes", true); + "sequence of child nodes", true); /** Comparing 2 Documents only one of which has a doctype */ public static final Difference HAS_DOCTYPE_DECLARATION = new Difference(HAS_DOCTYPE_DECLARATION_ID, - "presence of doctype declaration", true); + "presence of doctype declaration", true); } \ No newline at end of file Modified: trunk/xmlunit/src/java/org/custommonkey/xmlunit/DifferenceEngine.java =================================================================== --- trunk/xmlunit/src/java/org/custommonkey/xmlunit/DifferenceEngine.java 2007-02-02 21:36:23 UTC (rev 146) +++ trunk/xmlunit/src/java/org/custommonkey/xmlunit/DifferenceEngine.java 2007-02-05 19:47:29 UTC (rev 147) @@ -77,9 +77,9 @@ * @see ComparisonController#haltComparison(Difference) */ public DifferenceEngine(ComparisonController controller) { - this.controller = controller; - this.controlTracker = new XpathNodeTracker(); - this.testTracker = new XpathNodeTracker(); + this.controller = controller; + this.controlTracker = new XpathNodeTracker(); + this.testTracker = new XpathNodeTracker(); } /** @@ -93,21 +93,21 @@ * in any sequence and that sequence is not considered important. */ public void compare(Node control, Node test, DifferenceListener listener, - ElementQualifier elementQualifier) { - controlTracker.reset(); - testTracker.reset(); + ElementQualifier elementQualifier) { + controlTracker.reset(); + testTracker.reset(); try { compare(getNullOrNotNull(control), getNullOrNotNull(test), - control, test, listener, NODE_TYPE); + control, test, listener, NODE_TYPE); if (control!=null) { compareNode(control, test, listener, elementQualifier); } } catch (DifferenceFoundException e) { // thrown by the protected compare() method to terminate the // comparison and unwind the call stack back to here - } + } } - + private String getNullOrNotNull(Node aNode) { return aNode==null ? NULL_NODE : NOT_NULL_NODE; } @@ -122,41 +122,41 @@ * @throws DifferenceFoundException */ protected void compareNode(Node control, Node test, - DifferenceListener listener, ElementQualifier elementQualifier) - throws DifferenceFoundException { + DifferenceListener listener, ElementQualifier elementQualifier) + throws DifferenceFoundException { boolean comparable = compareNodeBasics(control, test, listener); boolean isDocumentNode = false; - if (comparable) { - switch (control.getNodeType()) { - case Node.ELEMENT_NODE: - compareElement((Element)control, (Element)test, listener); - break; - case Node.CDATA_SECTION_NODE: - case Node.TEXT_NODE: - compareText((CharacterData) control, - (CharacterData) test, listener); - break; - case Node.COMMENT_NODE: - compareComment((Comment)control, (Comment)test, listener); - break; - case Node.DOCUMENT_TYPE_NODE: - compareDocumentType((DocumentType)control, - (DocumentType)test, listener); - break; - case Node.PROCESSING_INSTRUCTION_NODE: - compareProcessingInstruction((ProcessingInstruction)control, - (ProcessingInstruction)test, listener); - break; - case Node.DOCUMENT_NODE: - isDocumentNode = true; - compareDocument((Document)control, (Document) test, - listener, elementQualifier); - break; - default: - listener.skippedComparison(control, test); - } - } + if (comparable) { + switch (control.getNodeType()) { + case Node.ELEMENT_NODE: + compareElement((Element)control, (Element)test, listener); + break; + case Node.CDATA_SECTION_NODE: + case Node.TEXT_NODE: + compareText((CharacterData) control, + (CharacterData) test, listener); + break; + case Node.COMMENT_NODE: + compareComment((Comment)control, (Comment)test, listener); + break; + case Node.DOCUMENT_TYPE_NODE: + compareDocumentType((DocumentType)control, + (DocumentType)test, listener); + break; + case Node.PROCESSING_INSTRUCTION_NODE: + compareProcessingInstruction((ProcessingInstruction)control, + (ProcessingInstruction)test, listener); + break; + case Node.DOCUMENT_NODE: + isDocumentNode = true; + compareDocument((Document)control, (Document) test, + listener, elementQualifier); + break; + default: + listener.skippedComparison(control, test); + } + } compareHasChildNodes(control, test, listener); if (isDocumentNode) { @@ -166,8 +166,8 @@ compareNode(controlElement, testElement, listener, elementQualifier); } } else { - controlTracker.indent(); - testTracker.indent(); + controlTracker.indent(); + testTracker.indent(); compareNodeChildren(control, test, listener, elementQualifier); controlTracker.outdent(); testTracker.outdent(); @@ -183,14 +183,14 @@ * @throws DifferenceFoundException */ protected void compareDocument(Document control, Document test, - DifferenceListener listener, ElementQualifier elementQualifier) - throws DifferenceFoundException { + DifferenceListener listener, ElementQualifier elementQualifier) + throws DifferenceFoundException { DocumentType controlDoctype = control.getDoctype(); DocumentType testDoctype = test.getDoctype(); compare(getNullOrNotNull(controlDoctype), - getNullOrNotNull(testDoctype), - controlDoctype, testDoctype, listener, - HAS_DOCTYPE_DECLARATION); + getNullOrNotNull(testDoctype), + controlDoctype, testDoctype, listener, + HAS_DOCTYPE_DECLARATION); if (controlDoctype!=null && testDoctype!=null) { compareNode(controlDoctype, testDoctype, listener, elementQualifier); } @@ -206,7 +206,7 @@ * @throws DifferenceFoundException */ protected boolean compareNodeBasics(Node control, Node test, - DifferenceListener listener) throws DifferenceFoundException { + DifferenceListener listener) throws DifferenceFoundException { controlTracker.visited(control); testTracker.visited(test); @@ -220,9 +220,9 @@ NODE_TYPE); } compare(control.getNamespaceURI(), test.getNamespaceURI(), - control, test, listener, NAMESPACE_URI); + control, test, listener, NAMESPACE_URI); compare(control.getPrefix(), test.getPrefix(), - control, test, listener, NAMESPACE_PREFIX); + control, test, listener, NAMESPACE_PREFIX); return textAndCDATA || controlType.equals(testType); } @@ -245,13 +245,13 @@ * @throws DifferenceFoundException */ protected void compareHasChildNodes(Node control, Node test, - DifferenceListener listener) throws DifferenceFoundException { + DifferenceListener listener) throws DifferenceFoundException { Boolean controlHasChildren = control.hasChildNodes() ? Boolean.TRUE : Boolean.FALSE; Boolean testHasChildren = test.hasChildNodes() ? Boolean.TRUE : Boolean.FALSE; compare(controlHasChildren, testHasChildren, control, test, - listener, HAS_CHILD_NODES); + listener, HAS_CHILD_NODES); } /** @@ -264,8 +264,8 @@ * @throws DifferenceFoundException */ protected void compareNodeChildren(Node control, Node test, - DifferenceListener listener, ElementQualifier elementQualifier) - throws DifferenceFoundException { + DifferenceListener listener, ElementQualifier elementQualifier) + throws DifferenceFoundException { if (control.hasChildNodes() && test.hasChildNodes()) { NodeList controlChildren = control.getChildNodes(); NodeList testChildren = test.getChildNodes(); @@ -273,9 +273,9 @@ Integer controlLength = new Integer(controlChildren.getLength()); Integer testLength = new Integer(testChildren.getLength()); compare(controlLength, testLength, control, test, listener, - CHILD_NODELIST_LENGTH); + CHILD_NODELIST_LENGTH); compareNodeList(controlChildren, testChildren, - controlLength.intValue(), listener, elementQualifier); + controlLength.intValue(), listener, elementQualifier); } } @@ -397,80 +397,80 @@ * @throws DifferenceFoundException */ protected void compareElement(Element control, Element test, - DifferenceListener listener) throws DifferenceFoundException { - compare(getUnNamespacedNodeName(control), getUnNamespacedNodeName(test), - control, test, listener, ELEMENT_TAG_NAME); + DifferenceListener listener) throws DifferenceFoundException { + compare(getUnNamespacedNodeName(control), getUnNamespacedNodeName(test), + control, test, listener, ELEMENT_TAG_NAME); NamedNodeMap controlAttr = control.getAttributes(); - Integer controlNonXmlnsAttrLength = getNonXmlnsAttrLength(controlAttr); + Integer controlNonXmlnsAttrLength = getNonXmlnsAttrLength(controlAttr); NamedNodeMap testAttr = test.getAttributes(); Integer testNonXmlnsAttrLength = getNonXmlnsAttrLength(testAttr); compare(controlNonXmlnsAttrLength, testNonXmlnsAttrLength, - control, test, listener, ELEMENT_NUM_ATTRIBUTES); + control, test, listener, ELEMENT_NUM_ATTRIBUTES); compareElementAttributes(control, test, controlAttr, testAttr, - listener); + listener); } - private Integer getNonXmlnsAttrLength(NamedNodeMap attributes) { - int length = 0, maxLength = attributes.getLength(); - for (int i = 0; i < maxLength; ++i) { - if (!isXMLNSAttribute((Attr) attributes.item(i))) { - ++length; - } - } - return new Integer(length); - } + private Integer getNonXmlnsAttrLength(NamedNodeMap attributes) { + int length = 0, maxLength = attributes.getLength(); + for (int i = 0; i < maxLength; ++i) { + if (!isXMLNSAttribute((Attr) attributes.item(i))) { + ++length; + } + } + return new Integer(length); + } private void compareElementAttributes(Element control, Element test, - NamedNodeMap controlAttr, NamedNodeMap testAttr, - DifferenceListener listener) throws DifferenceFoundException { + NamedNodeMap controlAttr, NamedNodeMap testAttr, + DifferenceListener listener) throws DifferenceFoundException { for (int i=0; i < controlAttr.getLength(); ++i) { Attr nextAttr = (Attr) controlAttr.item(i); - if (isXMLNSAttribute(nextAttr)) { - // xml namespacing is handled in compareNodeBasics - } else { - boolean isNamespacedAttr = isNamespaced(nextAttr); - String attrName = getUnNamespacedNodeName(nextAttr, isNamespacedAttr); - Attr compareTo = null; - - if (isNamespacedAttr) { - compareTo = (Attr) testAttr.getNamedItemNS( - nextAttr.getNamespaceURI(), attrName); - } else { - compareTo = (Attr) testAttr.getNamedItem(attrName); - } - - if (compareTo != null) { - compareAttribute(nextAttr, compareTo, listener); - - Attr attributeItem = (Attr) testAttr.item(i); - String testAttrName = "[attribute absent]"; - if (attributeItem != null) { - testAttrName = getUnNamespacedNodeName(attributeItem); - } - compare(attrName, testAttrName, - nextAttr, compareTo, listener, ATTR_SEQUENCE); - } else { - compare(attrName, null, control, test, listener, - ATTR_NAME_NOT_FOUND); - } - } + if (isXMLNSAttribute(nextAttr)) { + // xml namespacing is handled in compareNodeBasics + } else { + boolean isNamespacedAttr = isNamespaced(nextAttr); + String attrName = getUnNamespacedNodeName(nextAttr, isNamespacedAttr); + Attr compareTo = null; + + if (isNamespacedAttr) { + compareTo = (Attr) testAttr.getNamedItemNS( + nextAttr.getNamespaceURI(), attrName); + } else { + compareTo = (Attr) testAttr.getNamedItem(attrName); + } + + if (compareTo != null) { + compareAttribute(nextAttr, compareTo, listener); + + Attr attributeItem = (Attr) testAttr.item(i); + String testAttrName = "[attribute absent]"; + if (attributeItem != null) { + testAttrName = getUnNamespacedNodeName(attributeItem); + } + compare(attrName, testAttrName, + nextAttr, compareTo, listener, ATTR_SEQUENCE); + } else { + compare(attrName, null, control, test, listener, + ATTR_NAME_NOT_FOUND); + } + } } controlTracker.clearTrackedAttribute(); testTracker.clearTrackedAttribute(); } private String getUnNamespacedNodeName(Node aNode) { - return getUnNamespacedNodeName(aNode, isNamespaced(aNode)); + return getUnNamespacedNodeName(aNode, isNamespaced(aNode)); } - private String getUnNamespacedNodeName(Node aNode, boolean isNamespacedNode) { - if (isNamespacedNode) { - return aNode.getLocalName(); - } - return aNode.getNodeName(); - } + private String getUnNamespacedNodeName(Node aNode, boolean isNamespacedNode) { + if (isNamespacedNode) { + return aNode.getLocalName(); + } + return aNode.getNodeName(); + } /** @@ -490,19 +490,19 @@ * @throws DifferenceFoundException */ protected void compareAttribute(Attr control, Attr test, - DifferenceListener listener) throws DifferenceFoundException { - controlTracker.visited(control); - testTracker.visited(test); - - compare(control.getPrefix(), test.getPrefix(), control, test, - listener, NAMESPACE_PREFIX); - + DifferenceListener listener) throws DifferenceFoundException { + controlTracker.visited(control); + testTracker.visited(test); + + compare(control.getPrefix(), test.getPrefix(), control, test, + listener, NAMESPACE_PREFIX); + compare(control.getValue(), test.getValue(), control, test, - listener, ATTR_VALUE); + listener, ATTR_VALUE); compare(control.getSpecified() ? Boolean.TRUE : Boolean.FALSE, - test.getSpecified() ? Boolean.TRUE : Boolean.FALSE, - control, test, listener, ATTR_VALUE_EXPLICITLY_SPECIFIED); + test.getSpecified() ? Boolean.TRUE : Boolean.FALSE, + control, test, listener, ATTR_VALUE_EXPLICITLY_SPECIFIED); } /** @@ -513,7 +513,7 @@ * @throws DifferenceFoundException */ protected void compareCDataSection(CDATASection control, CDATASection test, - DifferenceListener listener) throws DifferenceFoundException { + DifferenceListener listener) throws DifferenceFoundException { compareText(control, test, listener); } @@ -525,7 +525,7 @@ * @throws DifferenceFoundException */ protected void compareComment(Comment control, Comment test, - DifferenceListener listener) throws DifferenceFoundException { + DifferenceListener listener) throws DifferenceFoundException { compareCharacterData(control, test, listener, COMMENT_VALUE); } @@ -537,14 +537,14 @@ * @throws DifferenceFoundException */ protected void compareDocumentType(DocumentType control, DocumentType test, - DifferenceListener listener) throws DifferenceFoundException { + DifferenceListener listener) throws DifferenceFoundException { compare(control.getName(), test.getName(), control, test, listener, - DOCTYPE_NAME); + DOCTYPE_NAME); compare(control.getPublicId(), test.getPublicId(), control, test, listener, - DOCTYPE_PUBLIC_ID); + DOCTYPE_PUBLIC_ID); compare(control.getSystemId(), test.getSystemId(), - control, test, listener, DOCTYPE_SYSTEM_ID); + control, test, listener, DOCTYPE_SYSTEM_ID); } /** @@ -555,12 +555,12 @@ * @throws DifferenceFoundException */ protected void compareProcessingInstruction(ProcessingInstruction control, - ProcessingInstruction test, DifferenceListener listener) - throws DifferenceFoundException { + ProcessingInstruction test, DifferenceListener listener) + throws DifferenceFoundException { compare(control.getTarget(), test.getTarget(), control, test, listener, - PROCESSING_INSTRUCTION_TARGET); + PROCESSING_INSTRUCTION_TARGET); compare(control.getData(), test.getData(), control, test, listener, - PROCESSING_INSTRUCTION_DATA); + PROCESSING_INSTRUCTION_DATA); } /** @@ -599,10 +599,10 @@ * @throws DifferenceFoundException */ private void compareCharacterData(CharacterData control, CharacterData test, - DifferenceListener listener, Difference difference) - throws DifferenceFoundException { + DifferenceListener listener, Difference difference) + throws DifferenceFoundException { compare(control.getData(), test.getData(), control, test, listener, - difference); + difference); } /** @@ -617,15 +617,15 @@ * @throws DifferenceFoundException */ protected void compare(Object expected, Object actual, - Node control, Node test, DifferenceListener listener, Difference difference) - throws DifferenceFoundException { + Node control, Node test, DifferenceListener listener, Difference difference) + throws DifferenceFoundException { if (unequal(expected, actual)) { - NodeDetail controlDetail = new NodeDetail(String.valueOf(expected), - control, controlTracker.toXpathString()); - NodeDetail testDetail = new NodeDetail(String.valueOf(actual), - test, testTracker.toXpathString()); - Difference differenceInstance = new Difference(difference, - controlDetail, testDetail); + NodeDetail controlDetail = new NodeDetail(String.valueOf(expected), + control, controlTracker.toXpathString()); + NodeDetail testDetail = new NodeDetail(String.valueOf(actual), + test, testTracker.toXpathString()); + Difference differenceInstance = new Difference(difference, + controlDetail, testDetail); listener.differenceFound(differenceInstance); if (controller.haltComparison(differenceInstance)) { throw flowControlException; Modified: trunk/xmlunit/src/java/org/custommonkey/xmlunit/DoctypeReader.java =================================================================== --- trunk/xmlunit/src/java/org/custommonkey/xmlunit/DoctypeReader.java 2007-02-02 21:36:23 UTC (rev 146) +++ trunk/xmlunit/src/java/org/custommonkey/xmlunit/DoctypeReader.java 2007-02-05 19:47:29 UTC (rev 147) @@ -72,7 +72,7 @@ * @param systemID */ public DoctypeReader(Reader originalSource, String doctypeName, - String systemID) { + String systemID) { this.originalSource = originalSource; this.doctypeName = doctypeName; this.systemId = systemID; @@ -132,13 +132,13 @@ curChar = withinContent.charAt(i); if (curChar == '<') { switch (withinContent.charAt(i + 1)) { - case '?': - case '!': - case '-': - canInsert = false; - break; - default: - startAt = i; + case '?': + case '!': + case '-': + canInsert = false; + break; + default: + startAt = i; } } else if (curChar == '>') { canInsert = true; @@ -157,7 +157,7 @@ * @return the content, after DOCTYPE amendment / addition */ public String replaceDoctype(StringBuffer withinContent, - String doctypeName, String systemId) { + String doctypeName, String systemId) { String content = withinContent.toString(); int startDoctype = content.indexOf(DOCTYPE); boolean noCurrentDoctype = false; @@ -206,7 +206,7 @@ private Reader getReplacementReader() throws IOException { StringBuffer originalContent = getContent(originalSource); String replacedContent = replaceDoctype(originalContent, - doctypeName, systemId); + doctypeName, systemId); return new StringReader(replacedContent); } Modified: trunk/xmlunit/src/java/org/custommonkey/xmlunit/ElementNameAndAttributeQualifier.java =================================================================== --- trunk/xmlunit/src/java/org/custommonkey/xmlunit/ElementNameAndAttributeQualifier.java 2007-02-02 21:36:23 UTC (rev 146) +++ trunk/xmlunit/src/java/org/custommonkey/xmlunit/ElementNameAndAttributeQualifier.java 2007-02-05 19:47:29 UTC (rev 147) @@ -7,16 +7,16 @@ modification, are permitted provided that the following conditions are met: - * Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above - copyright notice, this list of conditions and the following - disclaimer in the documentation and/or other materials provided - with the distribution. - * Neither the name of the xmlunit.sourceforge.net nor the names - of its contributors may be used to endorse or promote products - derived from this software without specific prior written - permission. + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above + copyright notice, this list of conditions and the following + disclaimer in the documentation and/or other materials provided + with the distribution. + * Neither the name of the xmlunit.sourceforge.net nor the names + of its contributors may be used to endorse or promote products + derived from this software without specific prior written + permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT @@ -49,105 +49,105 @@ * @see Diff#overrideElementQualifier(ElementQualifier) */ public class ElementNameAndAttributeQualifier extends ElementNameQualifier { - public static final String[] ALL_ATTRIBUTES = {"*"}; - - private final String[] qualifyingAttrNames; - - /** - * No-args constructor: use all attributes from all elements to determine - * whether elements qualify for comparability - */ - public ElementNameAndAttributeQualifier() { - this(ALL_ATTRIBUTES); - } - - /** - * Simple constructor for a single qualifying attribute name - * @param attrName the value to use to qualify whether two elements can be - * compared further for differences - */ - public ElementNameAndAttributeQualifier(String attrName) { - this(new String[] {attrName}); - } + public static final String[] ALL_ATTRIBUTES = {"*"}; + + private final String[] qualifyingAttrNames; + + /** + * No-args constructor: use all attributes from all elements to determine + * whether elements qualify for comparability + */ + public ElementNameAndAttributeQualifier() { + this(ALL_ATTRIBUTES); + } + + /** + * Simple constructor for a single qualifying attribute name + * @param attrName the value to use to qualify whether two elements can be + * compared further for differences + */ + public ElementNameAndAttributeQualifier(String attrName) { + this(new String[] {attrName}); + } - /** - * Extended constructor for multiple qualifying attribute names - * @param attrNames the array of values to use to qualify whether two - * elements can be compared further for differences - */ - public ElementNameAndAttributeQualifier(String[] attrNames) { - this.qualifyingAttrNames = attrNames; - } + /** + * Extended constructor for multiple qualifying attribute names + * @param attrNames the array of values to use to qualify whether two + * elements can be compared further for differences + */ + public ElementNameAndAttributeQualifier(String[] attrNames) { + this.qualifyingAttrNames = attrNames; + } - /** - * Determine whether two elements qualify for further Difference comparison. - * @param differenceEngine the DifferenceEngine instance wanting to - * determine if the elements are comparable - * @param control - * @param test - * @return true if the two elements qualify for further comparison based on - * both the superclass qualification (namespace URI and non- namespaced tag - * name), and the presence of qualifying attributes with the same values; - * false otherwise - */ - public boolean qualifyForComparison(Element control, Element test) { - if (super.qualifyForComparison(control, test)) { - return areAttributesComparable(control, test); - } - return false; - } - - /** - * Determine whether the qualifying attributes are present in both elements - * and if so whether their values are the same - * @param control - * @param test - * @return true if all qualifying attributes are present with the same - * values, false otherwise - */ - protected boolean areAttributesComparable(Element control, Element test) { - String controlValue, testValue; - Attr[] qualifyingAttributes; - NamedNodeMap namedNodeMap = control.getAttributes(); - if (qualifyingAttrNames == ALL_ATTRIBUTES) { - qualifyingAttributes = new Attr[namedNodeMap.getLength()]; - for (int n=0; n < qualifyingAttributes.length; ++n) { - qualifyingAttributes[n] = (Attr) namedNodeMap.item(n); - } - } else { - qualifyingAttributes = new Attr[qualifyingAttrNames.length]; - for (int n=0; n < qualifyingAttrNames.length; ++n) { - qualifyingAttributes[n] = (Attr) namedNodeMap.getNamedItem(qualifyingAttrNames[n]); - } - } - - String nsURI, name; - for (int i=0; i < qualifyingAttributes.length; ++i) { - if (qualifyingAttributes[i] != null) { - nsURI = qualifyingAttributes[i].getNamespaceURI(); - controlValue = qualifyingAttributes[i].getNodeValue(); - name = qualifyingAttributes[i].getName(); - } else { - // cannot be "*" case - nsURI = controlValue = ""; - name = qualifyingAttrNames[i]; - } - if (nsURI == null || nsURI.length() == 0) { - testValue = test.getAttribute(name); - } else { - testValue = test.getAttributeNS(nsURI, qualifyingAttributes[i].getLocalName()); - } - if (controlValue == null) { - if (testValue != null) { - return false; - } - } else { - if (!controlValue.equals(testValue)) { - return false; - } - } - } - return true; - } + /** + * Determine whether two elements qualify for further Difference comparison. + * @param differenceEngine the DifferenceEngine instance wanting to + * determine if the elements are comparable + * @param control + * @param test + * @return true if the two elements qualify for further comparison based on + * both the superclass qualification (namespace URI and non- namespaced tag + * name), and the presence of qualifying attributes with the same values; + * false otherwise + */ + public boolean qualifyForComparison(Element control, Element test) { + if (super.qualifyForComparison(control, test)) { + return areAttributesComparable(control, test); + } + return false; + } + + /** + * Determine whether the qualifying attributes are present in both elements + * and if so whether their values are the same + * @param control + * @param test + * @return true if all qualifying attributes are present with the same + * values, false otherwise + */ + protected boolean areAttributesComparable(Element control, Element test) { + String controlValue, testValue; + Attr[] qualifyingAttributes; + NamedNodeMap namedNodeMap = control.getAttributes(); + if (qualifyingAttrNames == ALL_ATTRIBUTES) { + qualifyingAttributes = new Attr[namedNodeMap.getLength()]; + for (int n=0; n < qualifyingAttributes.length; ++n) { + qualifyingAttributes[n] = (Attr) namedNodeMap.item(n); + } + } else { + qualifyingAttributes = new Attr[qualifyingAttrNames.length]; + for (int n=0; n < qualifyingAttrNames.length; ++n) { + qualifyingAttributes[n] = (Attr) namedNodeMap.getNamedItem(qualifyingAttrNames[n]); + } + } + + String nsURI, name; + for (int i=0; i < qualifyingAttributes.length; ++i) { + if (qualifyingAttributes[i] != null) { + nsURI = qualifyingAttributes[i].getNamespaceURI(); + controlValue = qualifyingAttributes[i].getNodeValue(); + name = qualifyingAttributes[i].getName(); + } else { + // cannot be "*" case + nsURI = controlValue = ""; + name = qualifyingAttrNames[i]; + } + if (nsURI == null || nsURI.length() == 0) { + testValue = test.getAttribute(name); + } else { + testValue = test.getAttributeNS(nsURI, qualifyingAttributes[i].getLocalName()); + } + if (controlValue == null) { + if (testValue != null) { + return false; + } + } else { + if (!controlValue.equals(testValue)) { + return false; + } + } + } + return true; + } } Modified: trunk/xmlunit/src/java/org/custommonkey/xmlunit/ElementNameAndTextQualifier.java =================================================================== --- trunk/xmlunit/src/java/org/custommonkey/xmlunit/ElementNameAndTextQualifier.java 2007-02-02 21:36:23 UTC (rev 146) +++ trunk/xmlunit/src/java/org/custommonkey/xmlunit/ElementNameAndTextQualifier.java 2007-02-05 19:47:29 UTC (rev 147) @@ -7,16 +7,16 @@ modification, are permitted provided that the following conditions are met: - * Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above - copyright notice, this list of conditions and the following - disclaimer in the documentation and/or other materials provided - with the distribution. - * Neither the name of the xmlunit.sourceforge.net nor the names - of its contributors may be used to endorse or promote products - derived from this software without specific prior written - permission. + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above + copyright notice, this list of conditions and the following + disclaimer in the documentation and/or other materials provided + with the distribution. + * Neither the name of the xmlunit.sourceforge.net nor the names + of its contributors may be used to endorse or promote products + derived from this software without specific prior written + permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT @@ -50,53 +50,53 @@ * @see Diff#overrideElementQualifier(ElementQualifier) */ public class ElementNameAndTextQualifier extends ElementNameQualifier { - /** - * Determine whether two elements qualify for further Difference comparison. - * @param control - * @param test - * @return true if the two elements qualify for further comparison based on - * both the superclass qualification (namespace URI and non- namespaced tag - * name), and the qualification of the text nodes contained within the - * elements; false otherwise - */ - public bo... [truncated message content] |