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/10/19 15:40:51 UTC

svn commit: r326556 - in /webservices/axis2/trunk/java/modules/xml: src/org/apache/axis2/om/impl/dom/ src/org/apache/axis2/om/impl/dom/jaxp/ test/org/apache/axis2/om/impl/dom/

Author: ruchithf
Date: Wed Oct 19 06:39:44 2005
New Revision: 326556

URL: http://svn.apache.org/viewcvs?rev=326556&view=rev
Log:
1.) Added the org.apache.axis2.om.impl.dom.jaxp package containing the DocumentBuilderFactoryImpl and the DocumentBuilderImpl classes
2.) Added some javadoc documentation in AttrImpl
3.) Updated AttributMap to set the correct parent in the Attr nodes

Added:
    webservices/axis2/trunk/java/modules/xml/src/org/apache/axis2/om/impl/dom/DOMImplementationImpl.java
    webservices/axis2/trunk/java/modules/xml/src/org/apache/axis2/om/impl/dom/jaxp/
    webservices/axis2/trunk/java/modules/xml/src/org/apache/axis2/om/impl/dom/jaxp/DocumentBuilderFactoryImpl.java
    webservices/axis2/trunk/java/modules/xml/src/org/apache/axis2/om/impl/dom/jaxp/DocumentBuilderImpl.java
Modified:
    webservices/axis2/trunk/java/modules/xml/src/org/apache/axis2/om/impl/dom/AttrImpl.java
    webservices/axis2/trunk/java/modules/xml/src/org/apache/axis2/om/impl/dom/AttributeMap.java
    webservices/axis2/trunk/java/modules/xml/src/org/apache/axis2/om/impl/dom/DocumentImpl.java
    webservices/axis2/trunk/java/modules/xml/src/org/apache/axis2/om/impl/dom/ElementImpl.java
    webservices/axis2/trunk/java/modules/xml/test/org/apache/axis2/om/impl/dom/DocumentImplTest.java

Modified: webservices/axis2/trunk/java/modules/xml/src/org/apache/axis2/om/impl/dom/AttrImpl.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/xml/src/org/apache/axis2/om/impl/dom/AttrImpl.java?rev=326556&r1=326555&r2=326556&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/xml/src/org/apache/axis2/om/impl/dom/AttrImpl.java (original)
+++ webservices/axis2/trunk/java/modules/xml/src/org/apache/axis2/om/impl/dom/AttrImpl.java Wed Oct 19 06:39:44 2005
@@ -30,18 +30,36 @@
 import javax.xml.stream.XMLStreamException;
 
 /**
+ * Implementation of <code>org.w3c.dom.Attr</code> and 
+ * <code>org.apache.axis2.om.OMAttribute</code>
  * @author Ruchith Fernando (ruchith.fernando@gmail.com)
  */
 public class AttrImpl extends NodeImpl implements OMAttribute, Attr {
 
+	/**
+	 * Name of the attribute
+	 */
 	private String attrName;
+	
+	/**
+	 * Attribute value
+	 */
 	private TextImpl attrValue;
 	
+	/**
+	 * Attribute namespace
+	 */
 	private NamespaceImpl namespace;
 	
+	/**
+	 * Flag to indicate whether this attr is used or not
+	 */
 	private boolean used;
 	
-	private ParentNode parent;
+	/**
+	 * Owner of this attribute
+	 */
+	protected ParentNode parent;
 	
 	protected AttrImpl(DocumentImpl ownerDocument) {
 		super(ownerDocument);
@@ -60,6 +78,17 @@
 		this.attrValue = new TextImpl(value);
 	}
 	
+	public AttrImpl(DocumentImpl ownerDocument, String name) {
+		super(ownerDocument);
+		this.attrName = name;
+	}
+
+	public AttrImpl(DocumentImpl ownerDocument, String localName, OMNamespace namespace) {
+		super(ownerDocument);
+		this.attrName = localName;
+		this.namespace = (NamespaceImpl)namespace;
+	}
+	
 	public AttrImpl(String localName, OMNamespace ns, String value) {
 		this.attrName = localName;
 		this.attrValue = new TextImpl(value);
@@ -71,25 +100,38 @@
 		this.attrValue = new TextImpl(value);
 	}
 	
-	public AttrImpl(DocumentImpl ownerDocument, String name) {
-		super(ownerDocument);
-		this.attrName = name;
-	}
 
+	
 	///
 	///org.w3c.dom.Node methods
 	///
+	/**
+	 * Returns the name of this attribute 
+	 */
 	public String getNodeName() {
-		return this.attrName.toString();
+		return this.attrName;
 	}
+	
+	/**
+	 * Returns the node type
+	 * @see org.w3c.dom.Node#getNodeType()
+	 */
 	public short getNodeType() {
 		return Node.ATTRIBUTE_NODE;
 	}
 	
+	/**
+	 * returns the value of this attribute
+	 * @see org.w3c.dom.Node#getNodeValue()
+	 */
 	public String getNodeValue() throws DOMException {
 		return (this.attrName==null)?"":this.attrValue.getData();
 	}
 	
+	/**
+	 * returns the value of this attribute
+	 * @see org.w3c.dom.Attr#getValue()
+	 */
 	public String getValue() {
 		return (this.attrValue == null)? null:this.attrValue.getText();
 	}
@@ -100,6 +142,11 @@
 	public String getName() {
 		return this.attrName;
 	}
+	
+	/**
+	 * Returns the owner element
+	 * @see org.w3c.dom.Attr#getOwnerElement()
+	 */
 	public Element getOwnerElement() {
 		//Owned is set to an element instance when the attribute is added to an element
 		return (Element) (isOwned() ? ownerNode : null);
@@ -110,30 +157,62 @@
 		throw new UnsupportedOperationException("TODO");
 	}
 
+	/**
+	 * Not supported: Cannot detach attributes
+	 * Use the operations available in the owner node
+	 * @see org.apache.axis2.om.OMNode#detach()
+	 */
 	public OMNode detach() throws OMException {
 		throw new UnsupportedOperationException("Not supported");
 	}
 
+	/**
+	 * Not supported: Cannot discard attributes
+	 * Use the operations available in the owner node
+	 * @see org.apache.axis2.om.OMNode#discard()
+	 */
 	public void discard() throws OMException {
 		throw new UnsupportedOperationException("Not supported");
 	}
 
+	/**
+	 * Returns the type of this Attr node
+	 * @see org.apache.axis2.om.OMNode#getType()
+	 */
 	public int getType() {
 		return Node.ATTRIBUTE_NODE;
 	}
 
+	/**
+	 * This is not supported since attributes serialization is handled by
+	 * the serialization of the owner nodes
+	 * @see org.apache.axis2.om.OMNode#serialize(org.apache.axis2.om.impl.OMOutputImpl)
+	 */
 	public void serialize(OMOutputImpl omOutput) throws XMLStreamException {
 		throw new UnsupportedOperationException("Not supported");
 	}
 
+	/**
+	 * This is not supported since attributes serialization is handled by
+	 * the serialization of the owner nodes
+	 * @see org.apache.axis2.om.OMNode#serializeAndConsume(org.apache.axis2.om.impl.OMOutputImpl)
+	 */
 	public void serializeAndConsume(OMOutputImpl omOutput) throws XMLStreamException {
 		throw new UnsupportedOperationException("Not supported");
 	}
 
+	/**
+	 * Returns the namespace of the attribute as an <code>OMNamespace</code>
+	 * @see org.apache.axis2.om.OMAttribute#getNamespace()
+	 */
 	public OMNamespace getNamespace() {
 		return this.namespace;
 	}
 
+	/**
+	 * Returns a qname representing the attribute 
+	 * @see org.apache.axis2.om.OMAttribute#getQName()
+	 */
 	public QName getQName() {
 		return (this.namespace == null) ? new QName(this.attrName) : 
 			new QName(this.namespace.getName(), this.attrName, this.namespace
@@ -141,18 +220,34 @@
 		
 	}
 
+	/**
+	 * Returns the attribute value 
+	 * @see org.apache.axis2.om.OMAttribute#getAttributeValue()
+	 */
 	public String getAttributeValue() {
 		return this.attrValue.getText();
 	}
 
+	/**
+	 * Sets the attribute name
+	 * @see org.apache.axis2.om.OMAttribute#setLocalName(java.lang.String)
+	 */
 	public void setLocalName(String localName) {
 		this.attrName = localName;
 	}
 
+	/**
+	 * Sets the namespace of this attribute node
+	 * @see org.apache.axis2.om.OMAttribute#setOMNamespace(org.apache.axis2.om.OMNamespace)
+	 */
 	public void setOMNamespace(OMNamespace omNamespace) {
 		this.namespace = (NamespaceImpl)omNamespace;
 	}
 
+	/**
+	 * Sets the attribute value
+	 * @see org.apache.axis2.om.OMAttribute#setAttributeValue(java.lang.String)
+	 */
 	public void setAttributeValue(String value) {
 		if(isReadonly()) {
 			String msg = DOMMessageFormatter.formatMessage(DOMMessageFormatter.DOM_DOMAIN, "NO_MODIFICATION_ALLOWED_ERR", null);
@@ -161,10 +256,19 @@
 		this.attrValue = (TextImpl)this.getOwnerDocument().createTextNode(value);
 	}
 
+	/**
+	 * Sets the parent element to the given OMContainer
+	 * @see org.apache.axis2.om.impl.OMNodeEx#setParent(org.apache.axis2.om.OMContainer)
+	 */
 	public void setParent(OMContainer element) {
 		this.parent = (ParentNode)element;
 	}
 
+	/**
+	 * Sets the type
+	 * NOT IMPLEMENTED: Unnecessary
+	 * @see org.apache.axis2.om.impl.OMNodeEx#setType(int)
+	 */
 	public void setType(int nodeType) throws OMException {
 		//not necessary ???
 	}
@@ -183,20 +287,35 @@
 		this.used = used;
 	}
 
+	/**
+	 * Sets the value of the attribute
+	 * @see org.w3c.dom.Attr#setValue(java.lang.String)
+	 */
 	public void setValue(String value) throws DOMException {
 		this.attrValue = (TextImpl) this.getOwnerDocument().createTextNode(
 				value);
 	}
 
+	/**
+	 * Returns the parent node of this attribute
+	 * @see org.apache.axis2.om.OMNode#getParent()
+	 */
 	public OMContainer getParent() {
 		return this.parent;
 	}
 	
-    public String getLocalName()
-    {
+	/**
+	 * Returns the attribute name
+	 * @see org.w3c.dom.Node#getLocalName()
+	 */
+    public String getLocalName() {
         return this.attrName;
     }
 
+    /**
+     * Retuns the namespace URI of this attr node
+     * @see org.w3c.dom.Node#getNamespaceURI()
+     */
     public String getNamespaceURI() {
 		if(this.namespace != null) {
 			return namespace.getName();
@@ -204,5 +323,15 @@
 		
 		return null;
 	}
+    
+    /**
+     * Returns the namespace prefix of this attr node
+     * @see org.w3c.dom.Node#getPrefix()
+     */
+    public String getPrefix()
+    {
+    	//TODO Error checking
+        return (this.namespace == null)?null:this.namespace.getPrefix();
+    }
 
 }

Modified: webservices/axis2/trunk/java/modules/xml/src/org/apache/axis2/om/impl/dom/AttributeMap.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/xml/src/org/apache/axis2/om/impl/dom/AttributeMap.java?rev=326556&r1=326555&r2=326556&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/xml/src/org/apache/axis2/om/impl/dom/AttributeMap.java (original)
+++ webservices/axis2/trunk/java/modules/xml/src/org/apache/axis2/om/impl/dom/AttributeMap.java Wed Oct 19 06:39:44 2005
@@ -78,7 +78,7 @@
         }
         
         
-        attr.ownerNode = (DocumentImpl)this.ownerNode.getOwnerDocument(); //Set the owner node
+        attr.parent = (DocumentImpl)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 
         
@@ -88,7 +88,7 @@
         if (i >= 0) { //There's an attribute already with this attr's name
             previous = (AttrImpl) nodes.elementAt(i);
             nodes.setElementAt(attr,i);
-            previous.ownerNode = (DocumentImpl)this.ownerNode.getOwnerDocument();
+            previous.parent = (DocumentImpl)this.ownerNode;
             previous.isOwned(false);
             
             // make sure it won't be mistaken with defaults in case it's reused

Added: webservices/axis2/trunk/java/modules/xml/src/org/apache/axis2/om/impl/dom/DOMImplementationImpl.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/xml/src/org/apache/axis2/om/impl/dom/DOMImplementationImpl.java?rev=326556&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/xml/src/org/apache/axis2/om/impl/dom/DOMImplementationImpl.java (added)
+++ webservices/axis2/trunk/java/modules/xml/src/org/apache/axis2/om/impl/dom/DOMImplementationImpl.java Wed Oct 19 06:39:44 2005
@@ -0,0 +1,46 @@
+/*
+ * Copyright 2004,2005 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.axis2.om.impl.dom;
+
+import org.w3c.dom.DOMException;
+import org.w3c.dom.DOMImplementation;
+import org.w3c.dom.Document;
+import org.w3c.dom.DocumentType;
+
+public class DOMImplementationImpl implements DOMImplementation {
+
+	public boolean hasFeature(String arg0, String arg1) {
+		// TODO 
+		throw new UnsupportedOperationException("TODO");
+	}
+
+	public Document createDocument(String namespaceURI, String qualifiedName, DocumentType doctype)
+			throws DOMException {
+		//TODO Handle docType stuff
+		DocumentImpl doc = new DocumentImpl();
+		
+		ElementImpl elem = new ElementImpl(doc,DOMUtil.getLocalName(qualifiedName),new NamespaceImpl(namespaceURI, DOMUtil.getPrefix(qualifiedName)));
+		
+		return doc;
+	}
+
+	public DocumentType createDocumentType(String qualifiedName, String publicId, 
+			String systemId) throws DOMException {
+		// TODO 
+		throw new UnsupportedOperationException("TODO");
+	}
+
+}

Modified: webservices/axis2/trunk/java/modules/xml/src/org/apache/axis2/om/impl/dom/DocumentImpl.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/xml/src/org/apache/axis2/om/impl/dom/DocumentImpl.java?rev=326556&r1=326555&r2=326556&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/xml/src/org/apache/axis2/om/impl/dom/DocumentImpl.java (original)
+++ webservices/axis2/trunk/java/modules/xml/src/org/apache/axis2/om/impl/dom/DocumentImpl.java Wed Oct 19 06:39:44 2005
@@ -125,9 +125,11 @@
 		return new AttrImpl(this,name);
 	}
 	
-	public Attr createAttributeNS(String namespaceURI, String qualifiedName) throws DOMException {
-		//TODO
-		throw new UnsupportedOperationException("TODO");
+	public Attr createAttributeNS(String namespaceURI, String qualifiedName)
+			throws DOMException {
+		return new AttrImpl(this, DOMUtil.getLocalName(qualifiedName),
+				new NamespaceImpl(namespaceURI, DOMUtil
+						.getPrefix(qualifiedName)));
 	}
 	
 	public CDATASection createCDATASection(String arg0) throws DOMException {
@@ -171,10 +173,7 @@
 		//TODO
 		throw new UnsupportedOperationException("TODO");
 	}
-	public Element getDocumentElement() {
-		//TODO
-		throw new UnsupportedOperationException("TODO");
-	}
+	
 	public Element getElementById(String arg0) {
 		//TODO
 		throw new UnsupportedOperationException("TODO");
@@ -258,10 +257,25 @@
 		//TODO
 		throw new UnsupportedOperationException("TODO");
 	}
-
+	
+	/**
+	 * Returns the document element
+	 * @see org.apache.axis2.om.OMDocument#getOMDocumentElement()
+	 */
 	public OMElement getOMDocumentElement() {
-		// TODO Auto-generated method stub
-		return null;
+		/*
+		 * We'r sure that only an element can be the first child 
+		 * of a Document
+		 */
+		return (OMElement)this.firstChild;
+	}
+	
+	/**
+	 * Returns the document element
+	 * @see org.w3c.dom.Document#getDocumentElement()
+	 */
+	public Element getDocumentElement() {
+		return (Element)this.firstChild;
 	}
 	
 	

Modified: webservices/axis2/trunk/java/modules/xml/src/org/apache/axis2/om/impl/dom/ElementImpl.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/xml/src/org/apache/axis2/om/impl/dom/ElementImpl.java?rev=326556&r1=326555&r2=326556&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/xml/src/org/apache/axis2/om/impl/dom/ElementImpl.java (original)
+++ webservices/axis2/trunk/java/modules/xml/src/org/apache/axis2/om/impl/dom/ElementImpl.java Wed Oct 19 06:39:44 2005
@@ -58,6 +58,8 @@
 	 */
 	public ElementImpl(DocumentImpl ownerDocument, String tagName) {
 		super(ownerDocument);
+		if(ownerDocument.firstChild == null)
+			ownerDocument.firstChild = this;
 		this.tagName = tagName;
 	}
 	
@@ -732,7 +734,7 @@
             throw new UnsupportedOperationException(
                     "This element was not created in a manner to be switched");
         }
-        if (builder.isCompleted() && !cache) {
+        if (builder != null && builder.isCompleted() && !cache) {
             throw new UnsupportedOperationException(
                     "The parser is already consumed!");
         }
@@ -784,9 +786,35 @@
         throw new UnsupportedOperationException("TODO");
 	}
 	
+	/**
+	 * Returns the local name of this element node
+	 * @see org.w3c.dom.Node#getLocalName()
+	 */
     public String getLocalName()
     {
         return this.tagName; 
     }
+    
+    /**
+     * returns the namespace prefix of this element node
+     * @see org.w3c.dom.Node#getPrefix()
+     */
+    public String getPrefix()
+    {
+    	//TODO Error checking
+        return (this.namespace == null)?null:this.namespace.getPrefix();
+    }
+
+	/**
+	 * @see org.apache.axis2.om.impl.dom.NodeImpl#setOwnerDocument(org.apache.axis2.om.impl.dom.DocumentImpl)
+	 */
+	protected void setOwnerDocument(DocumentImpl document) {
+		this.ownerNode = document;
+		this.isOwned(true);
+		if(document.firstChild == null)
+			document.firstChild = this;
+	}
+    
+    
 
 }

Added: webservices/axis2/trunk/java/modules/xml/src/org/apache/axis2/om/impl/dom/jaxp/DocumentBuilderFactoryImpl.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/xml/src/org/apache/axis2/om/impl/dom/jaxp/DocumentBuilderFactoryImpl.java?rev=326556&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/xml/src/org/apache/axis2/om/impl/dom/jaxp/DocumentBuilderFactoryImpl.java (added)
+++ webservices/axis2/trunk/java/modules/xml/src/org/apache/axis2/om/impl/dom/jaxp/DocumentBuilderFactoryImpl.java Wed Oct 19 06:39:44 2005
@@ -0,0 +1,27 @@
+package org.apache.axis2.om.impl.dom.jaxp;
+
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.ParserConfigurationException;
+
+public class DocumentBuilderFactoryImpl extends DocumentBuilderFactory{
+
+	public DocumentBuilderFactoryImpl() {
+		super();
+	}
+
+	public DocumentBuilder newDocumentBuilder() throws ParserConfigurationException {
+		return new DocumentBuilderImpl();
+	}
+
+	public Object getAttribute(String arg0) throws IllegalArgumentException {
+		// TODO 
+		throw new UnsupportedOperationException("TODO");
+	}
+
+	public void setAttribute(String arg0, Object arg1) throws IllegalArgumentException {
+		// TODO 
+		throw new UnsupportedOperationException("TODO");
+	}
+
+}

Added: webservices/axis2/trunk/java/modules/xml/src/org/apache/axis2/om/impl/dom/jaxp/DocumentBuilderImpl.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/xml/src/org/apache/axis2/om/impl/dom/jaxp/DocumentBuilderImpl.java?rev=326556&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/xml/src/org/apache/axis2/om/impl/dom/jaxp/DocumentBuilderImpl.java (added)
+++ webservices/axis2/trunk/java/modules/xml/src/org/apache/axis2/om/impl/dom/jaxp/DocumentBuilderImpl.java Wed Oct 19 06:39:44 2005
@@ -0,0 +1,140 @@
+/*
+ * Copyright 2004,2005 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.axis2.om.impl.dom.jaxp;
+
+import org.apache.axis2.om.impl.dom.DOMImplementationImpl;
+import org.apache.axis2.om.impl.dom.DocumentImpl;
+import org.apache.axis2.om.impl.dom.factory.OMDOMFactory;
+import org.apache.axis2.om.impl.llom.builder.StAXOMBuilder;
+import org.w3c.dom.DOMImplementation;
+import org.w3c.dom.Document;
+import org.xml.sax.EntityResolver;
+import org.xml.sax.ErrorHandler;
+import org.xml.sax.InputSource;
+import org.xml.sax.SAXException;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+
+public class DocumentBuilderImpl extends DocumentBuilder {
+
+	public DocumentBuilderImpl() {
+		super();
+	}
+
+	/**
+	 * Returns whether the parser is configured to understand namespaces or not
+	 * The StAX parser used by this DOM impl is namespace aware
+	 * therefore this will always return true
+	 * @see javax.xml.parsers.DocumentBuilder#isNamespaceAware()
+	 */
+	public boolean isNamespaceAware() {
+		return true;
+	}
+
+	/**
+	 * The StAX builder used is the org.apache.axis2.om.impl.llom.StAXOMBuilder
+	 * is a validating builder
+	 * @see javax.xml.parsers.DocumentBuilder#isValidating()
+	 */
+	public boolean isValidating() {
+		return true;
+	}
+
+	public DOMImplementation getDOMImplementation() {
+		return new DOMImplementationImpl();
+	}
+
+	public Document newDocument() {
+		return new DocumentImpl();
+	}
+
+	public void setEntityResolver(EntityResolver arg0) {
+		// TODO 
+		throw new UnsupportedOperationException("TODO");
+	}
+
+	public void setErrorHandler(ErrorHandler arg0) {
+		// TODO 
+		throw new UnsupportedOperationException("TODO");
+	}
+
+	public Document parse(InputSource inputSource) throws SAXException, IOException {
+		try {
+			OMDOMFactory factory = new OMDOMFactory();
+			//Not really sure whether this will work :-?
+			XMLStreamReader reader = XMLInputFactory.newInstance().createXMLStreamReader(inputSource.getByteStream());
+			StAXOMBuilder builder = new StAXOMBuilder(factory,reader);
+			return (DocumentImpl)builder.getDocument();
+		}catch (XMLStreamException e) {
+			throw new SAXException(e);
+		} 
+	}
+	
+	/**
+	 * @see javax.xml.parsers.DocumentBuilder#parse(java.io.InputStream)
+	 */
+	public Document parse(InputStream is) throws SAXException, IOException {
+		try {
+			OMDOMFactory factory = new OMDOMFactory();
+			XMLStreamReader reader = XMLInputFactory.newInstance().createXMLStreamReader(is);
+			StAXOMBuilder builder = new StAXOMBuilder(factory,reader);
+			return (DocumentImpl)builder.getDocument();
+		}catch (XMLStreamException e) {
+			throw new SAXException(e);
+		} 
+	}
+
+	/**
+	 * @see javax.xml.parsers.DocumentBuilder#parse(java.io.File)
+	 */
+	public Document parse(File file) throws SAXException, IOException {
+		try {
+			OMDOMFactory factory = new OMDOMFactory();
+			XMLStreamReader reader = XMLInputFactory.newInstance().createXMLStreamReader(new FileInputStream(file));
+			StAXOMBuilder builder = new StAXOMBuilder(factory,reader);
+			return (DocumentImpl)builder.getDocument();
+		}catch (XMLStreamException e) {
+			throw new SAXException(e);
+		} 
+	}
+
+	/**
+	 * @see javax.xml.parsers.DocumentBuilder#parse(java.io.InputStream, java.lang.String)
+	 */
+	public Document parse(InputStream is, String systemId) throws SAXException, IOException {
+		// TODO 
+		throw new UnsupportedOperationException("TODO");
+	}
+
+	/**
+	 * @see javax.xml.parsers.DocumentBuilder#parse(java.lang.String)
+	 */
+	public Document parse(String uri) throws SAXException, IOException {
+		// TODO 
+		throw new UnsupportedOperationException("TODO");
+	}
+
+	
+	
+}

Modified: webservices/axis2/trunk/java/modules/xml/test/org/apache/axis2/om/impl/dom/DocumentImplTest.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/xml/test/org/apache/axis2/om/impl/dom/DocumentImplTest.java?rev=326556&r1=326555&r2=326556&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/xml/test/org/apache/axis2/om/impl/dom/DocumentImplTest.java (original)
+++ webservices/axis2/trunk/java/modules/xml/test/org/apache/axis2/om/impl/dom/DocumentImplTest.java Wed Oct 19 06:39:44 2005
@@ -22,9 +22,6 @@
 
 public class DocumentImplTest extends TestCase {
 
-	
-
-	
 	public DocumentImplTest() {
 		super();
 	}
@@ -50,6 +47,8 @@
 	public void testCreateAttribute() {
 		String attrName = "attrIdentifier";
 		String attrValue = "attrValue";
+		String attrNs = "http://ws.apache.org/axis2/ns";
+		String attrNsPrefix = "axis2";
 		
 		DocumentImpl doc = new DocumentImpl();
 		Attr attr = doc.createAttribute(attrName);
@@ -57,7 +56,18 @@
 		assertEquals("Attr name mismatch",attrName,attr.getLocalName());
 		assertNull("Namespace value should be null", attr.getNamespaceURI());
 		
+		
+		attr = doc.createAttributeNS(attrNs,attrNsPrefix + ":" + attrName);
+		assertEquals("Attr name mismatch",attrName,attr.getLocalName());
+		assertNotNull("Namespace value should not be null", attr.getNamespaceURI());
+		assertEquals("NamsspaceURI mismatch", attrNs, attr.getNamespaceURI());
+		assertEquals("namespace prefix mismatch", attrNsPrefix, attr.getPrefix());
+		
 		attr.setValue(attrValue);
+		
+	}
+	
+	public void testCreateText() {
 		
 	}
 



Re: [Axis2] svn commit: r326556 - in /webservices/axis2/trunk/java/modules/xml: src/org/apache/axis2/om/impl/dom/ src/org/apache/axis2/om/impl/dom/jaxp/ test/org/apache/axis2/om/impl/dom/

Posted by Ruchith Fernando <ru...@gmail.com>.
On 10/19/05, Eran Chinthaka <ch...@opensource.lk> wrote:
>  Sorry, the name cofused me. DomImplementation is an interface, right ?
>
Yep it is :)
http://java.sun.com/j2se/1.4.2/docs/api/org/w3c/dom/DOMImplementation.html

>  Seems like Axis2 is not the only place that has naming issues. ;-)
>
>
>
>
>  Ruchith Fernando wrote:
>  It is the implementation of org.w3c.dom.DOMImplementation
>
> On 10/19/05, Eran Chinthaka <ch...@opensource.lk> wrote:
>
>
>  ruchithf@apache.org wrote:
>
>
>
> webservices/axis2/trunk/java/modules/xml/src/org/apache/axis2/om/impl/dom/DOMImplementationImpl.java
>
>
>
>
>  The name DomImplementationImpl seems bit weird for me. What does that
> mean ? DomImplementationImplementation ??
>
> Sorry, if I'm missing something here ...
>
> -- EC
>
>
>
>
> --
> Ruchith
>
>
>
>


--
Ruchith

Re: [Axis2] svn commit: r326556 - in /webservices/axis2/trunk/java/modules/xml: src/org/apache/axis2/om/impl/dom/ src/org/apache/axis2/om/impl/dom/jaxp/ test/org/apache/axis2/om/impl/dom/

Posted by Eran Chinthaka <ch...@opensource.lk>.
Sorry, the name cofused me. DomImplementation is an interface, right ?

Seems like Axis2 is not the only place that has naming issues. ;-)



Ruchith Fernando wrote:

>It is the implementation of org.w3c.dom.DOMImplementation
>
>On 10/19/05, Eran Chinthaka <ch...@opensource.lk> wrote:
>  
>
>>ruchithf@apache.org wrote:
>>
>>    
>>
>>>   webservices/axis2/trunk/java/modules/xml/src/org/apache/axis2/om/impl/dom/DOMImplementationImpl.java
>>>
>>>
>>>
>>>      
>>>
>>The name DomImplementationImpl seems bit weird for me. What does that
>>mean ? DomImplementationImplementation ??
>>
>>Sorry, if I'm missing something here ...
>>
>>-- EC
>>
>>
>>    
>>
>
>
>--
>Ruchith
>
>
>  
>

Re: [Axis2] svn commit: r326556 - in /webservices/axis2/trunk/java/modules/xml: src/org/apache/axis2/om/impl/dom/ src/org/apache/axis2/om/impl/dom/jaxp/ test/org/apache/axis2/om/impl/dom/

Posted by Ruchith Fernando <ru...@gmail.com>.
It is the implementation of org.w3c.dom.DOMImplementation

On 10/19/05, Eran Chinthaka <ch...@opensource.lk> wrote:
>
>
> ruchithf@apache.org wrote:
>
> >    webservices/axis2/trunk/java/modules/xml/src/org/apache/axis2/om/impl/dom/DOMImplementationImpl.java
> >
> >
> >
> The name DomImplementationImpl seems bit weird for me. What does that
> mean ? DomImplementationImplementation ??
>
> Sorry, if I'm missing something here ...
>
> -- EC
>
>


--
Ruchith

Re:[Axis2] svn commit: r326556 - in /webservices/axis2/trunk/java/modules/xml: src/org/apache/axis2/om/impl/dom/ src/org/apache/axis2/om/impl/dom/jaxp/ test/org/apache/axis2/om/impl/dom/

Posted by Eran Chinthaka <ch...@opensource.lk>.

ruchithf@apache.org wrote:

>    webservices/axis2/trunk/java/modules/xml/src/org/apache/axis2/om/impl/dom/DOMImplementationImpl.java
>    
>  
>
The name DomImplementationImpl seems bit weird for me. What does that
mean ? DomImplementationImplementation ??

Sorry, if I'm missing something here ...

-- EC