You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ws.apache.org by ve...@apache.org on 2011/10/02 14:52:30 UTC
svn commit: r1178184 - in /webservices/commons/trunk/modules/axiom/modules:
axiom-api/src/main/java/org/apache/axiom/om/
axiom-api/src/main/java/org/apache/axiom/om/xpath/
axiom-common-impl/src/main/java/org/apache/axiom/om/impl/common/
axiom-dom/src/m...
Author: veithen
Date: Sun Oct 2 12:52:29 2011
New Revision: 1178184
URL: http://svn.apache.org/viewvc?rev=1178184&view=rev
Log:
AXIOM-388: Added a getNamespacesInScope method to OMElement.
Added:
webservices/commons/trunk/modules/axiom/modules/axiom-common-impl/src/main/java/org/apache/axiom/om/impl/common/NamespaceIterator.java (with props)
webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestGetNamespacesInScope.java (with props)
webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestGetNamespacesInScopeWithDefaultNamespace.java (with props)
webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestGetNamespacesInScopeWithMaskedDefaultNamespace.java (with props)
webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestGetNamespacesInScopeWithMaskedNamespace.java (with props)
Modified:
webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/OMElement.java
webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/xpath/AXIOMXPath.java
webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/ElementImpl.java
webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMElementImpl.java
webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMSourcedElementImpl.java
webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/OMTestSuiteBuilder.java
Modified: webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/OMElement.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/OMElement.java?rev=1178184&r1=1178183&r2=1178184&view=diff
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/OMElement.java (original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/OMElement.java Sun Oct 2 12:52:29 2011
@@ -195,6 +195,7 @@ public interface OMElement extends OMNod
* namespace declarations and prefix undeclaring), it is generally recommended to use one of the
* following specialized methods for this purpose:
* <ul>
+ * <li>{@link #getNamespacesInScope()} to calculate the namespace context for the element.
* <li>{@link #findNamespace(String, String)} and {@link #findNamespaceURI(String)} to resolve a
* namespace prefix or to find a namespace prefix for a given URI.
* <li>{@link #resolveQName(String)} to resolve a QName literal.
@@ -217,6 +218,25 @@ public interface OMElement extends OMNod
Iterator getAllDeclaredNamespaces() throws OMException;
/**
+ * Get an iterator that returns all namespaces in scope for this element. This method may be
+ * used to determine the namespace context for this element. For any given prefix, the iterator
+ * returns at most one {@link OMNamespace} object with that prefix, and this object specifies
+ * the namespace URI bound to the prefix. The iterator returns an {@link OMNamespace} object
+ * with an empty prefix if and only if there is a default namespace. It will never return an
+ * {@link OMNamespace} object with both the prefix and the namespace URI set to the empty
+ * string, even if the element or one of its ancestors has a namespace declaration of the form
+ * <tt>xmlns=""</tt>.
+ * <p>
+ * The order in which the iterator returns the namespaces is undefined, and invoking the
+ * {@link Iterator#remove()} method on the returned iterator is not supported. The iterator may
+ * be a "live" object, which means that results are undefined if the document is modified (in a
+ * way that would modify the namespace context for the element) while the iterator is in use.
+ *
+ * @return an iterator over all namespaces in scope for this element
+ */
+ Iterator getNamespacesInScope();
+
+ /**
* Returns a list of OMAttributes.
* <p/>
* <p>Note that the iterator returned by this function will be invalidated by any
Modified: webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/xpath/AXIOMXPath.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/xpath/AXIOMXPath.java?rev=1178184&r1=1178183&r2=1178184&view=diff
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/xpath/AXIOMXPath.java (original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/xpath/AXIOMXPath.java Sun Oct 2 12:52:29 2011
@@ -20,18 +20,14 @@
package org.apache.axiom.om.xpath;
import org.apache.axiom.om.OMAttribute;
-import org.apache.axiom.om.OMContainer;
-import org.apache.axiom.om.OMDocument;
import org.apache.axiom.om.OMElement;
import org.apache.axiom.om.OMNamespace;
import org.jaxen.BaseXPath;
import org.jaxen.JaxenException;
import java.util.HashMap;
-import java.util.HashSet;
import java.util.Iterator;
import java.util.Map;
-import java.util.Set;
public class AXIOMXPath extends BaseXPath {
@@ -118,30 +114,13 @@ public class AXIOMXPath extends BaseXPat
* @param element the element to retrieve the namespace context from
* @throws JaxenException if an error occurred when adding the namespace declarations
*/
- // TODO: need to take prefix undeclaring into account here; probably we should add a method to OMElement that returns all namespaces in scope
public void addNamespaces(OMElement element) throws JaxenException {
- OMElement current = element;
- // An element can redeclare a namespace prefix that has already been declared
- // by one of its ancestors. Since we visit the tree from child to parent, we
- // need to keep track of the prefixes we have already seen in order to avoid
- // adding namespace declarations that are overridden by a descendant of an element.
- Set seenPrefixes = new HashSet();
- while (true) {
- for (Iterator it = current.getAllDeclaredNamespaces(); it.hasNext(); ) {
- OMNamespace ns = (OMNamespace) it.next();
- if (ns != null) {
- String prefix = ns.getPrefix();
- // Exclude the default namespace as explained in the Javadoc above
- if (prefix.length() != 0 && seenPrefixes.add(prefix)) {
- addNamespace(ns.getPrefix(), ns.getNamespaceURI());
- }
- }
- }
- OMContainer parent = current.getParent();
- if (parent == null || parent instanceof OMDocument) {
- break;
- } else {
- current = (OMElement)parent;
+ for (Iterator it = element.getNamespacesInScope(); it.hasNext(); ) {
+ OMNamespace ns = (OMNamespace) it.next();
+ String prefix = ns.getPrefix();
+ // Exclude the default namespace as explained in the Javadoc above
+ if (prefix.length() != 0) {
+ addNamespace(prefix, ns.getNamespaceURI());
}
}
}
Added: webservices/commons/trunk/modules/axiom/modules/axiom-common-impl/src/main/java/org/apache/axiom/om/impl/common/NamespaceIterator.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-common-impl/src/main/java/org/apache/axiom/om/impl/common/NamespaceIterator.java?rev=1178184&view=auto
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-common-impl/src/main/java/org/apache/axiom/om/impl/common/NamespaceIterator.java (added)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-common-impl/src/main/java/org/apache/axiom/om/impl/common/NamespaceIterator.java Sun Oct 2 12:52:29 2011
@@ -0,0 +1,92 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.axiom.om.impl.common;
+
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.NoSuchElementException;
+import java.util.Set;
+
+import org.apache.axiom.om.OMContainer;
+import org.apache.axiom.om.OMElement;
+import org.apache.axiom.om.OMNamespace;
+
+/**
+ * Iterator implementation used by {@link OMElement#getNamespacesInScope()}.
+ */
+public class NamespaceIterator implements Iterator {
+ private final Set/*<String>*/ seenPrefixes = new HashSet();
+ private OMElement element;
+ private Iterator declaredNamespaces;
+ private boolean hasNextCalled;
+ private OMNamespace next;
+
+ public NamespaceIterator(OMElement element) {
+ this.element = element;
+ }
+
+ public boolean hasNext() {
+ if (!hasNextCalled) {
+ while (true) {
+ if (declaredNamespaces == null) {
+ declaredNamespaces = element.getAllDeclaredNamespaces();
+ } else if (declaredNamespaces.hasNext()) {
+ OMNamespace namespace = (OMNamespace)declaredNamespaces.next();
+ // We only return a namespace declaration if it has not been overridden (i.e. if
+ // we have not seen another declaration with the same prefix yet) and if the namespace
+ // URI is not empty. The second part of the condition covers the case of namespace
+ // declarations such as xmlns="" (for which no OMNamespace object is returned, as
+ // described in the Javadoc of the getNamespacesInScope method) as well as undeclared
+ // prefixes (XML 1.1 only).
+ if (seenPrefixes.add(namespace.getPrefix()) && namespace.getNamespaceURI().length() > 0) {
+ next = namespace;
+ break;
+ }
+ } else {
+ declaredNamespaces = null;
+ OMContainer parent = element.getParent();
+ if (parent instanceof OMElement) {
+ element = (OMElement)parent;
+ } else {
+ next = null;
+ break;
+ }
+ }
+ }
+ hasNextCalled = true;
+ }
+ return next != null;
+ }
+
+ public Object next() {
+ if (hasNext()) {
+ OMNamespace result = next;
+ hasNextCalled = false;
+ next = null;
+ return result;
+ } else {
+ throw new NoSuchElementException();
+ }
+ }
+
+ // TODO: document that remove is not supported
+ public void remove() {
+ throw new UnsupportedOperationException();
+ }
+}
Propchange: webservices/commons/trunk/modules/axiom/modules/axiom-common-impl/src/main/java/org/apache/axiom/om/impl/common/NamespaceIterator.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/ElementImpl.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/ElementImpl.java?rev=1178184&r1=1178183&r2=1178184&view=diff
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/ElementImpl.java (original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/ElementImpl.java Sun Oct 2 12:52:29 2011
@@ -28,6 +28,7 @@ import org.apache.axiom.om.OMNamespace;
import org.apache.axiom.om.OMNode;
import org.apache.axiom.om.OMText;
import org.apache.axiom.om.OMXMLParserWrapper;
+import org.apache.axiom.om.impl.common.NamespaceIterator;
import org.apache.axiom.om.impl.common.OMNamespaceImpl;
import org.apache.axiom.om.impl.dom.factory.OMDOMFactory;
import org.apache.axiom.om.impl.traverse.OMChildElementIterator;
@@ -1149,6 +1150,10 @@ public class ElementImpl extends ParentN
return namespaces.values().iterator();
}
+ public Iterator getNamespacesInScope() {
+ return new NamespaceIterator(this);
+ }
+
/** @see org.apache.axiom.om.OMElement#getAllAttributes() */
public Iterator getAllAttributes() {
if (attributes == null) {
Modified: webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMElementImpl.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMElementImpl.java?rev=1178184&r1=1178183&r2=1178184&view=diff
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMElementImpl.java (original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMElementImpl.java Sun Oct 2 12:52:29 2011
@@ -33,6 +33,7 @@ import org.apache.axiom.om.OMXMLParserWr
import org.apache.axiom.om.impl.OMContainerEx;
import org.apache.axiom.om.impl.OMNodeEx;
import org.apache.axiom.om.impl.builder.StAXOMBuilder;
+import org.apache.axiom.om.impl.common.NamespaceIterator;
import org.apache.axiom.om.impl.common.OMNamespaceImpl;
import org.apache.axiom.om.impl.jaxp.OMSource;
import org.apache.axiom.om.impl.llom.factory.OMLinkedListImplFactory;
@@ -548,6 +549,10 @@ public class OMElementImpl extends OMNod
return namespaces.values().iterator();
}
+ public Iterator getNamespacesInScope() {
+ return new NamespaceIterator(this);
+ }
+
/**
* Returns a List of OMAttributes.
*
Modified: webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMSourcedElementImpl.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMSourcedElementImpl.java?rev=1178184&r1=1178183&r2=1178184&view=diff
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMSourcedElementImpl.java (original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMSourcedElementImpl.java Sun Oct 2 12:52:29 2011
@@ -402,6 +402,11 @@ public class OMSourcedElementImpl extend
return super.getAllDeclaredNamespaces();
}
+ public Iterator getNamespacesInScope() throws OMException {
+ forceExpand();
+ return super.getNamespacesInScope();
+ }
+
/* (non-Javadoc)
* @see org.apache.axiom.om.OMElement#getAllAttributes()
*/
Modified: webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/OMTestSuiteBuilder.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/OMTestSuiteBuilder.java?rev=1178184&r1=1178183&r2=1178184&view=diff
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/OMTestSuiteBuilder.java (original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/OMTestSuiteBuilder.java Sun Oct 2 12:52:29 2011
@@ -143,6 +143,10 @@ public class OMTestSuiteBuilder extends
addTest(new org.apache.axiom.ts.om.element.TestGetChildrenWithName4(metaFactory));
addTest(new org.apache.axiom.ts.om.element.TestGetFirstChildWithName(metaFactory));
addTest(new org.apache.axiom.ts.om.element.TestGetFirstChildWithNameOnIncompleteElement(metaFactory));
+ addTest(new org.apache.axiom.ts.om.element.TestGetNamespacesInScope(metaFactory));
+ addTest(new org.apache.axiom.ts.om.element.TestGetNamespacesInScopeWithDefaultNamespace(metaFactory));
+ addTest(new org.apache.axiom.ts.om.element.TestGetNamespacesInScopeWithMaskedDefaultNamespace(metaFactory));
+ addTest(new org.apache.axiom.ts.om.element.TestGetNamespacesInScopeWithMaskedNamespace(metaFactory));
addTest(new org.apache.axiom.ts.om.element.TestGetNamespaceURIWithNamespace(metaFactory));
addTest(new org.apache.axiom.ts.om.element.TestGetNamespaceURIWithoutNamespace(metaFactory));
addTest(new org.apache.axiom.ts.om.element.TestGetQNameWithNamespace(metaFactory));
Added: webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestGetNamespacesInScope.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestGetNamespacesInScope.java?rev=1178184&view=auto
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestGetNamespacesInScope.java (added)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestGetNamespacesInScope.java Sun Oct 2 12:52:29 2011
@@ -0,0 +1,58 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.axiom.ts.om.element;
+
+import java.util.Iterator;
+
+import org.apache.axiom.om.OMElement;
+import org.apache.axiom.om.OMMetaFactory;
+import org.apache.axiom.om.OMNamespace;
+import org.apache.axiom.om.util.AXIOMUtil;
+import org.apache.axiom.ts.AxiomTestCase;
+
+public class TestGetNamespacesInScope extends AxiomTestCase {
+ public TestGetNamespacesInScope(OMMetaFactory metaFactory) {
+ super(metaFactory);
+ }
+
+ protected void runTest() throws Throwable {
+ OMElement element = AXIOMUtil.stringToOM(metaFactory.getOMFactory(),
+ "<a xmlns:ns1='urn:ns1'><b xmlns:ns2='urn:ns2'/></a>");
+ boolean ns1seen = false;
+ boolean ns2seen = false;
+ Iterator it = element.getFirstElement().getNamespacesInScope();
+ int count = 0;
+ while (it.hasNext()) {
+ OMNamespace ns = (OMNamespace)it.next();
+ count++;
+ if (ns.getPrefix().equals("ns1")) {
+ ns1seen = true;
+ assertEquals("urn:ns1", ns.getNamespaceURI());
+ } else if (ns.getPrefix().equals("ns2")) {
+ ns2seen = true;
+ assertEquals("urn:ns2", ns.getNamespaceURI());
+ } else {
+ fail("Unexpected prefix: " + ns.getPrefix());
+ }
+ }
+ assertEquals("Number of namespaces in scope", 2, count);
+ assertTrue(ns1seen);
+ assertTrue(ns2seen);
+ }
+}
Propchange: webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestGetNamespacesInScope.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestGetNamespacesInScopeWithDefaultNamespace.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestGetNamespacesInScopeWithDefaultNamespace.java?rev=1178184&view=auto
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestGetNamespacesInScopeWithDefaultNamespace.java (added)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestGetNamespacesInScopeWithDefaultNamespace.java Sun Oct 2 12:52:29 2011
@@ -0,0 +1,44 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.axiom.ts.om.element;
+
+import java.util.Iterator;
+
+import org.apache.axiom.om.OMElement;
+import org.apache.axiom.om.OMMetaFactory;
+import org.apache.axiom.om.OMNamespace;
+import org.apache.axiom.om.util.AXIOMUtil;
+import org.apache.axiom.ts.AxiomTestCase;
+
+public class TestGetNamespacesInScopeWithDefaultNamespace extends AxiomTestCase {
+ public TestGetNamespacesInScopeWithDefaultNamespace(OMMetaFactory metaFactory) {
+ super(metaFactory);
+ }
+
+ protected void runTest() throws Throwable {
+ OMElement element = AXIOMUtil.stringToOM(metaFactory.getOMFactory(),
+ "<a xmlns='urn:test'><b/></a>");
+ Iterator it = element.getFirstElement().getNamespacesInScope();
+ assertTrue(it.hasNext());
+ OMNamespace ns = (OMNamespace)it.next();
+ assertEquals("", ns.getPrefix());
+ assertEquals("urn:test", ns.getNamespaceURI());
+ assertFalse(it.hasNext());
+ }
+}
Propchange: webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestGetNamespacesInScopeWithDefaultNamespace.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestGetNamespacesInScopeWithMaskedDefaultNamespace.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestGetNamespacesInScopeWithMaskedDefaultNamespace.java?rev=1178184&view=auto
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestGetNamespacesInScopeWithMaskedDefaultNamespace.java (added)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestGetNamespacesInScopeWithMaskedDefaultNamespace.java Sun Oct 2 12:52:29 2011
@@ -0,0 +1,39 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.axiom.ts.om.element;
+
+import java.util.Iterator;
+
+import org.apache.axiom.om.OMElement;
+import org.apache.axiom.om.OMMetaFactory;
+import org.apache.axiom.om.util.AXIOMUtil;
+import org.apache.axiom.ts.AxiomTestCase;
+
+public class TestGetNamespacesInScopeWithMaskedDefaultNamespace extends AxiomTestCase {
+ public TestGetNamespacesInScopeWithMaskedDefaultNamespace(OMMetaFactory metaFactory) {
+ super(metaFactory);
+ }
+
+ protected void runTest() throws Throwable {
+ OMElement element = AXIOMUtil.stringToOM(metaFactory.getOMFactory(),
+ "<a xmlns='urn:test'><b xmlns=''/></a>");
+ Iterator it = element.getFirstElement().getNamespacesInScope();
+ assertFalse(it.hasNext());
+ }
+}
Propchange: webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestGetNamespacesInScopeWithMaskedDefaultNamespace.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestGetNamespacesInScopeWithMaskedNamespace.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestGetNamespacesInScopeWithMaskedNamespace.java?rev=1178184&view=auto
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestGetNamespacesInScopeWithMaskedNamespace.java (added)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestGetNamespacesInScopeWithMaskedNamespace.java Sun Oct 2 12:52:29 2011
@@ -0,0 +1,44 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.axiom.ts.om.element;
+
+import java.util.Iterator;
+
+import org.apache.axiom.om.OMElement;
+import org.apache.axiom.om.OMMetaFactory;
+import org.apache.axiom.om.OMNamespace;
+import org.apache.axiom.om.util.AXIOMUtil;
+import org.apache.axiom.ts.AxiomTestCase;
+
+public class TestGetNamespacesInScopeWithMaskedNamespace extends AxiomTestCase {
+ public TestGetNamespacesInScopeWithMaskedNamespace(OMMetaFactory metaFactory) {
+ super(metaFactory);
+ }
+
+ protected void runTest() throws Throwable {
+ OMElement element = AXIOMUtil.stringToOM(metaFactory.getOMFactory(),
+ "<a xmlns:p='urn:ns1'><b xmlns:p='urn:ns2'/></a>");
+ Iterator it = element.getFirstElement().getNamespacesInScope();
+ assertTrue(it.hasNext());
+ OMNamespace ns = (OMNamespace)it.next();
+ assertEquals("p", ns.getPrefix());
+ assertEquals("urn:ns2", ns.getNamespaceURI());
+ assertFalse(it.hasNext());
+ }
+}
Propchange: webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestGetNamespacesInScopeWithMaskedNamespace.java
------------------------------------------------------------------------------
svn:eol-style = native