You are viewing a plain text version of this content. The canonical link for it is here.
Posted to axis-cvs@ws.apache.org by ru...@apache.org on 2005/11/24 15:46:32 UTC
svn commit: r348744 - in /webservices/axis2/trunk/java/modules:
saaj/src/org/apache/axis2/om/impl/dom/
saaj/src/org/apache/axis2/om/impl/dom/factory/
saaj/src/org/apache/axis2/soap/impl/dom/
saaj/src/org/apache/axis2/soap/impl/dom/factory/ xml/src/org/...
Author: ruchithf
Date: Thu Nov 24 06:46:10 2005
New Revision: 348744
URL: http://svn.apache.org/viewcvs?rev=348744&view=rev
Log:
- A small change in the StAXSOAPModelBuilder to set the factory properly
- A bunch of bug fixes to OM-DOM
Modified:
webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/om/impl/dom/AttrImpl.java
webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/om/impl/dom/AttributeMap.java
webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/om/impl/dom/DOMUtil.java
webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/om/impl/dom/ElementImpl.java
webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/om/impl/dom/NodeImpl.java
webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/om/impl/dom/NodeListImpl.java
webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/om/impl/dom/ParentNode.java
webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/om/impl/dom/factory/OMDOMFactory.java
webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/soap/impl/dom/SOAPElement.java
webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/soap/impl/dom/SOAPEnvelopeImpl.java
webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/soap/impl/dom/factory/DOMSOAPFactory.java
webservices/axis2/trunk/java/modules/xml/src/org/apache/axis2/soap/impl/llom/builder/StAXSOAPModelBuilder.java
Modified: webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/om/impl/dom/AttrImpl.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/om/impl/dom/AttrImpl.java?rev=348744&r1=348743&r2=348744&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/om/impl/dom/AttrImpl.java (original)
+++ webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/om/impl/dom/AttrImpl.java Thu Nov 24 06:46:10 2005
@@ -69,14 +69,14 @@
public AttrImpl(DocumentImpl ownerDocument, String localName, OMNamespace ns, String value) {
super(ownerDocument);
this.attrName = localName;
- this.attrValue = new TextImpl(value);
+ this.attrValue = new TextImpl(ownerDocument, value);
this.namespace = (NamespaceImpl)ns;
}
public AttrImpl(DocumentImpl ownerDocument, String name, String value) {
super(ownerDocument);
this.attrName = name;
- this.attrValue = new TextImpl(value);
+ this.attrValue = new TextImpl(ownerDocument,value);
}
public AttrImpl(DocumentImpl ownerDocument, String name) {
@@ -92,13 +92,13 @@
public AttrImpl(String localName, OMNamespace ns, String value) {
this.attrName = localName;
- this.attrValue = new TextImpl(value);
+ this.attrValue = new TextImpl((DocumentImpl)this.getOwnerDocument(),value);
this.namespace = (NamespaceImpl)ns;
}
public AttrImpl(String name, String value) {
this.attrName = name;
- this.attrValue = new TextImpl(value);
+ this.attrValue = new TextImpl((DocumentImpl)this.getOwnerDocument(),value);
}
Modified: webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/om/impl/dom/AttributeMap.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/om/impl/dom/AttributeMap.java?rev=348744&r1=348743&r2=348744&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/om/impl/dom/AttributeMap.java (original)
+++ webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/om/impl/dom/AttributeMap.java Thu Nov 24 06:46:10 2005
@@ -76,7 +76,7 @@
}
- attr.parent = (DocumentImpl)this.ownerNode; //Set the owner node
+ attr.parent = this.ownerNode; //Set the owner node
attr.isOwned(true); //To indicate that this attr belong to an element
attr.setUsed(true); //Setting used to true
Modified: webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/om/impl/dom/DOMUtil.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/om/impl/dom/DOMUtil.java?rev=348744&r1=348743&r2=348744&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/om/impl/dom/DOMUtil.java (original)
+++ webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/om/impl/dom/DOMUtil.java Thu Nov 24 06:46:10 2005
@@ -37,7 +37,9 @@
* qualifiedName, or its prefix, is "xmlns" and the namespaceURI is
* different from " http://www.w3.org/2000/xmlns/".
*/
- throw new UnsupportedOperationException("TODO");
+ //throw new UnsupportedOperationException("TODO");
+ //temporary fix
+ return true;
}
/**
Modified: webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/om/impl/dom/ElementImpl.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/om/impl/dom/ElementImpl.java?rev=348744&r1=348743&r2=348744&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/om/impl/dom/ElementImpl.java (original)
+++ webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/om/impl/dom/ElementImpl.java Thu Nov 24 06:46:10 2005
@@ -32,6 +32,7 @@
import org.w3c.dom.Attr;
import org.w3c.dom.DOMException;
import org.w3c.dom.Element;
+import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import org.w3c.dom.TypeInfo;
@@ -40,6 +41,7 @@
import javax.xml.stream.XMLStreamException;
import javax.xml.stream.XMLStreamReader;
import java.io.ByteArrayOutputStream;
+import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
@@ -63,6 +65,7 @@
if(ownerDocument.firstChild == null)
ownerDocument.firstChild = this;
this.localName = tagName;
+ this.attributes = new AttributeMap(this);
}
/**
@@ -76,6 +79,7 @@
this.localName = tagName;
this.namespace = ns;
this.declareNamespace(ns);
+ this.attributes = new AttributeMap(this);
}
public ElementImpl(DocumentImpl ownerDocument, String tagName, NamespaceImpl ns, OMXMLParserWrapper builder) {
@@ -84,6 +88,7 @@
this.namespace = ns;
this.builder = builder;
this.declareNamespace(ns);
+ this.attributes = new AttributeMap(this);
}
public ElementImpl(ParentNode parentNode, String tagName, NamespaceImpl ns) {
@@ -108,6 +113,7 @@
if(ns != null) {
this.declareNamespace(ns);
}
+ this.attributes = new AttributeMap(this);
}
@@ -232,9 +238,9 @@
throw new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR, msg);
}
if(this.attributes == null) {
- this.attributes = new AttributeMap((ParentNode)this.ownerNode);
+ this.attributes = new AttributeMap(this);
}
- this.attributes.setNamedItem(new AttrImpl(name, value));
+ this.attributes.setNamedItem(new AttrImpl(this.ownerNode, name, value));
}
/**
@@ -300,7 +306,7 @@
}
if(this.attributes == null) {
- this.attributes = new AttributeMap((ParentNode)this.ownerNode);
+ this.attributes = new AttributeMap(this);
}
return (Attr)this.attributes.setNamedItem(attr);
@@ -333,7 +339,7 @@
}
if(this.attributes == null) {
- this.attributes = new AttributeMap((ParentNode)this.ownerNode);
+ this.attributes = new AttributeMap(this);
}
//handle the namespaces
@@ -390,7 +396,7 @@
}
if(this.attributes == null) {
- this.attributes = new AttributeMap((ParentNode)this.ownerNode);
+ this.attributes = new AttributeMap(this);
}
//Check whether there's an existing Attr with same local name and namespace URI
@@ -814,9 +820,12 @@
if (attributes == null) {
return new EmptyIterator();
}
-// return
- //TODO Create a new AttrIterator and return it
- throw new UnsupportedOperationException("TODO");
+ ArrayList list = new ArrayList();
+ for (int i = 0; i < attributes.getLength(); i++) {
+ list.add(attributes.getItem(i));
+ }
+
+ return list.iterator();
}
/**
@@ -858,6 +867,10 @@
public QName resolveQName(String qname) {
ElementHelper helper = new ElementHelper(this);
return helper.resolveQName(qname);
+ }
+
+ public NamedNodeMap getAttributes() {
+ return this.attributes;
}
/*
Modified: webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/om/impl/dom/NodeImpl.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/om/impl/dom/NodeImpl.java?rev=348744&r1=348743&r2=348744&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/om/impl/dom/NodeImpl.java (original)
+++ webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/om/impl/dom/NodeImpl.java Thu Nov 24 06:46:10 2005
@@ -73,7 +73,7 @@
protected NodeImpl(DocumentImpl ownerDocument) {
this.ownerNode = ownerDocument;
- this.isOwned(true);
+// this.isOwned(true);
}
Modified: webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/om/impl/dom/NodeListImpl.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/om/impl/dom/NodeListImpl.java?rev=348744&r1=348743&r2=348744&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/om/impl/dom/NodeListImpl.java (original)
+++ webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/om/impl/dom/NodeListImpl.java Thu Nov 24 06:46:10 2005
@@ -63,7 +63,11 @@
if(!enableNS) {
children = ((OMContainerEx)rootNode).getChildrenWithName(new QName(this.tagName));
} else {
- children = ((OMContainerEx)rootNode).getChildrenWithName(new QName(this.nsName, DOMUtil.getLocalName(this.tagName), DOMUtil.getPrefix(this.tagName)));
+ if(DOMUtil.getPrefix(this.tagName) != null) {
+ children = ((OMContainerEx)rootNode).getChildrenWithName(new QName(this.nsName, DOMUtil.getLocalName(this.tagName), DOMUtil.getPrefix(this.tagName)));
+ } else {
+ children = ((OMContainerEx)rootNode).getChildrenWithName(new QName(this.nsName, DOMUtil.getLocalName(this.tagName)));
+ }
}
int count = 0;
while (children.hasNext()) {
Modified: webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/om/impl/dom/ParentNode.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/om/impl/dom/ParentNode.java?rev=348744&r1=348743&r2=348744&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/om/impl/dom/ParentNode.java (original)
+++ webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/om/impl/dom/ParentNode.java Thu Nov 24 06:46:10 2005
@@ -22,6 +22,7 @@
import org.apache.axis2.om.impl.llom.traverse.OMChildrenIterator;
import org.apache.axis2.om.impl.llom.traverse.OMChildrenQNameIterator;
import org.w3c.dom.DOMException;
+import org.w3c.dom.Document;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
@@ -142,7 +143,7 @@
"HIERARCHY_REQUEST_ERR", null));
}
- if(!(this.ownerNode == newDomChild.getOwnerDocument())) {
+ if(!(this instanceof Document) && !(this.ownerNode == newDomChild.getOwnerDocument())) {
throw new DOMException(DOMException.WRONG_DOCUMENT_ERR,
DOMMessageFormatter.formatMessage(
DOMMessageFormatter.DOM_DOMAIN,
@@ -156,11 +157,27 @@
"NO_MODIFICATION_ALLOWED_ERR", null));
}
+ if(this instanceof Document) {
+ if(this.firstChild != null) {
+ //Throw exception since there cannot be two document elements
+ throw new DOMException(DOMException.HIERARCHY_REQUEST_ERR,
+ DOMMessageFormatter.formatMessage(
+ DOMMessageFormatter.DOM_DOMAIN,
+ "HIERARCHY_REQUEST_ERR", null));
+ } else {
+ this.firstChild = newDomChild;
+ newDomChild.isFirstChild(true);
+ this.lastChild = newDomChild;
+ return newDomChild;
+ }
+ }
+
if(refChild == null) { //Append the child to the end of the list
//if there are no children
if(this.lastChild == null && firstChild == null ) {
this.lastChild = newDomChild;
this.firstChild = newDomChild;
+ this.firstChild.isFirstChild(true);
} else {
this.lastChild.nextSibling = newDomChild;
newDomChild.previousSubling = this.lastChild;
Modified: webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/om/impl/dom/factory/OMDOMFactory.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/om/impl/dom/factory/OMDOMFactory.java?rev=348744&r1=348743&r2=348744&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/om/impl/dom/factory/OMDOMFactory.java (original)
+++ webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/om/impl/dom/factory/OMDOMFactory.java Thu Nov 24 06:46:10 2005
@@ -45,7 +45,7 @@
*/
public class OMDOMFactory implements OMFactory {
- private DocumentImpl document;
+ protected DocumentImpl document;
public OMDocument createOMDocument() {
if(this.document == null)
Modified: webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/soap/impl/dom/SOAPElement.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/soap/impl/dom/SOAPElement.java?rev=348744&r1=348743&r2=348744&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/soap/impl/dom/SOAPElement.java (original)
+++ webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/soap/impl/dom/SOAPElement.java Thu Nov 24 06:46:10 2005
@@ -60,6 +60,10 @@
super(doc, localName, (NamespaceImpl)ns);
}
+ protected SOAPElement(DocumentImpl ownerDocument, String tagName, NamespaceImpl ns, OMXMLParserWrapper builder) {
+ super(ownerDocument, tagName, ns, builder);
+ }
+
// /**
// * Caution : This Constructor is meant to be used only by the SOAPEnvelope.
// * <p/>
Modified: webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/soap/impl/dom/SOAPEnvelopeImpl.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/soap/impl/dom/SOAPEnvelopeImpl.java?rev=348744&r1=348743&r2=348744&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/soap/impl/dom/SOAPEnvelopeImpl.java (original)
+++ webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/soap/impl/dom/SOAPEnvelopeImpl.java Thu Nov 24 06:46:10 2005
@@ -23,6 +23,9 @@
import org.apache.axis2.om.OMNode;
import org.apache.axis2.om.OMXMLParserWrapper;
import org.apache.axis2.om.impl.OMOutputImpl;
+import org.apache.axis2.om.impl.dom.DocumentImpl;
+import org.apache.axis2.om.impl.dom.NamespaceImpl;
+import org.apache.axis2.soap.SOAP11Constants;
import org.apache.axis2.soap.SOAP12Constants;
import org.apache.axis2.soap.SOAPBody;
import org.apache.axis2.soap.SOAPConstants;
@@ -33,6 +36,7 @@
import org.apache.axis2.soap.SOAPProcessingException;
import org.apache.axis2.soap.impl.dom.SOAPElement;
import org.apache.axis2.soap.impl.dom.factory.DOMSOAPFactory;
+import org.apache.axis2.soap.impl.dom.soap11.SOAP11Factory;
import javax.xml.namespace.QName;
import javax.xml.stream.XMLStreamException;
@@ -49,7 +53,17 @@
super(null, SOAPConstants.SOAPENVELOPE_LOCAL_NAME, builder);
this.factory = factory;
}
-
+
+ public SOAPEnvelopeImpl(DocumentImpl doc, OMXMLParserWrapper builder, SOAPFactory factory) {
+ super(
+ doc,
+ SOAPConstants.SOAPENVELOPE_LOCAL_NAME,
+ (NamespaceImpl)factory
+ .createOMNamespace((factory instanceof SOAP11Factory) ? SOAP11Constants.SOAP_ENVELOPE_NAMESPACE_URI
+ : SOAP12Constants.SOAP_ENVELOPE_NAMESPACE_URI, SOAPConstants.SOAP_DEFAULT_NAMESPACE_PREFIX),
+ builder);
+ this.factory = factory;
+ }
/**
* @param ns
*/
Modified: webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/soap/impl/dom/factory/DOMSOAPFactory.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/soap/impl/dom/factory/DOMSOAPFactory.java?rev=348744&r1=348743&r2=348744&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/soap/impl/dom/factory/DOMSOAPFactory.java (original)
+++ webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/soap/impl/dom/factory/DOMSOAPFactory.java Thu Nov 24 06:46:10 2005
@@ -17,6 +17,7 @@
import org.apache.axis2.om.OMNamespace;
import org.apache.axis2.om.OMXMLParserWrapper;
+import org.apache.axis2.om.impl.dom.DocumentImpl;
import org.apache.axis2.om.impl.dom.factory.OMDOMFactory;
import org.apache.axis2.soap.SOAPBody;
import org.apache.axis2.soap.SOAPEnvelope;
@@ -40,15 +41,19 @@
public class DOMSOAPFactory extends OMDOMFactory implements SOAPFactory {
public SOAPMessage createSOAPMessage(OMXMLParserWrapper builder) {
- return new SOAPMessageImpl(builder);
+ SOAPMessageImpl messageImpl = new SOAPMessageImpl(builder);
+ this.document = messageImpl;
+ return messageImpl;
}
public SOAPMessage createSOAPMessage(SOAPEnvelope envelope, OMXMLParserWrapper parserWrapper) {
- return new SOAPMessageImpl(envelope, parserWrapper);
+ SOAPMessageImpl messageImpl = new SOAPMessageImpl(envelope, parserWrapper);
+ this.document = messageImpl;
+ return messageImpl;
}
public SOAPEnvelope createSOAPEnvelope(OMXMLParserWrapper builder) {
- return new SOAPEnvelopeImpl(builder, this);
+ return new SOAPEnvelopeImpl((DocumentImpl)this.createOMDocument(), builder, this);
}
public SOAPEnvelope createSOAPEnvelope() throws SOAPProcessingException {
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=348744&r1=348743&r2=348744&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 Thu Nov 24 06:46:10 2005
@@ -106,7 +106,7 @@
* he can just pass null for this.
*/
public StAXSOAPModelBuilder(XMLStreamReader parser, SOAPFactory factory, String soapVersion) {
- super(parser);
+ super(factory, parser);
soapFactory = factory;
soapMessage = soapFactory.createSOAPMessage(this);
identifySOAPVersion(soapVersion);