You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by ru...@apache.org on 2005/11/30 21:43:11 UTC
svn commit: r350044 - in /webservices/axis2/trunk/java/modules:
core/src/org/apache/axis2/engine/ saaj/src/org/apache/axis2/om/impl/dom/
saaj/src/org/apache/axis2/om/impl/dom/jaxp/
saaj/src/org/apache/axis2/soap/impl/dom/ saaj/test/org/apache/axis2/om/...
Author: ruchithf
Date: Wed Nov 30 12:42:37 2005
New Revision: 350044
URL: http://svn.apache.org/viewcvs?rev=350044&view=rev
Log:
Yet another update to the 'DOOM' (DOM-OM) impl with a number of fixes. Mainly, fixed a problem due to DOM treating namespace declarations as normal attributes and StAX/OM treating them as 'namespaces'
Progress so far:
- Now we can use DOOM with WSS4J to work with Scenario1 (UsernameToken) and everything works fine :-)
- Scenario2: Encrypted UsernameToken message is generated by using DOOM with WSS4J+XML-SEC, and at the receiver the encrypted parts are properly decrypted :-) ... but have to complete Document.importNode() first (done, have to test) to get the response message working
Modified:
webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/engine/Phase.java
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/DocumentImpl.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/ParentNode.java
webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/om/impl/dom/TextImpl.java
webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/om/impl/dom/jaxp/DocumentBuilderFactoryImpl.java
webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/om/impl/dom/jaxp/DocumentBuilderImpl.java
webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/soap/impl/dom/SOAPMessageImpl.java
webservices/axis2/trunk/java/modules/saaj/test/org/apache/axis2/om/impl/dom/DocumentImplTest.java
webservices/axis2/trunk/java/modules/saaj/test/org/apache/axis2/om/impl/dom/ElementImplTest.java
webservices/axis2/trunk/java/modules/security/project.xml
webservices/axis2/trunk/java/modules/xml/src/org/apache/axis2/om/OMConstants.java
Modified: webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/engine/Phase.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/engine/Phase.java?rev=350044&r1=350043&r2=350044&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/engine/Phase.java (original)
+++ webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/engine/Phase.java Wed Nov 30 12:42:37 2005
@@ -109,7 +109,7 @@
* @param index
*/
public void addHandler(Handler handler, int index) {
- log.info(
+ log.debug(
"Handler " + handler.getName() + "Added to place " + 1 +
" At the Phase " +
phaseName);
@@ -122,7 +122,7 @@
* @param handler
*/
public void addHandler(Handler handler) {
- log.info(
+ log.debug(
"Handler " + handler.getName() + " Added to the Phase " +
phaseName);
handlers.add(handler);
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=350044&r1=350043&r2=350044&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 Wed Nov 30 12:42:37 2005
@@ -19,6 +19,7 @@
import javax.xml.stream.XMLStreamException;
import org.apache.axis2.om.OMAttribute;
+import org.apache.axis2.om.OMConstants;
import org.apache.axis2.om.OMContainer;
import org.apache.axis2.om.OMException;
import org.apache.axis2.om.OMNamespace;
@@ -126,7 +127,7 @@
* @see org.w3c.dom.Node#getNodeValue()
*/
public String getNodeValue() throws DOMException {
- return (this.attrName==null)?"":this.attrValue.getData();
+ return (this.attrName==null) ? "" : this.attrValue.getData();
}
/**
@@ -134,14 +135,14 @@
* @see org.w3c.dom.Attr#getValue()
*/
public String getValue() {
- return (this.attrValue == null)? null:this.attrValue.getText();
+ return (this.attrValue == null) ? null:this.attrValue.getText();
}
///
///org.w3c.dom.Attr methods
///
public String getName() {
- return this.attrName;
+ return (this.namespace==null) ? this.attrName:OMConstants.XMLNS_NS_PREFIX + ":" + this.attrName;
}
/**
@@ -310,7 +311,7 @@
* @see org.w3c.dom.Node#getLocalName()
*/
public String getLocalName() {
- return this.attrName;
+ return (this.namespace == null) ? null : this.attrName;
}
/**
Modified: webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/om/impl/dom/DocumentImpl.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/om/impl/dom/DocumentImpl.java?rev=350044&r1=350043&r2=350044&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/om/impl/dom/DocumentImpl.java (original)
+++ webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/om/impl/dom/DocumentImpl.java Wed Nov 30 12:42:37 2005
@@ -15,6 +15,11 @@
*/
package org.apache.axis2.om.impl.dom;
+import java.util.Hashtable;
+
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamWriter;
+
import org.apache.axis2.om.OMContainer;
import org.apache.axis2.om.OMDocument;
import org.apache.axis2.om.OMElement;
@@ -34,16 +39,12 @@
import org.w3c.dom.DocumentType;
import org.w3c.dom.Element;
import org.w3c.dom.EntityReference;
+import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import org.w3c.dom.ProcessingInstruction;
import org.w3c.dom.Text;
-import java.util.Hashtable;
-
-import javax.xml.stream.XMLStreamException;
-import javax.xml.stream.XMLStreamWriter;
-
/**
* @author Ruchith Fernando (ruchith.fernando@gmail.com)
*/
@@ -159,8 +160,7 @@
}
public DocumentFragment createDocumentFragment() {
- //TODO
- throw new UnsupportedOperationException("TODO");
+ return new DocumentFragmentimpl(this);
}
public Element createElement(String tagName) throws DOMException {
@@ -213,10 +213,91 @@
//TODO
throw new UnsupportedOperationException("TODO");
}
- public Node importNode(Node arg0, boolean arg1) throws DOMException {
- //TODO
- throw new UnsupportedOperationException("TODO");
+ public Node importNode(Node importedNode, boolean deep) throws DOMException {
+
+ short type = importedNode.getNodeType();
+ Node newNode = null;
+ switch(type) {
+ case Node.ELEMENT_NODE : {
+ Element newElement;
+ if(importedNode.getLocalName() == null) {
+ newElement = this.createElement(importedNode.getNodeName());
+ } else {
+ newElement = createElementNS(importedNode.getNamespaceURI(),importedNode.getNodeName());
+ }
+
+ //Copy element's attributes, if any.
+ NamedNodeMap sourceAttrs = importedNode.getAttributes();
+ if (sourceAttrs != null) {
+ int length = sourceAttrs.getLength();
+ for (int index = 0; index < length; index++) {
+ Attr attr = (Attr)sourceAttrs.item(index);
+
+ Attr newAttr = (Attr) importNode(attr, true);
+ if(attr.getLocalName() == null) {
+ newElement.setAttributeNode(newAttr);
+ } else {
+ newElement.setAttributeNodeNS(newAttr);
+ }
+
+ }
+ }
+ newNode = newElement;
+ break;
+ }
+
+ case Node.ATTRIBUTE_NODE : {
+ if (importedNode.getLocalName() == null) {
+ newNode = createAttribute(importedNode.getNodeName());
+ } else {
+ newNode = createAttributeNS(importedNode.getNamespaceURI(),
+ importedNode.getNodeName());
+ }
+ ((Attr)newNode).setValue(importedNode.getNodeValue());
+ break;
+ }
+
+ case Node.TEXT_NODE : {
+ newNode = createTextNode(importedNode.getNodeValue());
+ break;
+ }
+
+ case Node.DOCUMENT_FRAGMENT_NODE: {
+ newNode = createDocumentFragment();
+ // No name, kids carry value
+ break;
+ }
+
+ case Node.CDATA_SECTION_NODE:
+ case Node.ENTITY_REFERENCE_NODE:
+ case Node.ENTITY_NODE:
+ case Node.PROCESSING_INSTRUCTION_NODE:
+ case Node.COMMENT_NODE:
+ case Node.DOCUMENT_TYPE_NODE:
+ case Node.NOTATION_NODE:
+ throw new UnsupportedOperationException("TODO");
+
+ case Node.DOCUMENT_NODE: // Can't import document nodes
+ default: { // Unknown node type
+ String msg = DOMMessageFormatter.formatMessage(DOMMessageFormatter.DOM_DOMAIN, "NOT_SUPPORTED_ERR", null);
+ throw new DOMException(DOMException.NOT_SUPPORTED_ERR, msg);
+ }
+
+ }
+
+ // If deep, replicate and attach the kids.
+ if (deep) {
+ for (Node srckid = importedNode.getFirstChild(); srckid != null; srckid = srckid.getNextSibling()) {
+ newNode.appendChild(importNode(srckid, true));
+ }
+ }
+
+ return newNode;
+
}
+
+
+
public void serialize(XMLStreamWriter xmlWriter) throws XMLStreamException {
//TODO
@@ -296,6 +377,11 @@
* @see org.w3c.dom.Document#getDocumentElement()
*/
public Element getDocumentElement() {
+
+ if(this.firstChild == null && !this.done) {
+ this.build();
+ }
+
return (Element)this.firstChild;
}
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=350044&r1=350043&r2=350044&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 Wed Nov 30 12:42:37 2005
@@ -137,7 +137,8 @@
* @see org.w3c.dom.Node#getNodeName()
*/
public String getNodeName() {
- return this.localName;
+ return (this.namespace != null) ? this.namespace.getPrefix() + ":"
+ + this.localName : this.localName;
}
/**
@@ -189,31 +190,18 @@
throw new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR, msg);
}
+ if(name.startsWith(OMConstants.XMLNS_NS_PREFIX)) {
+ String namespacePrefix = DOMUtil.getLocalName(name);
+ if(this.findNamespaceURI(namespacePrefix) != null) {
+ this.removeNamespace(namespacePrefix);
+ }
+ }
+
if(this.attributes != null) {
this.attributes.removeNamedItem(name);
}
}
-
- /* (non-Javadoc)
- * @see org.w3c.dom.Element#hasAttribute(java.lang.String)
- */
- public boolean hasAttribute(String name) {
- return this.getAttributeNode(name) != null;
- }
-
- /**
- * Look in the local list of attributes and return if found
- * if the local list is null return null
- * @see org.w3c.dom.Element#getAttribute(java.lang.String)
- */
- public String getAttribute(String name) {
- if(attributes == null) {
- return "";
- } else {
- return ((Attr)attributes.getNamedItem(name)).getValue();
- }
- }
-
+
/* (non-Javadoc)
* @see org.w3c.dom.Element#removeAttributeNS(java.lang.String, java.lang.String)
*/
@@ -228,24 +216,28 @@
}
}
- /* (non-Javadoc)
- * @see org.w3c.dom.Element#setAttribute(java.lang.String, java.lang.String)
+ /**
+ * Removes the specified attribute node
+ * @see org.w3c.dom.Element#removeAttributeNode(org.w3c.dom.Attr)
*/
- public void setAttribute(String name, String value) throws DOMException {
- //Check for invalid charaters
- if(!DOMUtil.isValidChras(name)) {
- String msg = DOMMessageFormatter.formatMessage(DOMMessageFormatter.DOM_DOMAIN, "INVALID_CHARACTER_ERR", null);
- throw new DOMException(DOMException.INVALID_CHARACTER_ERR, msg);
- }
-
- if(this.isReadonly()) {
+ public Attr removeAttributeNode(Attr oldAttr) throws DOMException {
+ if(isReadonly()) {
String msg = DOMMessageFormatter.formatMessage(DOMMessageFormatter.DOM_DOMAIN, "NO_MODIFICATION_ALLOWED_ERR", null);
throw new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR, msg);
+ }
+ if(this.attributes == null || this.attributes.getNamedItem(oldAttr.getName()) == null) {
+ String msg = DOMMessageFormatter.formatMessage(DOMMessageFormatter.DOM_DOMAIN, "NOT_FOUND_ERR", null);
+ throw new DOMException(DOMException.NOT_FOUND_ERR, msg);
}
- if(this.attributes == null) {
- this.attributes = new AttributeMap(this);
- }
- this.attributes.setNamedItem(new AttrImpl(this.ownerNode, name, value));
+ AttrImpl tempAttr = (AttrImpl)this.attributes.removeNamedItem(oldAttr.getName());
+ return tempAttr;
+ }
+
+ /* (non-Javadoc)
+ * @see org.w3c.dom.Element#hasAttribute(java.lang.String)
+ */
+ public boolean hasAttribute(String name) {
+ return this.getAttributeNode(name) != null;
}
/**
@@ -255,34 +247,56 @@
public boolean hasAttributeNS(String namespaceURI, String localName) {
return this.getAttributeNodeNS(namespaceURI, localName) != null;
}
+
+ /**
+ * Look in the local list of attributes and return if found
+ * if the local list is null return null
+ * @see org.w3c.dom.Element#getAttribute(java.lang.String)
+ */
+ public String getAttribute(String name) {
+ if(attributes == null) {
+ return "";
+ } else {
+ return ((Attr)attributes.getNamedItem(name)).getValue();
+ }
+ }
/**
* Retrieves an attribute node by name.
* @see org.w3c.dom.Element#getAttributeNode(java.lang.String)
*/
public Attr getAttributeNode(String name) {
+ return (this.attributes==null)?null:(AttrImpl)this.attributes.getNamedItem(name);
+ }
+
+ /**
+ * Retrieves an attribute value by local name and namespace URI.
+ * @see org.w3c.dom.Element#getAttributeNS(java.lang.String, java.lang.String)
+ */
+ public String getAttributeNS(String namespaceURI, String localName) {
if(this.attributes == null) {
- return null;
+ return "";
}
-
- return (AttrImpl)this.attributes.getNamedItem(name);
+ Attr attributeNodeNS = this.getAttributeNodeNS(namespaceURI, localName);
+ return attributeNodeNS == null? "" : attributeNodeNS.getValue();
}
/**
- * Removes the specified attribute node
- * @see org.w3c.dom.Element#removeAttributeNode(org.w3c.dom.Attr)
+ * Retrieves an Attr node by local name and namespace URI.
+ * @see org.w3c.dom.Element#getAttributeNodeNS(java.lang.String, java.lang.String)
*/
- public Attr removeAttributeNode(Attr oldAttr) throws DOMException {
- if(isReadonly()) {
- String msg = DOMMessageFormatter.formatMessage(DOMMessageFormatter.DOM_DOMAIN, "NO_MODIFICATION_ALLOWED_ERR", null);
- throw new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR, msg);
- }
- if(this.attributes == null || this.attributes.getNamedItem(oldAttr.getName()) == null) {
- String msg = DOMMessageFormatter.formatMessage(DOMMessageFormatter.DOM_DOMAIN, "NOT_FOUND_ERR", null);
- throw new DOMException(DOMException.NOT_FOUND_ERR, msg);
+ public Attr getAttributeNodeNS(String namespaceURI, String localName) {
+
+ if(namespaceURI == OMConstants.XMLNS_NS_URI) {
+ OMNamespace ns = this.findNamespaceURI(localName);
+ AttrImpl namespaceAttr = new AttrImpl(localName, ns.getName());
+ NamespaceImpl xmlNs = new NamespaceImpl(OMConstants.XMLNS_NS_URI);
+ namespaceAttr.setOMNamespace(xmlNs);
+ return namespaceAttr;
}
- AttrImpl tempAttr = (AttrImpl)this.attributes.removeNamedItem(oldAttr.getName());
- return tempAttr;
+
+ return (this.attributes == null)?null:(Attr)this.attributes.getNamedItemNS(namespaceURI,localName);
+
}
/**
@@ -317,73 +331,90 @@
return (Attr)this.attributes.setNamedItem(attr);
}
+
+ /* (non-Javadoc)
+ * @see org.w3c.dom.Element#setAttribute(java.lang.String, java.lang.String)
+ */
+ public void setAttribute(String name, String value) throws DOMException {
+ //Check for invalid charaters
+ if(!DOMUtil.isValidChras(name)) {
+ String msg = DOMMessageFormatter.formatMessage(DOMMessageFormatter.DOM_DOMAIN, "INVALID_CHARACTER_ERR", null);
+ throw new DOMException(DOMException.INVALID_CHARACTER_ERR, msg);
+ }
+
+ this.setAttributeNode(new AttrImpl(this.ownerNode, name, value));
+ }
/* (non-Javadoc)
* @see org.w3c.dom.Element#setAttributeNodeNS(org.w3c.dom.Attr)
*/
public Attr setAttributeNodeNS(Attr attr) throws DOMException {
-
- AttrImpl attrImpl = (AttrImpl)attr;
- if(attrImpl.isOwned()) {//check for ownership
- if(!this.getOwnerDocument().equals(attr.getOwnerDocument())) {
- String msg = DOMMessageFormatter.formatMessage(DOMMessageFormatter.DOM_DOMAIN, "WRONG_DOCUMENT_ERR", null);
- throw new DOMException(DOMException.WRONG_DOCUMENT_ERR, msg);
+ //Check whether the attr is a namespace declaration
+ //if so add a namespace NOT an attribute
+ if(attr.getNamespaceURI() != null && attr.getNamespaceURI().equals(OMConstants.XMLNS_NS_URI)) {
+ this.declareNamespace(attr.getName(), attr.getValue());
+ return attr;
+ } else {
+ AttrImpl attrImpl = (AttrImpl)attr;
+
+ if(attrImpl.isOwned()) {//check for ownership
+ if(!this.getOwnerDocument().equals(attr.getOwnerDocument())) {
+ String msg = DOMMessageFormatter.formatMessage(DOMMessageFormatter.DOM_DOMAIN, "WRONG_DOCUMENT_ERR", null);
+ throw new DOMException(DOMException.WRONG_DOCUMENT_ERR, msg);
+ }
+ }
+
+ if(this.isReadonly()) {
+ String msg = DOMMessageFormatter.formatMessage(DOMMessageFormatter.DOM_DOMAIN, "NO_MODIFICATION_ALLOWED_ERR", null);
+ throw new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR, msg);
+ }
+
+ //check whether the attr is in use
+ if(attrImpl.isUsed()) {
+ String msg = DOMMessageFormatter.formatMessage(DOMMessageFormatter.DOM_DOMAIN, "INUSE_ATTRIBUTE_ERR", null);
+ throw new DOMException(DOMException.INUSE_ATTRIBUTE_ERR, msg);
}
- }
-
- if(this.isReadonly()) {
- String msg = DOMMessageFormatter.formatMessage(DOMMessageFormatter.DOM_DOMAIN, "NO_MODIFICATION_ALLOWED_ERR", null);
- throw new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR, msg);
- }
-
- //check whether the attr is in use
- if(attrImpl.isUsed()) {
- String msg = DOMMessageFormatter.formatMessage(DOMMessageFormatter.DOM_DOMAIN, "INUSE_ATTRIBUTE_ERR", null);
- throw new DOMException(DOMException.INUSE_ATTRIBUTE_ERR, msg);
- }
-
- if(this.attributes == null) {
- this.attributes = new AttributeMap(this);
- }
-
- //handle the namespaces
- if (attr.getNamespaceURI() != null && findNamespace(attr.getNamespaceURI(), attr.getPrefix()) == null) {
- //TODO checkwhether the same ns is declared with a different prefix and remove it
- this.declareNamespace(new NamespaceImpl(attr.getNamespaceURI(),attr.getPrefix()));
- }
-
- return (Attr)this.attributes.setNamedItemNS(attr);
- }
-
-
- /**
- * Retrieves an attribute value by local name and namespace URI.
- * @see org.w3c.dom.Element#getAttributeNS(java.lang.String, java.lang.String)
- */
- public String getAttributeNS(String namespaceURI, String localName) {
- if(this.attributes == null) {
- return "";
+ if(this.attributes == null) {
+ this.attributes = new AttributeMap(this);
+ }
+
+ //handle the namespaces
+ if (attr.getNamespaceURI() != null && findNamespace(attr.getNamespaceURI(), attr.getPrefix()) == null) {
+ //TODO checkwhether the same ns is declared with a different prefix and remove it
+ this.declareNamespace(new NamespaceImpl(attr.getNamespaceURI(),attr.getPrefix()));
+ }
+
+ return (Attr)this.attributes.setNamedItemNS(attr);
}
-
- return this.attributes.getNamedItemNS(namespaceURI, localName).getNodeValue();
}
-
+
/**
* Adds a new attribute
* @see org.w3c.dom.Element#setAttributeNS(java.lang.String, java.lang.String, java.lang.String)
*/
public void setAttributeNS(String namespaceURI, String qualifiedName, String value) throws DOMException {
- if (namespaceURI != null && findNamespace(namespaceURI, DOMUtil.getPrefix(qualifiedName)) == null) {
- //TODO checkwhether the same ns is declared with a different prefix and remove it
- this.declareNamespace(new NamespaceImpl(namespaceURI,DOMUtil.getPrefix(qualifiedName)));
- }
-
- this.addAttribute(namespaceURI,qualifiedName,value);
+ if(namespaceURI != null) {
+ if(namespaceURI.equals(OMConstants.XMLNS_NS_URI)) {
+ this.declareNamespace(value, DOMUtil.getLocalName(qualifiedName));
+ } else {
+ AttrImpl attr = new AttrImpl(this.ownerNode, DOMUtil.getLocalName(qualifiedName), value);
+ attr.setOMNamespace(new NamespaceImpl(namespaceURI, DOMUtil.getPrefix(qualifiedName)));
+
+ this.setAttributeNodeNS(attr);
+ }
+ } else {
+ //When the namespace is null, the attr name given better not be
+ //a qualified name
+ //But anyway check and set it
+ this.setAttribute(DOMUtil.getLocalName(qualifiedName), value);
+ }
+
}
-
+
+
private OMAttribute addAttribute(String namespaceURI, String qualifiedName, String value) throws DOMException {
if(!DOMUtil.isValidChras(qualifiedName)) {
String msg = DOMMessageFormatter.formatMessage(DOMMessageFormatter.DOM_DOMAIN, "INVALID_CHARACTER_ERR", null);
@@ -433,24 +464,11 @@
}
/**
- * Retrieves an Attr node by local name and namespace URI.
- * @see org.w3c.dom.Element#getAttributeNodeNS(java.lang.String, java.lang.String)
+ * Returns whether this element contains any attr or not
*/
- public Attr getAttributeNodeNS(String namespaceURI, String localName) {
- Attr attr = (this.attributes == null)?null:(Attr)this.attributes.getNamedItemNS(namespaceURI,localName);
-
- //In the case of a namespace decalation attribute go check the parent as well
- //When the namespaceURI is http://www.w3.org/2000/xmlns/
- if (attr == null
- && namespaceURI == OMConstants.XMLNS_NS_URI
- && this.parentNode instanceof ElementImpl) {
- ((ElementImpl) this.parentNode).getAttributeNodeNS(namespaceURI,
- localName);
- }
-
- return (this.attributes == null)?null:(Attr)this.attributes.getNamedItemNS(namespaceURI,localName);
-
- }
+ public boolean hasAttributes() {
+ return this.attributes==null?false:this.attributes.getLength()>0;
+ }
/* (non-Javadoc)
* @see org.w3c.dom.Element#getElementsByTagNameNS(java.lang.String, java.lang.String)
@@ -496,11 +514,17 @@
if (ns != null && findNamespace(ns.getName(), ns.getPrefix()) != null){
declareNamespace(ns);
}
+// if(ns != null) {
+// return this.addAttribute(ns.getName(),attributeName,value);
+// } else {
+// return this.addAttribute(null,attributeName,value);
+// }
if(ns != null) {
return this.addAttribute(ns.getName(),attributeName,value);
} else {
return this.addAttribute(null,attributeName,value);
}
+
}
/**
@@ -892,7 +916,7 @@
*/
public String getLocalName()
{
- return this.localName;
+ return this.namespace != null ? this.localName : null;
}
/**
@@ -931,8 +955,30 @@
throw new UnsupportedOperationException("Cloning is not supported yet !!");
}
+ /**
+ * This will return the set of attributes of this node and the
+ * namespace declarations available
+ */
public NamedNodeMap getAttributes() {
- return this.attributes;
+ AttributeMap attributeMap = new AttributeMap(this);
+
+ //Add the set of existing attrs
+ for(int i = 0; i < attributeMap.getLength(); i++) {
+ attributeMap.setNamedItem((Attr)attributeMap.getItem(i));
+ }
+
+ //Add the NS declarations
+ if(this.namespaces != null) {
+ Iterator nsDecls = this.namespaces.keySet().iterator();
+ while (nsDecls.hasNext()) {
+ String prefix = (String) nsDecls.next();
+ OMNamespace ns = (OMNamespace)this.namespaces.get(prefix);
+ AttrImpl attr = new AttrImpl(this.ownerNode, OMConstants.XMLNS_NS_PREFIX + ":" + prefix, ns.getName());
+ attributeMap.addItem(attr);
+ }
+ }
+
+ return attributeMap;
}
/**
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=350044&r1=350043&r2=350044&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 Wed Nov 30 12:42:37 2005
@@ -216,6 +216,8 @@
newDomChild.nextSibling = refDomChild;
refDomChild.previousSubling = newDomChild;
+ this.firstChild.isFirstChild(true);
+ refDomChild.isFirstChild(false);
newDomChild.previousSubling = null; //Just to be sure :-)
}
@@ -303,13 +305,25 @@
newDomChild.previousSubling = oldDomChild.previousSubling;
oldDomChild.previousSubling.nextSibling = newDomChild;
- oldDomChild.nextSibling.previousSubling = newDomChild;
+
+ //If the old child is not the last
+ if(oldDomChild.nextSibling != null) {
+ oldDomChild.nextSibling.previousSubling = newDomChild;
+ } else {
+ this.lastChild = newDomChild;
+ }
+
+ if(newDomChild.parentNode == null) {
+ newDomChild.parentNode = this;
+ }
+
}
found = true;
//remove the old child's references to this tree
oldDomChild.nextSibling = null;
oldDomChild.previousSubling = null;
+ oldDomChild.parentNode = null;
}
}
@@ -342,17 +356,31 @@
while(children.hasNext()) {
ChildNode tempNode = (ChildNode)children.next();
if(tempNode.equals(oldChild)) {
- //Child found
- ChildNode oldDomChild = (ChildNode)oldChild;
- ChildNode privChild = oldDomChild.previousSubling;
-
- privChild.nextSibling = oldDomChild.nextSibling;
- oldDomChild.nextSibling.previousSubling = privChild;
-
- //Remove old child's references to this tree
- oldDomChild.nextSibling = null;
- oldDomChild.previousSubling = null;
+ if(tempNode.isFirstChild()) {
+ //If this is the first child
+ this.firstChild = null;
+ this.lastChild = null;
+ tempNode.parentNode = null;
+ } else if (this.lastChild == tempNode) {
+ //not the first child, but the last child
+ ChildNode prevSib = tempNode.previousSubling;
+ prevSib.nextSibling = null;
+ tempNode.parentNode = null;
+ tempNode.previousSubling = null;
+ } else {
+
+ ChildNode oldDomChild = (ChildNode)oldChild;
+ ChildNode privChild = oldDomChild.previousSubling;
+
+ privChild.nextSibling = oldDomChild.nextSibling;
+ oldDomChild.nextSibling.previousSubling = privChild;
+
+ //Remove old child's references to this tree
+ oldDomChild.nextSibling = null;
+ oldDomChild.previousSubling = null;
+ }
+ //Child found
childFound = true;
}
}
Modified: webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/om/impl/dom/TextImpl.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/om/impl/dom/TextImpl.java?rev=350044&r1=350043&r2=350044&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/om/impl/dom/TextImpl.java (original)
+++ webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/om/impl/dom/TextImpl.java Wed Nov 30 12:42:37 2005
@@ -206,7 +206,7 @@
return "#text";
}
public short getNodeType() {
- return OMNode.TEXT_NODE;
+ return Node.TEXT_NODE;
}
Modified: webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/om/impl/dom/jaxp/DocumentBuilderFactoryImpl.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/om/impl/dom/jaxp/DocumentBuilderFactoryImpl.java?rev=350044&r1=350043&r2=350044&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/om/impl/dom/jaxp/DocumentBuilderFactoryImpl.java (original)
+++ webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/om/impl/dom/jaxp/DocumentBuilderFactoryImpl.java Wed Nov 30 12:42:37 2005
@@ -20,8 +20,8 @@
}
public void setAttribute(String arg0, Object arg1) throws IllegalArgumentException {
- // TODO
- throw new UnsupportedOperationException("TODO");
+// // TODO
+// throw new UnsupportedOperationException("TODO");
}
public static DocumentBuilderFactory newInstance() {
Modified: webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/om/impl/dom/jaxp/DocumentBuilderImpl.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/om/impl/dom/jaxp/DocumentBuilderImpl.java?rev=350044&r1=350043&r2=350044&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/om/impl/dom/jaxp/DocumentBuilderImpl.java (original)
+++ webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/om/impl/dom/jaxp/DocumentBuilderImpl.java Wed Nov 30 12:42:37 2005
@@ -70,7 +70,9 @@
* @see javax.xml.parsers.DocumentBuilder#newDocument()
*/
public Document newDocument() {
- return new DocumentImpl();
+ DocumentImpl documentImpl = new DocumentImpl();
+ documentImpl.setComplete(true);
+ return documentImpl;
}
public void setEntityResolver(EntityResolver arg0) {
@@ -87,7 +89,7 @@
try {
OMDOMFactory factory = new OMDOMFactory();
//Not really sure whether this will work :-?
- XMLStreamReader reader = XMLInputFactory.newInstance().createXMLStreamReader(inputSource.getByteStream());
+ XMLStreamReader reader = XMLInputFactory.newInstance().createXMLStreamReader(inputSource.getCharacterStream());
StAXOMBuilder builder = new StAXOMBuilder(factory,reader);
return (DocumentImpl)builder.getDocument();
}catch (XMLStreamException e) {
Modified: webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/soap/impl/dom/SOAPMessageImpl.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/soap/impl/dom/SOAPMessageImpl.java?rev=350044&r1=350043&r2=350044&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/soap/impl/dom/SOAPMessageImpl.java (original)
+++ webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/soap/impl/dom/SOAPMessageImpl.java Wed Nov 30 12:42:37 2005
@@ -16,8 +16,9 @@
package org.apache.axis2.soap.impl.dom;
+import javax.xml.stream.XMLStreamException;
+
import org.apache.axis2.om.OMElement;
-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;
@@ -25,8 +26,6 @@
import org.apache.axis2.soap.SOAPMessage;
import org.apache.axis2.soap.SOAPProcessingException;
-import javax.xml.stream.XMLStreamException;
-
public class SOAPMessageImpl extends DocumentImpl implements SOAPMessage {
public SOAPMessageImpl() {
@@ -48,24 +47,7 @@
}
public void setSOAPEnvelope(SOAPEnvelope envelope) throws SOAPProcessingException {
- if(this.getDocumentElement() != null) {
- this.replaceChild(this.getDocumentElement(), (SOAPEnvelopeImpl)envelope);
- } else {
- this.appendChild((SOAPEnvelopeImpl)envelope);
- }
- }
-
- public void setOMDocumentElement(OMElement rootElement) {
- throw new UnsupportedOperationException("This is not allowed. Use set SOAPEnvelope instead");
- }
-
- public void addChild(OMNode child) {
- throw new UnsupportedOperationException("Can not add normal children to SOAP envelope. Use setSOAPEnvelope()");
- }
-
-
- public void setFirstChild(OMNode firstChild) {
- throw new UnsupportedOperationException("This is not allowed. Use set SOAPEnvelope instead");
+ this.addChild(envelope);
}
protected void serialize(OMOutputImpl omOutput, boolean cache, boolean includeXMLDeclaration) throws XMLStreamException {
Modified: webservices/axis2/trunk/java/modules/saaj/test/org/apache/axis2/om/impl/dom/DocumentImplTest.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/saaj/test/org/apache/axis2/om/impl/dom/DocumentImplTest.java?rev=350044&r1=350043&r2=350044&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/saaj/test/org/apache/axis2/om/impl/dom/DocumentImplTest.java (original)
+++ webservices/axis2/trunk/java/modules/saaj/test/org/apache/axis2/om/impl/dom/DocumentImplTest.java Wed Nov 30 12:42:37 2005
@@ -37,7 +37,7 @@
DocumentImpl doc = new DocumentImpl();
Element elem = doc.createElement(tagName);
- assertEquals("Local name misnatch",tagName,elem.getLocalName());
+ assertEquals("Local name misnatch",tagName,elem.getNodeName());
elem = doc.createElementNS(namespace, tagName);
assertEquals("Local name misnatch",tagName,elem.getLocalName());
@@ -54,7 +54,7 @@
DocumentImpl doc = new DocumentImpl();
Attr attr = doc.createAttribute(attrName);
- assertEquals("Attr name mismatch",attrName,attr.getLocalName());
+ assertEquals("Attr name mismatch",attrName,attr.getName());
assertNull("Namespace value should be null", attr.getNamespaceURI());
Modified: webservices/axis2/trunk/java/modules/saaj/test/org/apache/axis2/om/impl/dom/ElementImplTest.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/saaj/test/org/apache/axis2/om/impl/dom/ElementImplTest.java?rev=350044&r1=350043&r2=350044&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/saaj/test/org/apache/axis2/om/impl/dom/ElementImplTest.java (original)
+++ webservices/axis2/trunk/java/modules/saaj/test/org/apache/axis2/om/impl/dom/ElementImplTest.java Wed Nov 30 12:42:37 2005
@@ -15,22 +15,21 @@
*/
package org.apache.axis2.om.impl.dom;
+import java.io.ByteArrayOutputStream;
+import java.util.Iterator;
+
+import javax.xml.namespace.QName;
+
+import junit.framework.TestCase;
+
import org.apache.axis2.om.OMElement;
import org.apache.axis2.om.OMText;
-import org.apache.axis2.om.impl.OMOutputImpl;
import org.apache.axis2.om.impl.dom.factory.OMDOMFactory;
import org.apache.axis2.om.impl.dom.jaxp.DocumentBuilderFactoryImpl;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.NodeList;
import org.w3c.dom.Text;
-
-import java.io.ByteArrayOutputStream;
-import java.util.Iterator;
-
-import javax.xml.namespace.QName;
-
-import junit.framework.TestCase;
public class ElementImplTest extends TestCase {
Modified: webservices/axis2/trunk/java/modules/security/project.xml
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/security/project.xml?rev=350044&r1=350043&r2=350044&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/security/project.xml (original)
+++ webservices/axis2/trunk/java/modules/security/project.xml Wed Nov 30 12:42:37 2005
@@ -52,6 +52,11 @@
<artifactId>axis2-core</artifactId>
<version>${pom.currentVersion}</version>
</dependency>
+ <dependency>
+ <groupId>axis2</groupId>
+ <artifactId>axis2-saaj</artifactId>
+ <version>${pom.currentVersion}</version>
+ </dependency>
<!-- external JARs -->
<dependency>
<groupId>axis</groupId>
Modified: webservices/axis2/trunk/java/modules/xml/src/org/apache/axis2/om/OMConstants.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/xml/src/org/apache/axis2/om/OMConstants.java?rev=350044&r1=350043&r2=350044&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/xml/src/org/apache/axis2/om/OMConstants.java (original)
+++ webservices/axis2/trunk/java/modules/xml/src/org/apache/axis2/om/OMConstants.java Wed Nov 30 12:42:37 2005
@@ -68,6 +68,7 @@
"http://www.w3.org/XML/1998/namespace";
public static final String XMLNS_NS_URI = "http://www.w3.org/2000/xmlns/";
+ public final static String XMLNS_NS_PREFIX = "xmlns";
public static final String XMLNS_PREFIX =
"xml";