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 he...@apache.org on 2004/09/27 09:08:10 UTC

svn commit: rev 47277 - in webservices/axis/trunk/java/dev/scratch/dasarath: . om om/src om/src/java om/src/java/org om/src/java/org/apache om/src/java/org/apache/axis om/src/java/org/apache/axis/om om/src/test om/src/test-resources om/src/test/org om/src/test/org/apache om/src/test/org/apache/axis om/src/test/org/apache/axis/om

Author: hemapani
Date: Mon Sep 27 00:08:10 2004
New Revision: 47277

Added:
   webservices/axis/trunk/java/dev/scratch/dasarath/
   webservices/axis/trunk/java/dev/scratch/dasarath/om/
   webservices/axis/trunk/java/dev/scratch/dasarath/om/src/
   webservices/axis/trunk/java/dev/scratch/dasarath/om/src/java/
   webservices/axis/trunk/java/dev/scratch/dasarath/om/src/java/org/
   webservices/axis/trunk/java/dev/scratch/dasarath/om/src/java/org/apache/
   webservices/axis/trunk/java/dev/scratch/dasarath/om/src/java/org/apache/axis/
   webservices/axis/trunk/java/dev/scratch/dasarath/om/src/java/org/apache/axis/om/
   webservices/axis/trunk/java/dev/scratch/dasarath/om/src/java/org/apache/axis/om/OMAttribute.java
   webservices/axis/trunk/java/dev/scratch/dasarath/om/src/java/org/apache/axis/om/OMElement.java
   webservices/axis/trunk/java/dev/scratch/dasarath/om/src/java/org/apache/axis/om/OMException.java
   webservices/axis/trunk/java/dev/scratch/dasarath/om/src/java/org/apache/axis/om/OMNamedNode.java
   webservices/axis/trunk/java/dev/scratch/dasarath/om/src/java/org/apache/axis/om/OMNamespace.java
   webservices/axis/trunk/java/dev/scratch/dasarath/om/src/java/org/apache/axis/om/OMNavigator.java
   webservices/axis/trunk/java/dev/scratch/dasarath/om/src/java/org/apache/axis/om/OMNode.java
   webservices/axis/trunk/java/dev/scratch/dasarath/om/src/java/org/apache/axis/om/OMNodeImpl.java
   webservices/axis/trunk/java/dev/scratch/dasarath/om/src/java/org/apache/axis/om/OMText.java
   webservices/axis/trunk/java/dev/scratch/dasarath/om/src/java/org/apache/axis/om/OMXmlPullParserWrapper.java
   webservices/axis/trunk/java/dev/scratch/dasarath/om/src/test/
   webservices/axis/trunk/java/dev/scratch/dasarath/om/src/test-resources/
   webservices/axis/trunk/java/dev/scratch/dasarath/om/src/test-resources/soapmessage.xml
   webservices/axis/trunk/java/dev/scratch/dasarath/om/src/test-resources/soapmessage1.xml
   webservices/axis/trunk/java/dev/scratch/dasarath/om/src/test-resources/testFile.xml
   webservices/axis/trunk/java/dev/scratch/dasarath/om/src/test-resources/tester-out.xml
   webservices/axis/trunk/java/dev/scratch/dasarath/om/src/test/org/
   webservices/axis/trunk/java/dev/scratch/dasarath/om/src/test/org/apache/
   webservices/axis/trunk/java/dev/scratch/dasarath/om/src/test/org/apache/axis/
   webservices/axis/trunk/java/dev/scratch/dasarath/om/src/test/org/apache/axis/om/
   webservices/axis/trunk/java/dev/scratch/dasarath/om/src/test/org/apache/axis/om/Tester.java
Log:
check in the Dasarath's OM on behalf of Dasarath

Added: webservices/axis/trunk/java/dev/scratch/dasarath/om/src/java/org/apache/axis/om/OMAttribute.java
==============================================================================
--- (empty file)
+++ webservices/axis/trunk/java/dev/scratch/dasarath/om/src/java/org/apache/axis/om/OMAttribute.java	Mon Sep 27 00:08:10 2004
@@ -0,0 +1,76 @@
+/*
+ * Copyright  2004 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.
+ *
+ */
+
+/*
+ * Created on Sep 25, 2004
+ *
+ */
+package org.apache.axis.om;
+
+import java.io.PrintStream;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+/**
+ * @author Dasarath Weeratunge
+ *
+ */
+public class OMAttribute extends OMNamedNode {
+	private static String QUOTE_ENTITY= """;
+	private static Matcher matcher= Pattern.compile("\"").matcher(null);
+
+	public OMAttribute(String localName, OMNamespace ns, String value) {
+		super(localName, ns, null);
+		setValue(value);
+	}
+	
+	public OMAttribute(String localName, OMNamespace ns, String value, OMElement parent) {
+		super(localName, ns, parent);
+		setValue(value);
+	}
+
+	synchronized static String replaceQuoteWithEntity(String value) {
+		matcher.reset(value);
+		return matcher.replaceAll(QUOTE_ENTITY);
+	}
+
+	public void print(PrintStream s) throws OMException {
+		super.print(s);
+		s.print('=');
+		String v= value;
+		char quote= '"';
+		if (value.indexOf('"') != -1)
+			if (value.indexOf('\'') == -1)
+				quote= '\'';
+			else
+				v= replaceQuoteWithEntity(value);
+		s.print(quote);
+		s.print(v);
+		s.print(quote);
+	}
+
+	public void detach() throws OMException {
+		if (parent == null)
+			throw new OMException();
+		if (prevSibling == null)
+			parent.setFirstAttribute((OMAttribute)nextSibling);
+		else
+			prevSibling.setNextSibling(nextSibling);
+		if (nextSibling != null)
+			nextSibling.setPrevSibling(prevSibling);
+	}
+}

Added: webservices/axis/trunk/java/dev/scratch/dasarath/om/src/java/org/apache/axis/om/OMElement.java
==============================================================================
--- (empty file)
+++ webservices/axis/trunk/java/dev/scratch/dasarath/om/src/java/org/apache/axis/om/OMElement.java	Mon Sep 27 00:08:10 2004
@@ -0,0 +1,163 @@
+/*
+ * Copyright  2004 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.
+ *
+ */
+/*
+ * Created on Sep 24, 2004
+ *
+ */
+package org.apache.axis.om;
+
+import org.apache.axis.om.OMAttribute;
+
+import java.io.PrintStream;
+
+/**
+ * @author Dasarath Weeratunge
+ *
+ */
+public class OMElement extends OMNamedNode {
+	OMXmlPullParserWrapper builder;
+	boolean complete= false;
+	OMNode firstChild;
+	OMAttribute firstAttribute;
+	OMNamespace firstNamespace;
+
+	public OMElement(String localName, OMNamespace ns) {
+		super(localName, ns, null);
+		complete= true;
+	}
+
+	public OMElement(String localName, OMNamespace ns, OMElement parent, OMXmlPullParserWrapper builder) {
+		super(localName, ns, parent);
+		this.builder= builder;
+	}
+
+	public void setFirstChild(OMNode node) throws OMException {
+		firstChild= node;
+	}
+
+	public void complete() {
+		this.complete= true;
+	}
+
+	public boolean isComplete() {
+		return complete;
+	}
+
+	protected void buildNext() throws OMException {
+		builder.next();
+	}
+
+	public void print(PrintStream s) throws OMException {
+		s.print('<');
+		super.print(s);
+
+		OMNode node= firstAttribute;
+		while (node != null) {
+			s.print(" ");
+			node.print(s);
+			node= node.getNextSibling();
+		}
+
+		node= firstNamespace;
+		while (node != null) {
+			s.print(" ");
+			node.print(s);
+			node= node.getNextSibling();		
+		}
+
+		node= getFirstChild();
+		if (node != null) {
+			s.print('>');
+			while (node != null) {
+				node.print(s);
+				node= node.getNextSibling();
+			}
+			s.print('<');
+			s.print('/');
+			super.print(s);
+		}
+		else
+			s.print('/');
+		s.print('>');
+	}
+
+	public OMNode getFirstChild() throws OMException {
+		if (firstChild == null && !complete)
+			buildNext();
+		return firstChild;
+	}
+
+	public void detach() throws OMException {
+		if (complete)
+			super.detach();
+		else
+			builder.discard(this);
+	}
+
+	public void insertChild(OMNode child) throws OMException {
+		if (firstChild == null && !complete)
+			builder.next();
+		child.setPrevSibling(null);
+		child.setNextSibling(firstChild);
+		if (firstChild != null)
+			firstChild.setPrevSibling(child);
+		child.setParent(this);
+		firstChild= child;
+	}
+
+	public OMNode getNextSibling() throws OMException {
+		while (!complete)
+			builder.next();
+		return super.getNextSibling();
+	}
+
+	public OMAttribute getFirstAttribute() {
+		return firstAttribute;
+	}
+
+	public void setFirstAttribute(OMAttribute attr) {
+		firstAttribute= attr;
+	}
+
+	public void insertAttribute(OMAttribute attr) {
+		attr.setPrevSibling(null);
+		attr.setNextSibling(firstAttribute);
+		if (firstAttribute != null)
+			firstAttribute.setPrevSibling(attr);
+		attr.setParent(this);
+		firstAttribute= attr;
+	}
+
+	public OMNamespace createNamespace(String uri, String prefix) {
+		OMNamespace ns= new OMNamespace(uri, prefix);
+		ns.setNextSibling(firstNamespace);
+		firstNamespace= ns;
+		return ns;
+	}
+
+	public OMNamespace resolveNamespace(String uri, String prefix) throws OMException {
+		OMNamespace ns= firstNamespace;
+		while (ns != null) {
+			if (ns.equals(uri, prefix))
+				return ns;
+			ns= (OMNamespace)ns.getNextSibling();
+		}
+		if (parent != null)
+			return parent.resolveNamespace(uri, prefix);
+		return null;
+	}
+}

Added: webservices/axis/trunk/java/dev/scratch/dasarath/om/src/java/org/apache/axis/om/OMException.java
==============================================================================
--- (empty file)
+++ webservices/axis/trunk/java/dev/scratch/dasarath/om/src/java/org/apache/axis/om/OMException.java	Mon Sep 27 00:08:10 2004
@@ -0,0 +1,46 @@
+/*
+ * Copyright  2004 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.
+ *
+ */
+
+/*
+ * Created on Sep 24, 2004
+ *
+ */
+package org.apache.axis.om;
+
+/**
+ * @author Dasarath Weeratunge
+ *
+ */
+public class OMException extends Exception {
+
+	public OMException() {
+		super();
+	}
+
+	public OMException(String arg0) {
+		super(arg0);
+	}
+
+	public OMException(String arg0, Throwable arg1) {
+		super(arg0, arg1);
+	}
+
+	public OMException(Throwable arg0) {
+		super(arg0);
+	}
+	
+}

Added: webservices/axis/trunk/java/dev/scratch/dasarath/om/src/java/org/apache/axis/om/OMNamedNode.java
==============================================================================
--- (empty file)
+++ webservices/axis/trunk/java/dev/scratch/dasarath/om/src/java/org/apache/axis/om/OMNamedNode.java	Mon Sep 27 00:08:10 2004
@@ -0,0 +1,68 @@
+/*
+ * Copyright  2004 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.
+ *
+ */
+
+/*
+ * Created on Sep 24, 2004
+ *
+ */
+package org.apache.axis.om;
+
+import org.apache.axis.om.OMElement;
+import org.apache.axis.om.OMException;
+
+import java.io.PrintStream;
+
+/**
+ * @author Dasarath Weeratunge
+ *
+ */
+public abstract class OMNamedNode extends OMNodeImpl {
+	OMNamespace ns;
+	String localName;
+
+	public OMNamedNode(String localName, OMNamespace ns) {
+		super();
+		this.localName= localName;
+		this.ns= ns;
+	}
+
+	public OMNamedNode(String localName, OMNamespace ns, OMElement parent) {
+		super(parent);
+		this.localName= localName;
+		this.ns= ns;
+	}
+
+	public String getLocalName() {
+		return localName;
+	}
+
+	public OMNamespace getNamespace() {
+		return ns;
+	}
+	
+	protected void setNamespace(OMNamespace ns) {
+		this.ns= ns;
+	}	
+
+	public void print(PrintStream s) throws OMException {
+		if (ns != null && !ns.isDefaultNs()) {
+			s.print(ns.getPrefix());
+			s.print(':');
+		}
+		s.print(localName);
+	}
+}

Added: webservices/axis/trunk/java/dev/scratch/dasarath/om/src/java/org/apache/axis/om/OMNamespace.java
==============================================================================
--- (empty file)
+++ webservices/axis/trunk/java/dev/scratch/dasarath/om/src/java/org/apache/axis/om/OMNamespace.java	Mon Sep 27 00:08:10 2004
@@ -0,0 +1,73 @@
+/*
+ * Copyright  2004 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.
+ *
+ */
+
+/*
+ * Created on Sep 26, 2004
+ *
+ */
+package org.apache.axis.om;
+
+import org.apache.axis.om.OMException;
+
+import java.io.PrintStream;
+
+/**
+ * @author Dasarath Weeratunge
+ *
+ */
+public class OMNamespace extends OMNodeImpl {
+	String prefix;
+
+	protected OMNamespace(String uri, String prefix) {
+		value= uri;
+		this.prefix= prefix;
+	}
+
+	public boolean equals(OMNamespace ns) {
+		return ((prefix == null && ns.prefix == null) || (prefix != null && prefix.equals(ns.prefix)))
+			&& value.equals(ns.value);
+	}
+
+	public boolean equals(String uri, String prefix) {
+		return ((prefix == null && this.prefix == null) || (prefix != null && prefix.equals(this.prefix)))
+			&& value.equals(uri);
+	}
+
+	public void print(PrintStream s) {
+		s.print("xmlns");
+		if (prefix != null) {
+			s.print(':');
+			s.print(prefix);
+		}
+		s.print('=');
+		s.print('"');
+		s.print(value);
+		s.print('"');
+	}
+
+	public boolean isDefaultNs() {
+		return prefix == null;
+	}
+
+	public String getPrefix() {
+		return prefix;
+	}
+
+	public OMNode getNextSibling() throws OMException {
+		return nextSibling;
+	}
+}

Added: webservices/axis/trunk/java/dev/scratch/dasarath/om/src/java/org/apache/axis/om/OMNavigator.java
==============================================================================
--- (empty file)
+++ webservices/axis/trunk/java/dev/scratch/dasarath/om/src/java/org/apache/axis/om/OMNavigator.java	Mon Sep 27 00:08:10 2004
@@ -0,0 +1,80 @@
+/*
+ * Copyright  2004 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.
+ *
+ */
+
+/*
+ * Created on Sep 25, 2004
+ *
+ */
+package org.apache.axis.om;
+
+import org.apache.axis.om.OMElement;
+
+/**
+ * @author Dasarath Weeratunge
+ *
+ */
+public class OMNavigator {
+	protected OMNode node;
+	private boolean visited;
+	private OMNode next;
+	private boolean backtracked;
+
+	public OMNavigator() {}
+
+	public OMNavigator(OMNode node) {
+		init(node);
+	}
+
+	public void init(OMNode node) {
+		next= node;
+		backtracked= false;
+	}
+
+	public OMNode next() {
+		if (next == null)
+			return null;
+		node= next;
+		visited= backtracked;
+		backtracked= false;
+		if (next instanceof OMElement && !visited) {
+			OMElement e= (OMElement)next;
+			if (e.firstChild != null)
+				next= e.firstChild;
+			else
+				if (e.complete)
+					backtracked= true;
+				else
+					next= null;
+			return node;
+		}
+		OMNodeImpl n= (OMNodeImpl)next;
+		if (n.nextSibling != null)
+			next= n.nextSibling;
+		else
+			if (n.parent != null && n.parent.complete) {
+				next= n.parent;
+				backtracked= true;
+			}
+			else
+				next= null;
+		return node;
+	}
+
+	public boolean visited() {
+		return visited;
+	}
+}

Added: webservices/axis/trunk/java/dev/scratch/dasarath/om/src/java/org/apache/axis/om/OMNode.java
==============================================================================
--- (empty file)
+++ webservices/axis/trunk/java/dev/scratch/dasarath/om/src/java/org/apache/axis/om/OMNode.java	Mon Sep 27 00:08:10 2004
@@ -0,0 +1,45 @@
+/*
+ * Copyright  2004 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.
+ *
+ */
+
+/*
+ * Created on Sep 24, 2004
+ *
+ */
+package org.apache.axis.om;
+
+import org.apache.axis.om.OMElement;
+import org.apache.axis.om.OMException;
+
+import java.io.PrintStream;
+
+/**
+ * @author Dasarath Weeratunge
+ *
+ */
+public interface OMNode {
+	OMElement getParent() throws OMException;
+	void setParent(OMElement element);
+	OMNode getNextSibling() throws OMException;
+	void setNextSibling(OMNode node);
+	OMNode getPrevSibling();
+	void setPrevSibling(OMNode node);
+	String getValue() throws OMException;
+	void setValue(String value);
+	boolean isComplete();
+	void print(PrintStream s) throws OMException;
+	void detach() throws OMException;
+}

Added: webservices/axis/trunk/java/dev/scratch/dasarath/om/src/java/org/apache/axis/om/OMNodeImpl.java
==============================================================================
--- (empty file)
+++ webservices/axis/trunk/java/dev/scratch/dasarath/om/src/java/org/apache/axis/om/OMNodeImpl.java	Mon Sep 27 00:08:10 2004
@@ -0,0 +1,120 @@
+/*
+ * Copyright  2004 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.
+ *
+ */
+
+/*
+ * Created on Sep 24, 2004
+ *
+ */
+package org.apache.axis.om;
+
+import org.apache.axis.om.OMElement;
+import org.apache.axis.om.OMException;
+import org.apache.axis.om.OMNode;
+
+/**
+ * @author Dasarath Weeratunge
+ *
+ */
+public abstract class OMNodeImpl implements OMNode {
+	protected OMElement parent;
+	protected OMNode nextSibling;
+	protected OMNode prevSibling;
+	protected String value;
+	
+	protected OMNodeImpl(){
+	}
+	
+	protected OMNodeImpl(OMElement parent) {
+		this.parent= parent;
+	}
+
+	public OMElement getParent() throws OMException {
+		return parent;
+	}
+
+	public OMNode getNextSibling() throws OMException {
+		if (nextSibling == null && !parent.isComplete())
+			parent.buildNext();
+		return nextSibling;
+	}
+
+	public void setNextSibling(OMNode node) {
+		nextSibling= node;
+	}
+
+	public String getValue() throws OMException {
+		return value;
+	}
+
+	public void setValue(String value) {
+		this.value= value;
+	}
+
+	public boolean isComplete() {
+		return true;
+	}
+
+	public void setParent(OMElement element) {
+		parent= element;
+	}
+
+	public OMNode getPrevSibling() {
+		return prevSibling;
+	}
+
+	public void setPrevSibling(OMNode node) {
+		prevSibling= node;
+	}
+
+	public void detach() throws OMException {
+		if (parent == null)
+			throw new OMException();
+		OMNode nextSibling= getNextSibling();
+		if (prevSibling == null)
+			parent.setFirstChild(nextSibling);
+		else
+			prevSibling.setNextSibling(nextSibling);
+		if (nextSibling != null)
+			nextSibling.setPrevSibling(prevSibling);
+	}
+
+	public void insertSiblingAfter(OMNode sibling) throws OMException {
+		if (parent == null)
+			throw new OMException();
+		sibling.setParent(parent);
+		if (nextSibling == null)
+			getNextSibling();
+		sibling.setPrevSibling(this);
+		if (nextSibling != null)
+			nextSibling.setPrevSibling(sibling);
+		sibling.setNextSibling(nextSibling);
+		nextSibling= sibling;
+	}
+
+	public void insertSiblingBefore(OMNode sibling) throws OMException {
+		if (parent == null)
+			throw new OMException();
+		sibling.setParent(parent);
+		sibling.setPrevSibling(prevSibling);
+		sibling.setNextSibling(this);
+		if (prevSibling == null)
+			parent.setFirstChild(sibling);
+		else
+			prevSibling.setNextSibling(sibling);
+		prevSibling= sibling;
+	}
+}

Added: webservices/axis/trunk/java/dev/scratch/dasarath/om/src/java/org/apache/axis/om/OMText.java
==============================================================================
--- (empty file)
+++ webservices/axis/trunk/java/dev/scratch/dasarath/om/src/java/org/apache/axis/om/OMText.java	Mon Sep 27 00:08:10 2004
@@ -0,0 +1,57 @@
+/*
+ * Copyright  2004 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.
+ *
+ */
+
+/*
+ * Created on Sep 24, 2004
+ *
+ */
+package org.apache.axis.om;
+
+import org.apache.axis.om.OMElement;
+import org.apache.axis.om.OMException;
+import org.apache.axis.om.OMNode;
+import org.apache.axis.om.OMNodeImpl;
+
+import java.io.PrintStream;
+
+/**
+ * @author Dasarath Weeratunge
+ *
+ */
+public class OMText extends OMNodeImpl {
+	public OMText(String s){
+		super();
+		setValue(s);
+	}
+
+	public OMText(OMElement parent, String s) {
+		super(parent);
+		setValue(s);
+	}
+
+	public OMNode getFirstChild() throws OMException {
+		throw new OMException();
+	}
+
+	public void setFirstChild(OMNode node) throws OMException {
+		throw new OMException();
+	}
+
+	public void print(PrintStream s) throws OMException {
+		s.print(value);
+	}
+}

Added: webservices/axis/trunk/java/dev/scratch/dasarath/om/src/java/org/apache/axis/om/OMXmlPullParserWrapper.java
==============================================================================
--- (empty file)
+++ webservices/axis/trunk/java/dev/scratch/dasarath/om/src/java/org/apache/axis/om/OMXmlPullParserWrapper.java	Mon Sep 27 00:08:10 2004
@@ -0,0 +1,349 @@
+/*
+ * Copyright  2004 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.
+ *
+ */
+
+/*
+ * Created on Sep 25, 2004
+ *
+ */
+package org.apache.axis.om;
+
+import org.xmlpull.v1.XmlPullParser;
+import org.xmlpull.v1.XmlPullParserException;
+import org.apache.axis.om.*;
+
+/**
+ * @author Dasarath Weeratunge
+ *
+ */
+public class OMXmlPullParserWrapper {
+	private XmlPullParser parser;
+	private OMElement root;
+	private OMNode lastNode;
+	private boolean cache= true;
+	private boolean slip= false;
+	private boolean navigate= false;
+	private boolean done= false;
+	private OMNavigator navigator= new OMNavigator();
+
+	public OMXmlPullParserWrapper(XmlPullParser parser) {
+		this.parser= parser;
+	}
+
+	public OMElement getDocument() throws OMException {
+		if (root == null)
+			next();
+		return root;
+	}
+
+	private OMNode createOMElement() throws OMException {
+		OMElement node;
+		if (lastNode == null) {
+			root= new OMElement(parser.getName(), null, null, this);
+			node= root;
+		}
+		else
+			if (lastNode.isComplete()) {
+				node= new OMElement(parser.getName(), null, lastNode.getParent(), this);
+				lastNode.setNextSibling(node);
+				node.setPrevSibling(lastNode);
+			}
+			else {
+				OMElement e= (OMElement)lastNode;
+				node= new OMElement(parser.getName(), null, (OMElement)lastNode, this);
+				e.setFirstChild(node);
+			}
+
+		int i, j;
+		try {
+			j= parser.getNamespaceCount(parser.getDepth());
+			i= 0;
+			if (j > 1)
+				i= parser.getNamespaceCount(parser.getDepth() - 1);
+			while (i < j) {
+				node.createNamespace(parser.getNamespaceUri(i), parser.getNamespacePrefix(i));
+				i++;
+			}
+		}
+		catch (XmlPullParserException e) {
+			throw new OMException(e);
+		}
+
+		node.setNamespace(node.resolveNamespace(parser.getNamespace(), parser.getPrefix()));
+
+		j= parser.getAttributeCount();
+		for (i= 0; i < j; i++) {
+			OMNamespace ns= null;
+			String uri= parser.getAttributeNamespace(i);
+			if (uri.hashCode() != 0)
+				ns= node.resolveNamespace(uri, parser.getAttributePrefix(i));
+			node.insertAttribute(
+				new OMAttribute(parser.getAttributeName(i), ns, parser.getAttributeValue(i), node));
+		}
+
+		return node;
+	}
+
+	private OMNode createOMText() throws OMException {
+		if (lastNode == null)
+			throw new OMException();
+		OMNode node;
+		if (lastNode.isComplete()) {
+			node= new OMText(lastNode.getParent(), parser.getText());
+			lastNode.setNextSibling(node);
+			node.setPrevSibling(lastNode);
+		}
+		else {
+			OMElement e= (OMElement)lastNode;
+			node= new OMText(e, parser.getText());
+			e.setFirstChild(node);
+		}
+		return node;
+	}
+
+	public void reset(OMNode node) throws OMException {
+		navigate= true;
+		lastNode= null;
+		navigator.init(node);
+	}
+
+	//	TODO:
+	public int next() throws OMException {
+		try {
+			if (navigate) {
+				OMNode next= navigator.next();
+				if (next != null) {
+					lastNode= next;
+					if (lastNode instanceof OMText)
+						return XmlPullParser.TEXT;
+					else
+						if (navigator.visited())
+							return XmlPullParser.END_TAG;
+						else
+							return XmlPullParser.START_TAG;
+				}
+				navigate= false;
+				if (done)
+					return XmlPullParser.END_DOCUMENT;
+				if (slip)
+					throw new OMException();
+			}
+
+			if (done)
+				throw new OMException();
+
+			int token= parser.nextToken();
+
+			if (!cache) {
+				slip= true;
+				return token;
+			}
+
+			switch (token) {
+				case XmlPullParser.START_TAG :
+					lastNode= createOMElement();
+					break;
+
+				case XmlPullParser.TEXT :
+					lastNode= createOMText();
+					break;
+
+				case XmlPullParser.END_TAG :
+					if (lastNode.isComplete()) {
+						OMElement parent= lastNode.getParent();
+						parent.complete();
+						lastNode= parent;
+					}
+					else {
+						OMElement e= (OMElement)lastNode;
+						e.complete();
+					}
+					break;
+
+				case XmlPullParser.END_DOCUMENT :
+					done= true;
+					break;
+
+				default :
+					throw new OMException();
+			}
+			return token;
+		}
+		catch (OMException e) {
+			throw e;
+		}
+		catch (Exception e) {
+			throw new OMException(e);
+		}
+	}
+
+	public void discard(OMElement el) throws OMException {
+		if (el.isComplete() || !cache)
+			throw new OMException();
+		try {
+			cache= false;
+			do {
+				while (parser.next() != XmlPullParser.END_TAG);
+				//	TODO:
+			}
+			while (!parser.getName().equals(el.getLocalName()));
+			lastNode= el.getPrevSibling();
+			if (lastNode != null)
+				lastNode.setNextSibling(null);
+			else {
+				OMElement parent= el.getParent();
+				if (parent == null)
+					throw new OMException();
+				parent.setFirstChild(null);
+				lastNode= parent;
+			}
+			slip= false;
+			cache= true;
+		}
+		catch (OMException e) {
+			throw e;
+		}
+		catch (Exception e) {
+			throw new OMException(e);
+		}
+	}
+
+	public void setCache(boolean b) {
+		cache= b;
+	}
+
+	public String getName() throws OMException {
+		if (navigate) {
+			try {
+				OMElement e= (OMElement)lastNode;
+				return e.getLocalName();
+			}
+			catch (Exception e) {
+				throw new OMException(e);
+			}
+		}
+		return parser.getName();
+	}
+
+	public String getText() throws OMException {
+		if (navigate) {
+			try {
+				return (String)lastNode.getValue();
+			}
+			catch (Exception e) {
+				throw new OMException(e);
+			}
+		}
+		return parser.getText();
+	}
+
+	public String getNamespace() throws OMException {
+		if (navigate) {
+			if (lastNode instanceof OMElement) {
+				OMElement node= (OMElement)lastNode;
+				OMNamespace ns= node.getNamespace();
+				if (ns != null)
+					return ns.getValue();
+				//	TODO: else						
+			}
+			throw new OMException();
+		}
+		return parser.getNamespace();
+	}
+
+	public int getNamespaceCount(int arg) throws OMException {
+		if (navigate)
+			//	TODO:
+			throw new OMException();
+		try {
+			return parser.getNamespaceCount(arg);
+		}
+		catch (Exception e) {
+			throw new OMException(e);
+		}
+	}
+
+	public String getNamespacePrefix(int arg) throws OMException {
+		if (navigate)
+			//	TODO:
+			throw new OMException();
+		try {
+			return parser.getNamespacePrefix(arg);
+		}
+		catch (Exception e) {
+			throw new OMException(e);
+		}
+	}
+
+	public String getNamespaceUri(int arg) throws OMException {
+		if (navigate)
+			//	TODO:
+			throw new OMException();
+		try {
+			return parser.getNamespaceUri(arg);
+		}
+		catch (Exception e) {
+			throw new OMException(e);
+		}
+	}
+
+	public String getNamespace(String arg) throws OMException {
+		if (navigate)
+			//	TODO:
+			throw new OMException();
+		try {
+			return parser.getNamespace(arg);
+		}
+		catch (Exception e) {
+			throw new OMException(e);
+		}
+	}
+
+	public String getPrefix() throws OMException {
+		if (navigate)
+			//	TODO:
+			throw new OMException();
+		return parser.getPrefix();
+	}
+
+	public int getAttributeCount() throws OMException {
+		if (navigate)
+			//	TODO:
+			throw new OMException();
+		return parser.getAttributeCount();
+	}
+
+	public String getAttributeNamespace(int arg) throws OMException {
+		if (navigate)
+			//	TODO:
+			throw new OMException();
+		return parser.getAttributeNamespace(arg);
+	}
+
+	public String getAttributeName(int arg) throws OMException {
+		if (navigate)
+			//	TODO:
+			throw new OMException();
+		return parser.getAttributeNamespace(arg);
+	}
+
+	public String getAttributePrefix(int arg) throws OMException {
+		if (navigate)
+			//	TODO:
+			throw new OMException();
+		return parser.getAttributeNamespace(arg);
+	}
+}

Added: webservices/axis/trunk/java/dev/scratch/dasarath/om/src/test-resources/soapmessage.xml
==============================================================================
--- (empty file)
+++ webservices/axis/trunk/java/dev/scratch/dasarath/om/src/test-resources/soapmessage.xml	Mon Sep 27 00:08:10 2004
@@ -0,0 +1,15 @@
+<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/03/addressing">
+    <soapenv:Header>
+        <wsa:MessageID soapenv:mustUnderstand="0">uuid:920C5190-0B8F-11D9-8CED-F22EDEEBF7E5</wsa:MessageID>
+        <wsa:To soapenv:mustUnderstand="0">http://localhost:8081/axis/services/BankPort</wsa:To>
+        <wsa:From soapenv:mustUnderstand="0">
+            <Address xmlns="http://schemas.xmlsoap.org/ws/2004/03/addressing">http://schemas.xmlsoap.org/ws/2004/03/addressing/role/anonymous</Address>
+        </wsa:From>
+    </soapenv:Header>
+    <soapenv:Body>
+        <ns1:getBalance soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:ns1="http://localhost:8081/axis/services/BankPort">
+            <accountNo href="#id0"/>
+        </ns1:getBalance>
+        <multiRef id="id0" soapenc:root="0" soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xsi:type="xsd:int" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">1001</multiRef>
+    </soapenv:Body>
+</soapenv:Envelope>
\ No newline at end of file

Added: webservices/axis/trunk/java/dev/scratch/dasarath/om/src/test-resources/soapmessage1.xml
==============================================================================
--- (empty file)
+++ webservices/axis/trunk/java/dev/scratch/dasarath/om/src/test-resources/soapmessage1.xml	Mon Sep 27 00:08:10 2004
@@ -0,0 +1 @@
+<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/03/addressing"><soapenv:Header><wsa:MessageID soapenv:mustUnderstand="0">uuid:920C5190-0B8F-11D9-8CED-F22EDEEBF7E5</wsa:MessageID><wsa:To soapenv:mustUnderstand="0">http://localhost:8081/axis/services/BankPort</wsa:To><wsa:From soapenv:mustUnderstand="0"><Address xmlns="http://schemas.xmlsoap.org/ws/2004/03/addressing">http://schemas.xmlsoap.org/ws/2004/03/addressing/role/anonymous</Address></wsa:From></soapenv:Header><soapenv:Body><ns1:getBalance soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:ns1="http://localhost:8081/axis/services/BankPort"><accountNo href="#id0"/></ns1:getBalance><multiRef id="id0" soapenc:root="0" soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xsi:type="xsd:int" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">1001</multiRef></soapenv:Body></soapenv:Envelope>
\ No newline at end of file

Added: webservices/axis/trunk/java/dev/scratch/dasarath/om/src/test-resources/testFile.xml
==============================================================================
--- (empty file)
+++ webservices/axis/trunk/java/dev/scratch/dasarath/om/src/test-resources/testFile.xml	Mon Sep 27 00:08:10 2004
@@ -0,0 +1,7 @@
+<root>
+    <name type="original">
+        <firstname>Ajith</firstname>
+        <surname>Ranabahu</surname>
+    </name>
+    <age>26</age>
+</root>
\ No newline at end of file

Added: webservices/axis/trunk/java/dev/scratch/dasarath/om/src/test-resources/tester-out.xml
==============================================================================
--- (empty file)
+++ webservices/axis/trunk/java/dev/scratch/dasarath/om/src/test-resources/tester-out.xml	Mon Sep 27 00:08:10 2004
@@ -0,0 +1 @@
+<soapenv:Envelope xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/03/addressing" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"><soapenv:Header><wsa:MessageID soapenv:mustUnderstand="0">uuid:920C5190-0B8F-11D9-8CED-F22EDEEBF7E5</wsa:MessageID><wsa:To soapenv:mustUnderstand="0">http://localhost:8081/axis/services/BankPort</wsa:To><wsa:From soapenv:mustUnderstand="0"><Address xmlns="http://schemas.xmlsoap.org/ws/2004/03/addressing">http://schemas.xmlsoap.org/ws/2004/03/addressing/role/anonymous</Address></wsa:From><wsa:RelatesTo soapenv:mustUnderstand="0" RelationshipType="wsa:Reply">uuid:3821F4F0-D020-11D8-A10A-E4EE6425FCB0</wsa:RelatesTo></soapenv:Header></soapenv:Envelope>
\ No newline at end of file

Added: webservices/axis/trunk/java/dev/scratch/dasarath/om/src/test/org/apache/axis/om/Tester.java
==============================================================================
--- (empty file)
+++ webservices/axis/trunk/java/dev/scratch/dasarath/om/src/test/org/apache/axis/om/Tester.java	Mon Sep 27 00:08:10 2004
@@ -0,0 +1,198 @@
+/*
+ * Created on Sep 26, 2004
+ * Copyright  2004 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.axis.om;
+
+import java.io.FileOutputStream;
+import java.io.FileReader;
+import java.io.PrintStream;
+import java.lang.reflect.Field;
+
+import junit.framework.TestCase;
+
+import org.xmlpull.v1.XmlPullParser;
+import org.xmlpull.v1.XmlPullParserFactory;
+import org.apache.axis.om.*;
+
+/**
+ * @author Dasarath Weeratunge
+ *
+ */
+public class Tester extends TestCase {
+    private static final String IN_FILE_NAME = "src/test-resources/soapmessage.xml";
+    private static final String OUT_FILE_NAME = "src/test-resources/tester-out.xml";
+
+    public void test1() throws Exception {
+		System.out.println("\n+++");
+		OMElement root= getOMBuilder().getDocument();
+		System.out.println(root.isComplete());
+		root.print(System.out);
+	}
+
+	public void test2() throws Exception {
+		System.out.println("\n+++");
+		OMElement root= getOMBuilder().getDocument();
+
+		System.out.println(root.isComplete());
+		root.getFirstChild().detach();
+
+		System.out.println("---");
+		navigate(root);
+
+		OMElement header= (OMElement)root.getFirstChild();
+		//	we read the header completely but do not cache it
+		header.detach();
+
+		System.out.println("---");
+		navigate(root);
+
+		System.out.println("---");
+		root.print(System.out);
+	}
+
+	public void test3() throws Exception {
+		System.out.println("\n+++");
+		OMElement root= getOMBuilder().getDocument();
+
+		OMNamespace soapenv= root.resolveNamespace("http://schemas.xmlsoap.org/soap/envelope/", "soapenv");
+		OMNamespace wsa= root.resolveNamespace("http://schemas.xmlsoap.org/ws/2004/03/addressing", "wsa");
+
+		OMElement relatesTo= new OMElement("RelatesTo", wsa);
+		relatesTo.insertAttribute(new OMAttribute("RelationshipType", null, "wsa:Reply"));
+		relatesTo.insertAttribute(new OMAttribute("mustUnderstand", soapenv, "0"));
+		relatesTo.insertChild(new OMText("uuid:3821F4F0-D020-11D8-A10A-E4EE6425FCB0"));
+
+		System.out.println(root.isComplete());
+		root.insertChild(relatesTo);
+
+		OMNavigator navigator= new OMNavigator(root);
+		OMNode node= navigator.next();
+		do {
+			if (node instanceof OMElement) {
+				OMElement el= (OMElement)node;
+				System.out.println("OMElement= " + el.getLocalName());
+			}
+			else
+				System.out.println("OMText= " + node.getValue());
+			node= navigator.next();
+		}
+		while (node != null);
+
+		root.print(System.out);
+	}
+
+	public void test4() throws Exception {
+		System.out.println("\n+++");
+		OMElement root= new OMElement("Envelope", null);
+		OMNamespace soapenv= root.createNamespace("http://schemas.xmlsoap.org/soap/envelope/", "soapenv");
+		root.setNamespace(soapenv);
+		OMElement header= new OMElement("Header", soapenv);
+		root.insertChild(header);
+		OMNamespace xsd= root.createNamespace("http://www.w3.org/2001/XMLSchema", "xsd");
+		OMNamespace xsi= root.createNamespace("http://www.w3.org/2001/XMLSchema-instance", "xsi");
+		OMNamespace wsa= root.createNamespace("http://schemas.xmlsoap.org/ws/2004/03/addressing", "wsa");
+
+		OMElement messageID= new OMElement("MessageID", wsa);
+		messageID.insertChild(new OMText("uuid:920C5190-0B8F-11D9-8CED-F22EDEEBF7E5"));
+		messageID.insertAttribute(new OMAttribute("mustUnderstand", soapenv, "0"));
+
+		OMElement from= new OMElement("From", wsa);
+		OMElement address= new OMElement("Address", null);
+		address.createNamespace("http://schemas.xmlsoap.org/ws/2004/03/addressing", null);
+		address.setNamespace(
+			address.resolveNamespace("http://schemas.xmlsoap.org/ws/2004/03/addressing", null));
+		address.insertChild(new OMText("http://schemas.xmlsoap.org/ws/2004/03/addressing/role/anonymous"));
+		from.insertChild(address);
+		//	FIXME:	cannot reuse the attribute object created earlier. linked list--
+		from.insertAttribute(new OMAttribute("mustUnderstand", soapenv, "0"));
+
+		OMElement to= new OMElement("To", wsa);
+		to.insertChild(new OMText("http://localhost:8081/axis/services/BankPort"));
+		to.insertAttribute(new OMAttribute("mustUnderstand", soapenv, "0"));
+
+		OMElement relatesTo= new OMElement("RelatesTo", wsa);
+		relatesTo.insertAttribute(new OMAttribute("RelationshipType", null, "wsa:Reply"));
+		relatesTo.insertAttribute(new OMAttribute("mustUnderstand", soapenv, "0"));
+		relatesTo.insertChild(new OMText("uuid:3821F4F0-D020-11D8-A10A-E4EE6425FCB0"));
+
+		header.insertChild(from);
+		from.insertSiblingAfter(relatesTo);
+		from.insertSiblingBefore(to);
+		to.insertSiblingBefore(messageID);
+
+		root.print(new PrintStream(new FileOutputStream(OUT_FILE_NAME)));
+	}
+	
+	public void test5() throws Exception {
+			System.out.println("\n+++");
+			OMXmlPullParserWrapper omBuilder= getOMBuilder();
+			OMElement root= omBuilder.getDocument();
+			root.getFirstChild().detach();
+			OMElement header= (OMElement)root.getFirstChild();
+			while (!header.isComplete())
+				omBuilder.next();
+			navigate(root);	
+			System.out.println("---");
+			omBuilder.reset(header);
+			int event;
+			do {
+				event= omBuilder.next();
+				System.out.print(getFieldName(event)+"= ");
+				if (event == XmlPullParser.TEXT)
+					System.out.println(omBuilder.getText());
+				else {
+					System.out.println("{"+omBuilder.getNamespace()+"}"+omBuilder.getName());
+				}
+			}while (event != XmlPullParser.END_DOCUMENT);
+			System.out.println("---");
+			root.print(System.out);
+		}
+
+	private void navigate(OMNode node) throws Exception {
+		OMNavigator navigator= new OMNavigator(node);
+		node= navigator.next();
+		do {
+			if (node instanceof OMElement) {
+				OMElement el= (OMElement)node;
+				System.out.print("OMElement= " + el.getLocalName());
+			}
+			else
+				System.out.print("OMText= " + node.getValue());
+			System.out.println(" isComplete= " + node.isComplete());
+			node= navigator.next();
+		}
+		while (node != null);
+	}
+
+	private OMXmlPullParserWrapper getOMBuilder() throws Exception {
+		XmlPullParser parser= XmlPullParserFactory.newInstance().newPullParser();
+		parser.setFeature(XmlPullParser.FEATURE_PROCESS_NAMESPACES, true);
+		parser.setInput(new FileReader(IN_FILE_NAME));
+		return new OMXmlPullParserWrapper(parser);
+	}
+	
+	private static Field[] flds= XmlPullParser.class.getDeclaredFields();
+
+	public static String getFieldName(int field) throws Exception {
+		for (int i= 1; i < flds.length + 1; i++) {
+			if (flds[i].getInt(null) == field)
+				return flds[i].getName();
+		}
+		return null;
+	}
+}