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 di...@apache.org on 2005/07/11 05:35:34 UTC

svn commit: r210061 - in /webservices/axis/trunk/java/modules/xml/src/org/apache/axis2/om: impl/llom/builder/StAXOMBuilder.java xpath/DocumentNavigator.java

Author: dims
Date: Sun Jul 10 20:35:33 2005
New Revision: 210061

URL: http://svn.apache.org/viewcvs?rev=210061&view=rev
Log:
- StAXOMBuilder was not setting the namespace properly when parsing
- Store the parent of the namespace in DocumentNavigatore
- Flesh out getPrecedingSiblingAxisIterator and getFollowingSiblingAxisIterator



Modified:
    webservices/axis/trunk/java/modules/xml/src/org/apache/axis2/om/impl/llom/builder/StAXOMBuilder.java
    webservices/axis/trunk/java/modules/xml/src/org/apache/axis2/om/xpath/DocumentNavigator.java

Modified: webservices/axis/trunk/java/modules/xml/src/org/apache/axis2/om/impl/llom/builder/StAXOMBuilder.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/xml/src/org/apache/axis2/om/impl/llom/builder/StAXOMBuilder.java?rev=210061&r1=210060&r2=210061&view=diff
==============================================================================
--- webservices/axis/trunk/java/modules/xml/src/org/apache/axis2/om/impl/llom/builder/StAXOMBuilder.java (original)
+++ webservices/axis/trunk/java/modules/xml/src/org/apache/axis2/om/impl/llom/builder/StAXOMBuilder.java Sun Jul 10 20:35:33 2005
@@ -266,6 +266,9 @@
                 if (namespace == null) {
                     namespace = node.declareNamespace(namespaceURI, "");
                 }
+                if(node.getNamespace() == null){
+                    node.setNamespace(namespace);
+                }
             } else {
                 namespace = node.findNamespace(namespaceURI, prefix);
                 if(namespace == null){

Modified: webservices/axis/trunk/java/modules/xml/src/org/apache/axis2/om/xpath/DocumentNavigator.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/xml/src/org/apache/axis2/om/xpath/DocumentNavigator.java?rev=210061&r1=210060&r2=210061&view=diff
==============================================================================
--- webservices/axis/trunk/java/modules/xml/src/org/apache/axis2/om/xpath/DocumentNavigator.java (original)
+++ webservices/axis/trunk/java/modules/xml/src/org/apache/axis2/om/xpath/DocumentNavigator.java Sun Jul 10 20:35:33 2005
@@ -355,12 +355,12 @@
                     String prefix = namespace.getPrefix();
                     if (prefix != null && ! prefixes.contains(prefix)) {
                         prefixes.add(prefix);
-                        nsList.add(namespace);
+                        nsList.add(new OMNamespaceEx(namespace, context));
                     }
                 }
             }
         }
-        nsList.add(new OMNamespaceImpl("http://www.w3.org/XML/1998/namespace", "xml"));
+        nsList.add(new OMNamespaceEx(new OMNamespaceImpl("http://www.w3.org/XML/1998/namespace", "xml"), (OMContainer)contextNode));
         return nsList.iterator();
     }
 
@@ -445,8 +445,15 @@
      *                                  not supported by this object model
      */
     public Iterator getFollowingSiblingAxisIterator(Object contextNode) throws UnsupportedAxisException {
-        //TODO: Fix this better?
-        return super.getFollowingSiblingAxisIterator(contextNode);
+        ArrayList list = new ArrayList();
+        if(contextNode != null &&contextNode instanceof OMNode) {
+            while(contextNode != null && contextNode instanceof OMNode){
+                contextNode = ((OMNode)contextNode).getNextSibling();
+                if(contextNode != null)
+                    list.add(contextNode);
+            }
+        }
+        return list.iterator();
     }
 
     /**
@@ -459,8 +466,15 @@
      *                                  not supported by this object model
      */
     public Iterator getPrecedingSiblingAxisIterator(Object contextNode) throws UnsupportedAxisException {
-        //TODO: Fix this better?
-        return super.getPrecedingSiblingAxisIterator(contextNode);
+        ArrayList list = new ArrayList();
+        if(contextNode != null &&contextNode instanceof OMNode) {
+            while(contextNode != null && contextNode instanceof OMNode){
+                contextNode = ((OMNode)contextNode).getPreviousSibling();
+                if(contextNode != null)
+                    list.add(contextNode);
+            }
+        }
+        return list.iterator();
     }
 
     /**
@@ -566,7 +580,7 @@
      */
     public String translateNamespacePrefixToUri(String prefix, Object element) {
         //TODO: Fix this better?
-        return super.translateNamespacePrefixToUri(prefix, prefix);
+        return super.translateNamespacePrefixToUri(prefix, element);
     }
 
     /**
@@ -622,10 +636,36 @@
     public Object getParentNode(Object contextNode) throws UnsupportedAxisException {
         if (contextNode == null ||
                 contextNode instanceof OMDocument ||
-                contextNode instanceof OMAttribute ||
-                contextNode instanceof OMNamespace)
+                contextNode instanceof OMAttribute)
             return null;
+        if(contextNode instanceof OMNamespaceEx) {
+            return ((OMNamespaceEx)contextNode).getParent();
+        }
         return getDocumentNode(((OMNode) contextNode).getParent());
+    }
+
+    class OMNamespaceEx implements OMNamespace {
+        OMNamespace originalNsp = null;
+        OMContainer contextNode = null;
+        OMNamespaceEx(OMNamespace nsp, OMContainer node) {
+            originalNsp = nsp;
+            contextNode = node;
+        }
+        public boolean equals(String uri, String prefix) {
+            return originalNsp.equals(uri, prefix);
+        }
+
+        public String getPrefix() {
+            return originalNsp.getPrefix();
+        }
+
+        public String getName() {
+            return originalNsp.getName();
+        }
+
+        public OMContainer getParent() {
+            return contextNode;
+        }
     }
 }