From: <bo...@us...> - 2013-02-03 08:35:18
|
Revision: 504 http://xmlunit.svn.sourceforge.net/xmlunit/?rev=504&view=rev Author: bodewig Date: 2013-02-03 08:35:12 +0000 (Sun, 03 Feb 2013) Log Message: ----------- Actually, the NS lookup method is not needed when DOM3 is there Modified Paths: -------------- trunk/xmlunit/src/main/java-core/net/sf/xmlunit/diff/DOMDifferenceEngine.java trunk/xmlunit/src/main/java-core/net/sf/xmlunit/util/Nodes.java Modified: trunk/xmlunit/src/main/java-core/net/sf/xmlunit/diff/DOMDifferenceEngine.java =================================================================== --- trunk/xmlunit/src/main/java-core/net/sf/xmlunit/diff/DOMDifferenceEngine.java 2013-02-03 06:37:37 UTC (rev 503) +++ trunk/xmlunit/src/main/java-core/net/sf/xmlunit/diff/DOMDifferenceEngine.java 2013-02-03 08:35:12 UTC (rev 504) @@ -667,15 +667,17 @@ private static QName valueAsQName(Attr attribute) { String[] pieces = attribute.getValue().split(":"); if (pieces.length < 2) { - pieces = new String[] { "", pieces[0] }; + pieces = new String[] { null, pieces[0] }; } else if (pieces.length > 2) { pieces = new String[] { pieces[0], attribute.getValue().substring(pieces[0].length() + 1) }; } - return new QName(Nodes.findNamespaceURIForPrefix(attribute, pieces[0]), - pieces[1], pieces[0]); + if ("".equals(pieces[0])) { + pieces[0] = null; + } + return new QName(attribute.lookupNamespaceURI(pieces[0]), pieces[1]); } private static class Attributes { Modified: trunk/xmlunit/src/main/java-core/net/sf/xmlunit/util/Nodes.java =================================================================== --- trunk/xmlunit/src/main/java-core/net/sf/xmlunit/util/Nodes.java 2013-02-03 06:37:37 UTC (rev 503) +++ trunk/xmlunit/src/main/java-core/net/sf/xmlunit/util/Nodes.java 2013-02-03 08:35:12 UTC (rev 504) @@ -113,35 +113,6 @@ } /** - * Looks up the namespace URI associated with a given prefix on a given node. - * @param onNode the reference node - * @param prefix the prefix to look for - * @return the URI or null of it cannot be found - */ - public static String findNamespaceURIForPrefix(Node onNode, String prefix) { - if (onNode != null && onNode instanceof Attr) { - onNode = ((Attr) onNode).getOwnerElement(); - } - while (onNode != null && onNode.getNodeType() != Node.ELEMENT_NODE) { - onNode = onNode.getParentNode(); - } - if (onNode == null) { - return null; - } - - if (prefix == null || "".equals(prefix)) { - prefix = XMLConstants.XMLNS_ATTRIBUTE; - } - Map<QName, String> attrs = getAttributes(onNode); - String uri = attrs.get(new QName(XMLConstants.XMLNS_ATTRIBUTE_NS_URI, - prefix)); - if (uri != null) { - return uri; - } - return findNamespaceURIForPrefix(onNode.getParentNode(), prefix); - } - - /** * Trims textual content of this node, removes empty text and * CDATA children, recurses into its child nodes. * @param normalize whether to normalize whitespace as well This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |