axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aj...@apache.org
Subject svn commit: r331877 - in /webservices/axis2/trunk/java/modules/xml/src/org/apache/axis2: om/impl/llom/OMSerializerUtil.java om/impl/llom/builder/StAXOMBuilder.java soap/impl/llom/builder/StAXSOAPModelBuilder.java
Date Tue, 08 Nov 2005 20:19:59 GMT
Author: ajith
Date: Tue Nov  8 12:19:56 2005
New Revision: 331877

URL: http://svn.apache.org/viewcvs?rev=331877&view=rev
Log:
1.Did a change to fix the NS prob. The change is still not complete

Modified:
    webservices/axis2/trunk/java/modules/xml/src/org/apache/axis2/om/impl/llom/OMSerializerUtil.java
    webservices/axis2/trunk/java/modules/xml/src/org/apache/axis2/om/impl/llom/builder/StAXOMBuilder.java
    webservices/axis2/trunk/java/modules/xml/src/org/apache/axis2/soap/impl/llom/builder/StAXSOAPModelBuilder.java

Modified: webservices/axis2/trunk/java/modules/xml/src/org/apache/axis2/om/impl/llom/OMSerializerUtil.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/xml/src/org/apache/axis2/om/impl/llom/OMSerializerUtil.java?rev=331877&r1=331876&r2=331877&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/xml/src/org/apache/axis2/om/impl/llom/OMSerializerUtil.java
(original)
+++ webservices/axis2/trunk/java/modules/xml/src/org/apache/axis2/om/impl/llom/OMSerializerUtil.java
Tue Nov  8 12:19:56 2005
@@ -118,8 +118,9 @@
                     writer.writeStartElement(nameSpaceName,
                             element.getLocalName());
                 } else {
-                    if (prefix == null) {
-                        prefix = "ns"+ ++namespaceCounter;
+                    //todo - Need to verify whether this'll cause a problem!
+                    if (prefix == null || "".equals(prefix)) {
+                        prefix = "nsss"+ ++namespaceCounter;
                     }
                     writer.writeStartElement(prefix, element.getLocalName(),
                             nameSpaceName);
@@ -136,8 +137,8 @@
             // a namespace, we deliberately associate it with the empty namespace
             // If the OMElement is associated with a namespace, even by inheritance
             // then it shouldn't be here!!!!. kind of ugly but perfectly legal
-            //and gets the thing done!
-            writer.writeDefaultNamespace("");
+            // and gets the thing done!
+            // writer.writeDefaultNamespace("");
             /////////////////////////////////////////////////////
         }
 

Modified: webservices/axis2/trunk/java/modules/xml/src/org/apache/axis2/om/impl/llom/builder/StAXOMBuilder.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/xml/src/org/apache/axis2/om/impl/llom/builder/StAXOMBuilder.java?rev=331877&r1=331876&r2=331877&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/xml/src/org/apache/axis2/om/impl/llom/builder/StAXOMBuilder.java
(original)
+++ webservices/axis2/trunk/java/modules/xml/src/org/apache/axis2/om/impl/llom/builder/StAXOMBuilder.java
Tue Nov  8 12:19:56 2005
@@ -46,6 +46,7 @@
      */
 
     private boolean doDebug = false;
+    private static int nsCount = 0;
 
     /**
      * Constructor StAXOMBuilder
@@ -296,21 +297,17 @@
      * @param isSOAPElement
      */
     protected void processNamespaceData(OMElement node, boolean isSOAPElement) {
-        int namespaceCount = parser.getNamespaceCount();
-        for (int i = 0; i < namespaceCount; i++) {
-            node.declareNamespace(parser.getNamespaceURI(i),
-                    parser.getNamespacePrefix(i));
-        }
         // set the own namespace
         String namespaceURI = parser.getNamespaceURI();
         String prefix = parser.getPrefix();
+
         OMNamespace namespace = null;
         if (namespaceURI != null && namespaceURI.length() > 0) {
             if (prefix == null) {
                 // this means, this elements has a default namespace or it has inherited
a default namespace from its parent
                 namespace = node.findNamespace(namespaceURI, "");
                 if (namespace == null) {
-                    namespace = node.declareNamespace(namespaceURI, "");
+                    namespace = node.declareNamespace(namespaceURI, createPrefix());
                 }
                 if (node.getNamespace() == null) {
                     node.setNamespace(namespace);
@@ -324,6 +321,16 @@
                     node.setNamespace(namespace);
                 }
             }
+
+
+        }
+
+        int namespaceCount = parser.getNamespaceCount();
+        for (int i = 0; i < namespaceCount; i++) {
+            if (!parser.getNamespaceURI(i).equals(namespaceURI)){
+            node.declareNamespace(parser.getNamespaceURI(i),
+                    parser.getNamespacePrefix(i));
+            }
         }
     }
 
@@ -332,4 +339,9 @@
     public void setDoDebug(boolean doDebug) {
         this.doDebug = doDebug;
     }
+
+    protected String createPrefix(){
+        return "ns"+ nsCount++;
+    }
+
 }

Modified: webservices/axis2/trunk/java/modules/xml/src/org/apache/axis2/soap/impl/llom/builder/StAXSOAPModelBuilder.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/xml/src/org/apache/axis2/soap/impl/llom/builder/StAXSOAPModelBuilder.java?rev=331877&r1=331876&r2=331877&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/xml/src/org/apache/axis2/soap/impl/llom/builder/StAXSOAPModelBuilder.java
(original)
+++ webservices/axis2/trunk/java/modules/xml/src/org/apache/axis2/soap/impl/llom/builder/StAXSOAPModelBuilder.java
Tue Nov  8 12:19:56 2005
@@ -186,7 +186,7 @@
      * @throws OMException
      */
     protected OMNode createOMElement() throws OMException {
-    	elementLevel++;
+        elementLevel++;
         OMElement node;
         String elementName = parser.getLocalName();
         if (lastNode == null) {
@@ -318,28 +318,28 @@
 
     private String getSenderFaultCode() {
         if(senderfaultCode == null){
-           senderfaultCode = SOAP12Constants.SOAP_ENVELOPE_NAMESPACE_URI.equals(envelopeNamespace.getName())
? SOAP12Constants.FAULT_CODE_SENDER : SOAP11Constants.FAULT_CODE_SENDER;
+            senderfaultCode = SOAP12Constants.SOAP_ENVELOPE_NAMESPACE_URI.equals(envelopeNamespace.getName())
? SOAP12Constants.FAULT_CODE_SENDER : SOAP11Constants.FAULT_CODE_SENDER;
         }
         return senderfaultCode;
     }
 
     private String getReceiverFaultCode() {
         if(receiverfaultCode == null){
-           receiverfaultCode = SOAP12Constants.SOAP_ENVELOPE_NAMESPACE_URI.equals(envelopeNamespace.getName())
? SOAP12Constants.FAULT_CODE_RECEIVER : SOAP11Constants.FAULT_CODE_RECEIVER;
+            receiverfaultCode = SOAP12Constants.SOAP_ENVELOPE_NAMESPACE_URI.equals(envelopeNamespace.getName())
? SOAP12Constants.FAULT_CODE_RECEIVER : SOAP11Constants.FAULT_CODE_RECEIVER;
         }
         return receiverfaultCode;
     }
 
     public void endElement(){
-    	 if (lastNode.isComplete()) {
-             OMElement parent = (OMElement) lastNode.getParent();
-             ((OMNodeEx)parent).setComplete(true);
-             lastNode = parent;
-         } else {
-             OMNode e = lastNode;
-             ((OMNodeEx)e).setComplete(true);
-         }
-         elementLevel--;
+        if (lastNode.isComplete()) {
+            OMElement parent = (OMElement) lastNode.getParent();
+            ((OMNodeEx)parent).setComplete(true);
+            lastNode = parent;
+        } else {
+            OMNode e = lastNode;
+            ((OMNodeEx)e).setComplete(true);
+        }
+        elementLevel--;
     }
 
     /**
@@ -349,7 +349,7 @@
      *  should not have a DTD
      */
     protected OMNode createDTD() throws OMException {
-    	throw new OMException("SOAP message MUST NOT contain a Document Type Declaration(DTD)");
+        throw new OMException("SOAP message MUST NOT contain a Document Type Declaration(DTD)");
     }
 
     /**
@@ -359,7 +359,7 @@
      * should not have a PI
      */
     protected OMNode createPI() throws OMException {
-    	throw new OMException("SOAP message MUST NOT contain Processing Instructions(PI)");
+        throw new OMException("SOAP message MUST NOT contain Processing Instructions(PI)");
     }
 
     /**
@@ -378,11 +378,6 @@
      * @param isSOAPElement
      */
     protected void processNamespaceData(OMElement node, boolean isSOAPElement) {
-        int namespaceCount = parser.getNamespaceCount();
-        for (int i = 0; i < namespaceCount; i++) {
-            node.declareNamespace(parser.getNamespaceURI(i),
-                    parser.getNamespacePrefix(i));
-        }
 
         // set the owner namespace
         String namespaceURI = parser.getNamespaceURI();
@@ -393,12 +388,20 @@
                 // this means, this elements has a default namespace or it has inherited
a default namespace from its parent
                 namespace = node.findNamespace(namespaceURI, "");
                 if (namespace == null) {
-                    namespace = node.declareNamespace(namespaceURI, "");
+                    namespace = node.declareNamespace(namespaceURI, createPrefix());
                 }
             } else {
                 namespace = node.findNamespace(namespaceURI, prefix);
             }
             node.setNamespace(namespace);
+        }
+
+        int namespaceCount = parser.getNamespaceCount();
+        for (int i = 0; i < namespaceCount; i++) {
+            if (!parser.getNamespaceURI(i).equals(namespaceURI)){
+                node.declareNamespace(parser.getNamespaceURI(i),
+                        parser.getNamespacePrefix(i));
+            }
         }
 
         if (isSOAPElement) {



Mime
View raw message