Am attaching a quick patch for community's review. I know there can be
better refactoring done which can reduce the code duplication etc. but
as I said this one is a quick patch disturbing things minimally :-)
If comment support in SOAP model is the need of the hour, one can
think of committing this patch if it looks okay.
I've tested to see the soap message provided by Ashu below passes
properly or not with this patch, and it worked.

Thanks
Jaya
Note: Patch is made from modules/xml/src/org/apache/axis2/soap folder

On 7/27/05, Shahi, Ashutosh <[EMAIL PROTECTED]> wrote:
> 
> 
> Hi OMers  ;-),
> 
> As part of XML Infoset, there was some code added to next() method in
> staxOMBuilder to process comments etc.
> 
> But, we have staxSOAPModelBuilder also, where we do not have any such
> capability yet. Now comments can be part of soapMessage as well.
> 
> I have a test soap message : 
> 
> "<?xml version='1.0' encoding='UTF-8'?>" + 
> 
>                                     "<!-- Comment -->" +
> 
>                                     "<env:Envelope
> xmlns:env='http://schemas.xmlsoap.org/soap/envelope/'>" +
> 
>                                    
> "<env:Body><echo><arg0>Hello</arg0></echo></env:Body>" +
> 
>                                     "</env:Envelope>";
> 
>  
> 
> And doing something like:
> 
> stAXSOAPModelBuilder =
> 
>                         new StAXSOAPModelBuilder(
> 
>                                 XMLInputFactory.newInstance()
> 
>                        
> .createXMLStreamReader(inputStream));
> 
> Where input stream has soap message with comments gives an OMException.
> 
>  
> 
> Now my question is: 
> 
> Both StaxSOAPModelBuilder and StaxOMBuilder extend the abstract class
> StaxBuilder which has next() as abstract method. Why not put the
> functionality in next() method of StaxBuilder itself? Or atleast we should
> process comments in StaxSOAPModelBuilder as well.
> 
>  
> 
> -Ashutosh
> 
>  


-- 
-- Jaya
Index: impl/llom/builder/StAXSOAPModelBuilder.java
===================================================================
--- impl/llom/builder/StAXSOAPModelBuilder.java (revision 225472)
+++ impl/llom/builder/StAXSOAPModelBuilder.java (working copy)
@@ -381,6 +381,9 @@
                 case XMLStreamConstants.END_DOCUMENT:
                     done = true;
                     break;
+                case XMLStreamConstants.COMMENT:
+                    createComment();
+                    break;
                 case XMLStreamConstants.SPACE:
                     next();
                     break;
@@ -396,6 +399,26 @@
     }
 
     /**
+     * Method createComment
+     *
+     * @return
+     * @throws OMException
+     */
+    protected OMNode createComment() throws OMException {
+        OMNode node;
+        if (lastNode == null) {//meaning Document level comment
+               //Since there is no SOAPDocument kind of support... we
+               //will just create a node whose parent is null
+            node = omfactory.createOMComment(null, parser.getText());
+        } else if (lastNode.isComplete()) {
+            node = omfactory.createOMComment(lastNode.getParent(), 
parser.getText());
+        } else {
+            node = omfactory.createOMComment((OMElement) lastNode, 
parser.getText());
+        }
+        return node;
+    }
+    
+    /**
      * Method getDocumentElement
      *
      * @return

Reply via email to