Author: veithen
Date: Thu Apr  9 22:30:04 2009
New Revision: 763831

URL: http://svn.apache.org/viewvc?rev=763831&view=rev
Log:
Fixed two issues in StAXOMBuilder#processNamespaceData:
* The code didn't take into account that the result of 
OMElement#findNamespace(String, String) is undefined if both arguments are non 
null. The right approach is to search by prefix and than compare the namespace 
URIs (because a prefix can be bound to at most one namespace URI, but a 
namespace URI can be bound to multiple prefixes).
* When comparing prefixes, the code didn't take into account that 
XMLStreamReader#getPrefix() returns null if there is no prefix, while Axiom 
uses an empty string in this case. This caused the code to add a namespace 
declaration to every element without prefix, event if a corresponding namespace 
declaration is already in scope.

Added:
    
webservices/commons/trunk/modules/axiom/modules/axiom-api/src/test/resources/conformance/AXIS2-565.xml
   (with props)
    
webservices/commons/trunk/modules/axiom/modules/axiom-api/src/test/resources/conformance/namespaces2.xml
   (with props)
Modified:
    
webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/impl/builder/StAXOMBuilder.java

Modified: 
webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/impl/builder/StAXOMBuilder.java
URL: 
http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/impl/builder/StAXOMBuilder.java?rev=763831&r1=763830&r2=763831&view=diff
==============================================================================
--- 
webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/impl/builder/StAXOMBuilder.java
 (original)
+++ 
webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/impl/builder/StAXOMBuilder.java
 Thu Apr  9 22:30:04 2009
@@ -534,8 +534,8 @@
         }
 
         if (namespaceURI != null && namespaceURI.length() > 0) {
-            OMNamespace namespace = node.findNamespace(namespaceURI, prefix);
-            if (namespace == null || (!namespace.getPrefix().equals(prefix))) {
+            OMNamespace namespace = node.findNamespaceURI(prefix == null ? "" 
: prefix);
+            if (namespace == null || 
!namespace.getNamespaceURI().equals(namespaceURI)) {
                 // See NOTE_A above
                 if (isNamespaceURIInterning()) {
                     namespaceURI = namespaceURI.intern();

Added: 
webservices/commons/trunk/modules/axiom/modules/axiom-api/src/test/resources/conformance/AXIS2-565.xml
URL: 
http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-api/src/test/resources/conformance/AXIS2-565.xml?rev=763831&view=auto
==============================================================================
--- 
webservices/commons/trunk/modules/axiom/modules/axiom-api/src/test/resources/conformance/AXIS2-565.xml
 (added)
+++ 
webservices/commons/trunk/modules/axiom/modules/axiom-api/src/test/resources/conformance/AXIS2-565.xml
 Thu Apr  9 22:30:04 2009
@@ -0,0 +1,20 @@
+<?xml version="1.0"?>
+<root>
+    <node>Some text</node>
+    <node>More test</node>
+    <items>
+        <item shape="rectangle" xmlns:col="urn:mycolor">
+            <col:color rgb="#FF0000">red</col:color>
+            <name>My fine <b>item</b></name>
+        </item>
+        <item shape="circle" xmlns:col="urn:mycolor">
+            <col:color rgb="#0000FF">blue</col:color>
+            <name>Something else</name>
+        </item>
+    </items>
+    <shapes>
+        <shape>rectangle</shape>
+        <shape>circle</shape>
+        <shape basedOn="rectangle">square</shape>
+    </shapes>
+</root>
\ No newline at end of file

Propchange: 
webservices/commons/trunk/modules/axiom/modules/axiom-api/src/test/resources/conformance/AXIS2-565.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Added: 
webservices/commons/trunk/modules/axiom/modules/axiom-api/src/test/resources/conformance/namespaces2.xml
URL: 
http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-api/src/test/resources/conformance/namespaces2.xml?rev=763831&view=auto
==============================================================================
--- 
webservices/commons/trunk/modules/axiom/modules/axiom-api/src/test/resources/conformance/namespaces2.xml
 (added)
+++ 
webservices/commons/trunk/modules/axiom/modules/axiom-api/src/test/resources/conformance/namespaces2.xml
 Thu Apr  9 22:30:04 2009
@@ -0,0 +1,2 @@
+<?xml version="1.0"?>
+<a xmlns="urn:ns"><b/></a>
\ No newline at end of file

Propchange: 
webservices/commons/trunk/modules/axiom/modules/axiom-api/src/test/resources/conformance/namespaces2.xml
------------------------------------------------------------------------------
    svn:eol-style = native


Reply via email to