Author: veithen Date: Wed Mar 18 23:47:23 2009 New Revision: 755788 URL: http://svn.apache.org/viewvc?rev=755788&view=rev Log: According to the StAX specs, the requirements for the getPrefix and getNamespacePrefix methods in XMLStreamReader are:
getPrefix: "Returns the prefix of the current event or null if the event does not have a prefix" getNamespacePrefix: "Returns the prefix for the namespace declared at the index. Returns null if this is the default namespace declaration" Fixed the implementations of these methods in OMStAXWrapper to return the correct value in the default namespace case (taking into account that in this case Axiom uses the empty string for the prefix). Modified: webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/impl/OMStAXWrapper.java webservices/commons/trunk/modules/axiom/modules/axiom-api/src/test/java/org/apache/axiom/om/impl/XMLStreamReaderComparator.java Modified: webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/impl/OMStAXWrapper.java URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/impl/OMStAXWrapper.java?rev=755788&r1=755787&r2=755788&view=diff ============================================================================== --- webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/impl/OMStAXWrapper.java (original) +++ webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/impl/OMStAXWrapper.java Wed Mar 18 23:47:23 2009 @@ -255,7 +255,12 @@ if ((currentEvent == START_ELEMENT) || (currentEvent == END_ELEMENT)) { OMNamespace ns = ((OMElement) getNode()).getNamespace(); - return (ns == null) ? null : ns.getPrefix(); + if (ns == null) { + return null; + } else { + String prefix = ns.getPrefix(); + return prefix == null || prefix.length() == 0 ? null : prefix; + } } else { throw new IllegalStateException(); } @@ -495,7 +500,10 @@ || (currentEvent == NAMESPACE)) { OMNamespace ns = (OMNamespace) getItemFromIterator( ((OMElement) getNode()).getAllDeclaredNamespaces(), i); - returnString = (ns == null) ? null : ns.getPrefix(); + if (ns != null) { + String prefix = ns.getPrefix(); + returnString = prefix == null || prefix.length() == 0 ? null : prefix; + } } } return returnString; Modified: webservices/commons/trunk/modules/axiom/modules/axiom-api/src/test/java/org/apache/axiom/om/impl/XMLStreamReaderComparator.java URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-api/src/test/java/org/apache/axiom/om/impl/XMLStreamReaderComparator.java?rev=755788&r1=755787&r2=755788&view=diff ============================================================================== --- webservices/commons/trunk/modules/axiom/modules/axiom-api/src/test/java/org/apache/axiom/om/impl/XMLStreamReaderComparator.java (original) +++ webservices/commons/trunk/modules/axiom/modules/axiom-api/src/test/java/org/apache/axiom/om/impl/XMLStreamReaderComparator.java Wed Mar 18 23:47:23 2009 @@ -139,12 +139,12 @@ actualNamespaces.put(actual.getNamespacePrefix(i), actual.getNamespaceURI(i)); } -// assertEquals(expectedNamespaces, actualNamespaces); + assertEquals(expectedNamespaces, actualNamespaces); } assertSameResult("getNamespaceURI", null); assertSameResult("getPIData", null); assertSameResult("getPITarget", null); -// assertSameResult("getPrefix", null); + assertSameResult("getPrefix", null); assertSameResult("getText", null); assertSameResult("getTextLength", null); assertSameResult("hasName", null);