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/11/13 21:21:53 UTC
svn commit: r1201503 - in /webservices/commons/trunk/modules/axiom/modules:
axiom-api/src/main/java/org/apache/axiom/om/impl/builder/
axiom-impl/src/test/java/org/apache/axiom/om/impl/llom/
Author: veithen
Date: Sun Nov 13 20:21:52 2011
New Revision: 1201503
URL: http://svn.apache.org/viewvc?rev=1201503&view=rev
Log:
AXIOM-398: Fixed the handling of default namespaces in SAXOMBuilder by reusing the same code as in StAXOMBuilder. Note that there is still a problem in DOOM somewhere.
Added:
webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/impl/builder/BuilderUtil.java (with props)
Modified:
webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/impl/builder/SAXOMBuilder.java
webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/impl/builder/StAXOMBuilder.java
webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/test/java/org/apache/axiom/om/impl/llom/OMImplementationTest.java
Added: webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/impl/builder/BuilderUtil.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/impl/builder/BuilderUtil.java?rev=1201503&view=auto
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/impl/builder/BuilderUtil.java (added)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/impl/builder/BuilderUtil.java Sun Nov 13 20:21:52 2011
@@ -0,0 +1,48 @@
+/*
+ * 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.builder;
+
+import org.apache.axiom.om.OMElement;
+import org.apache.axiom.om.OMNamespace;
+import org.apache.axiom.om.impl.OMElementEx;
+
+class BuilderUtil {
+ private BuilderUtil() {}
+
+ static void setNamespace(OMElement element, String namespaceURI, String prefix, boolean namespaceURIInterning) {
+ if (namespaceURI != null && namespaceURI.length() > 0) {
+ // Check if there is an existing namespace declaration. This has two purposes:
+ // * Avoid creating a new OMNamespace instance for each OMElement
+ // * Perform namespace repairing
+ OMNamespace namespace = element.findNamespaceURI(prefix == null ? "" : prefix);
+ if (namespace == null || !namespace.getNamespaceURI().equals(namespaceURI)) {
+ if (namespaceURIInterning) {
+ namespaceURI = namespaceURI.intern();
+ }
+ if (prefix == null) {
+ prefix = "";
+ }
+ // This is actually the place where we perform namespace repairing as specified
+ // in the contract of OMXMLBuilderFactory#createStAXOMBuilder:
+ namespace = ((OMElementEx)element).addNamespaceDeclaration(namespaceURI, prefix);
+ }
+ element.setNamespaceWithNoFindInCurrentScope(namespace);
+ }
+ }
+}
Propchange: webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/impl/builder/BuilderUtil.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/impl/builder/SAXOMBuilder.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/impl/builder/SAXOMBuilder.java?rev=1201503&r1=1201502&r2=1201503&view=diff
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/impl/builder/SAXOMBuilder.java (original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/impl/builder/SAXOMBuilder.java Sun Nov 13 20:21:52 2011
@@ -147,8 +147,10 @@ public class SAXOMBuilder extends Defaul
nextElem = createNextElement(localName);
else
nextElem.setLocalName(localName);
-
- nextElem.setNamespace(nextElem.findNamespace(namespaceURI, null));
+
+ int idx = qName.indexOf(':');
+ String prefix = idx == -1 ? "" : qName.substring(0, idx);
+ BuilderUtil.setNamespace(nextElem, namespaceURI, prefix, false);
int j = atts.getLength();
for (int i = 0; i < j; i++) {
Modified: webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/impl/builder/StAXOMBuilder.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/impl/builder/StAXOMBuilder.java?rev=1201503&r1=1201502&r2=1201503&view=diff
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/impl/builder/StAXOMBuilder.java (original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/impl/builder/StAXOMBuilder.java Sun Nov 13 20:21:52 2011
@@ -26,7 +26,6 @@ import org.apache.axiom.om.OMElement;
import org.apache.axiom.om.OMException;
import org.apache.axiom.om.OMFactory;
import org.apache.axiom.om.OMHierarchyException;
-import org.apache.axiom.om.OMNamespace;
import org.apache.axiom.om.OMNode;
import org.apache.axiom.om.OMText;
import org.apache.axiom.om.impl.OMContainerEx;
@@ -613,20 +612,8 @@ public class StAXOMBuilder extends StAXB
String namespaceURI = parser.getNamespaceURI();
String prefix = parser.getPrefix();
- if (namespaceURI != null && namespaceURI.length() > 0) {
- OMNamespace namespace = node.findNamespaceURI(prefix == null ? "" : prefix);
- if (namespace == null || !namespace.getNamespaceURI().equals(namespaceURI)) {
- // See NOTE_A above
- if (isNamespaceURIInterning()) {
- namespaceURI = namespaceURI.intern();
- }
- if (prefix == null) {
- prefix = "";
- }
- namespace = ((OMElementEx)node).addNamespaceDeclaration(namespaceURI, prefix);
- }
- node.setNamespaceWithNoFindInCurrentScope(namespace);
- }
+ // See NOTE_A above
+ BuilderUtil.setNamespace(node, namespaceURI, prefix, isNamespaceURIInterning());
}
/**
Modified: webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/test/java/org/apache/axiom/om/impl/llom/OMImplementationTest.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/test/java/org/apache/axiom/om/impl/llom/OMImplementationTest.java?rev=1201503&r1=1201502&r2=1201503&view=diff
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/test/java/org/apache/axiom/om/impl/llom/OMImplementationTest.java (original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/test/java/org/apache/axiom/om/impl/llom/OMImplementationTest.java Sun Nov 13 20:21:52 2011
@@ -26,7 +26,6 @@ import org.apache.axiom.ts.OMTestSuiteBu
import org.apache.axiom.ts.om.builder.TestCreateOMBuilderFromDOMSource;
import org.apache.axiom.ts.om.container.TestSerialize;
import org.apache.axiom.ts.om.document.TestDigest;
-import org.apache.axiom.ts.om.element.TestGetNamespaceNormalizedWithSAXSource;
import org.apache.axiom.ts.om.element.TestGetXMLStreamReaderWithOMSourcedElementDescendant;
import org.apache.axiom.ts.om.node.TestInsertSiblingAfterOnChild;
import org.apache.axiom.ts.om.node.TestInsertSiblingBeforeOnChild;
@@ -57,9 +56,6 @@ public class OMImplementationTest extend
// TODO: if there is a comment node surrounded by text, then these text nodes need to be merged
builder.exclude(TestDigest.class, "(|(file=digest3.xml)(file=digest4.xml))");
- // TODO: AXIOM-398
- builder.exclude(TestGetNamespaceNormalizedWithSAXSource.class);
-
return builder.build();
}
}