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 2015/06/13 20:02:02 UTC
svn commit: r1685295 - in /webservices/axiom/branches/attrs-aspects:
aspects/core-aspects/src/main/java/org/apache/axiom/core/
aspects/dom-aspects/src/main/java/org/apache/axiom/dom/
implementations/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/...
Author: veithen
Date: Sat Jun 13 18:02:01 2015
New Revision: 1685295
URL: http://svn.apache.org/r1685295
Log:
Initial support for namespace unaware (DOM 1) attributes.
Added:
webservices/axiom/branches/attrs-aspects/aspects/core-aspects/src/main/java/org/apache/axiom/core/CoreNSUnawareNamedNodeSupport.aj (with props)
webservices/axiom/branches/attrs-aspects/aspects/dom-aspects/src/main/java/org/apache/axiom/dom/DOMNSUnawareAttribute.java (with props)
webservices/axiom/branches/attrs-aspects/aspects/dom-aspects/src/main/java/org/apache/axiom/dom/DOMNSUnawareAttributeSupport.aj (with props)
webservices/axiom/branches/attrs-aspects/aspects/dom-aspects/src/main/java/org/apache/axiom/dom/DOMNSUnawareNamedNode.java (with props)
webservices/axiom/branches/attrs-aspects/aspects/dom-aspects/src/main/java/org/apache/axiom/dom/DOMNSUnawareNamedNodeSupport.aj (with props)
webservices/axiom/branches/attrs-aspects/aspects/dom-aspects/src/main/java/org/apache/axiom/dom/NSUtil.java (with props)
webservices/axiom/branches/attrs-aspects/implementations/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/NSUnawareAttribute.java (with props)
webservices/axiom/branches/attrs-aspects/implementations/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/TypedAttribute.java (with props)
Modified:
webservices/axiom/branches/attrs-aspects/aspects/core-aspects/src/main/java/org/apache/axiom/core/CoreNSUnawareNamedNode.java
webservices/axiom/branches/attrs-aspects/aspects/core-aspects/src/main/java/org/apache/axiom/core/NodeFactory.java
webservices/axiom/branches/attrs-aspects/aspects/dom-aspects/src/main/java/org/apache/axiom/dom/DOMElementSupport.aj
webservices/axiom/branches/attrs-aspects/aspects/dom-aspects/src/main/java/org/apache/axiom/dom/Policies.java
webservices/axiom/branches/attrs-aspects/implementations/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/ElementImpl.java
webservices/axiom/branches/attrs-aspects/implementations/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/NSAwareAttribute.java
webservices/axiom/branches/attrs-aspects/implementations/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/NamespaceDeclaration.java
webservices/axiom/branches/attrs-aspects/implementations/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/factory/OMDOMFactory.java
Modified: webservices/axiom/branches/attrs-aspects/aspects/core-aspects/src/main/java/org/apache/axiom/core/CoreNSUnawareNamedNode.java
URL: http://svn.apache.org/viewvc/webservices/axiom/branches/attrs-aspects/aspects/core-aspects/src/main/java/org/apache/axiom/core/CoreNSUnawareNamedNode.java?rev=1685295&r1=1685294&r2=1685295&view=diff
==============================================================================
--- webservices/axiom/branches/attrs-aspects/aspects/core-aspects/src/main/java/org/apache/axiom/core/CoreNSUnawareNamedNode.java (original)
+++ webservices/axiom/branches/attrs-aspects/aspects/core-aspects/src/main/java/org/apache/axiom/core/CoreNSUnawareNamedNode.java Sat Jun 13 18:02:01 2015
@@ -23,4 +23,5 @@ package org.apache.axiom.core;
*/
public interface CoreNSUnawareNamedNode {
String coreGetName();
+ void coreSetName(String name);
}
Added: webservices/axiom/branches/attrs-aspects/aspects/core-aspects/src/main/java/org/apache/axiom/core/CoreNSUnawareNamedNodeSupport.aj
URL: http://svn.apache.org/viewvc/webservices/axiom/branches/attrs-aspects/aspects/core-aspects/src/main/java/org/apache/axiom/core/CoreNSUnawareNamedNodeSupport.aj?rev=1685295&view=auto
==============================================================================
--- webservices/axiom/branches/attrs-aspects/aspects/core-aspects/src/main/java/org/apache/axiom/core/CoreNSUnawareNamedNodeSupport.aj (added)
+++ webservices/axiom/branches/attrs-aspects/aspects/core-aspects/src/main/java/org/apache/axiom/core/CoreNSUnawareNamedNodeSupport.aj Sat Jun 13 18:02:01 2015
@@ -0,0 +1,31 @@
+/*
+ * 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.core;
+
+public aspect CoreNSUnawareNamedNodeSupport {
+ private String CoreNSUnawareNamedNode.name;
+
+ public final String CoreNSUnawareNamedNode.coreGetName() {
+ return name;
+ }
+
+ public final void CoreNSUnawareNamedNode.coreSetName(String name) {
+ this.name = name;
+ }
+}
Propchange: webservices/axiom/branches/attrs-aspects/aspects/core-aspects/src/main/java/org/apache/axiom/core/CoreNSUnawareNamedNodeSupport.aj
------------------------------------------------------------------------------
svn:eol-style = native
Modified: webservices/axiom/branches/attrs-aspects/aspects/core-aspects/src/main/java/org/apache/axiom/core/NodeFactory.java
URL: http://svn.apache.org/viewvc/webservices/axiom/branches/attrs-aspects/aspects/core-aspects/src/main/java/org/apache/axiom/core/NodeFactory.java?rev=1685295&r1=1685294&r2=1685295&view=diff
==============================================================================
--- webservices/axiom/branches/attrs-aspects/aspects/core-aspects/src/main/java/org/apache/axiom/core/NodeFactory.java (original)
+++ webservices/axiom/branches/attrs-aspects/aspects/core-aspects/src/main/java/org/apache/axiom/core/NodeFactory.java Sat Jun 13 18:02:01 2015
@@ -22,6 +22,7 @@ public interface NodeFactory {
CoreDocument createDocument();
CoreCharacterData createCharacterData();
CoreCDATASection createCDATASection();
+ CoreNSUnawareAttribute createAttribute(CoreDocument document, String name, String value, String type);
CoreNSAwareAttribute createAttribute(CoreDocument document, String namespaceURI, String localName, String prefix, String value, String type);
CoreNamespaceDeclaration createNamespaceDeclaration(CoreDocument document, String prefix, String namespaceURI);
}
Modified: webservices/axiom/branches/attrs-aspects/aspects/dom-aspects/src/main/java/org/apache/axiom/dom/DOMElementSupport.aj
URL: http://svn.apache.org/viewvc/webservices/axiom/branches/attrs-aspects/aspects/dom-aspects/src/main/java/org/apache/axiom/dom/DOMElementSupport.aj?rev=1685295&r1=1685294&r2=1685295&view=diff
==============================================================================
--- webservices/axiom/branches/attrs-aspects/aspects/dom-aspects/src/main/java/org/apache/axiom/dom/DOMElementSupport.aj (original)
+++ webservices/axiom/branches/attrs-aspects/aspects/dom-aspects/src/main/java/org/apache/axiom/dom/DOMElementSupport.aj Sat Jun 13 18:02:01 2015
@@ -143,4 +143,9 @@ public aspect DOMElementSupport {
public final boolean DOMElement.hasAttributeNS(String namespaceURI, String localName) {
return getAttributeNodeNS(namespaceURI, localName) != null;
}
+
+ public final void DOMElement.setAttribute(String name, String value) {
+ NSUtil.validateName(name);
+ coreSetAttribute(Policies.DOM1_ATTRIBUTE_MATCHER, null, name, null, value);
+ }
}
Added: webservices/axiom/branches/attrs-aspects/aspects/dom-aspects/src/main/java/org/apache/axiom/dom/DOMNSUnawareAttribute.java
URL: http://svn.apache.org/viewvc/webservices/axiom/branches/attrs-aspects/aspects/dom-aspects/src/main/java/org/apache/axiom/dom/DOMNSUnawareAttribute.java?rev=1685295&view=auto
==============================================================================
--- webservices/axiom/branches/attrs-aspects/aspects/dom-aspects/src/main/java/org/apache/axiom/dom/DOMNSUnawareAttribute.java (added)
+++ webservices/axiom/branches/attrs-aspects/aspects/dom-aspects/src/main/java/org/apache/axiom/dom/DOMNSUnawareAttribute.java Sat Jun 13 18:02:01 2015
@@ -0,0 +1,25 @@
+/*
+ * 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.dom;
+
+import org.apache.axiom.core.CoreNSUnawareAttribute;
+
+public interface DOMNSUnawareAttribute extends DOMAttribute, DOMNSUnawareNamedNode, CoreNSUnawareAttribute {
+
+}
Propchange: webservices/axiom/branches/attrs-aspects/aspects/dom-aspects/src/main/java/org/apache/axiom/dom/DOMNSUnawareAttribute.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: webservices/axiom/branches/attrs-aspects/aspects/dom-aspects/src/main/java/org/apache/axiom/dom/DOMNSUnawareAttributeSupport.aj
URL: http://svn.apache.org/viewvc/webservices/axiom/branches/attrs-aspects/aspects/dom-aspects/src/main/java/org/apache/axiom/dom/DOMNSUnawareAttributeSupport.aj?rev=1685295&view=auto
==============================================================================
--- webservices/axiom/branches/attrs-aspects/aspects/dom-aspects/src/main/java/org/apache/axiom/dom/DOMNSUnawareAttributeSupport.aj (added)
+++ webservices/axiom/branches/attrs-aspects/aspects/dom-aspects/src/main/java/org/apache/axiom/dom/DOMNSUnawareAttributeSupport.aj Sat Jun 13 18:02:01 2015
@@ -0,0 +1,25 @@
+/*
+ * 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.dom;
+
+public aspect DOMNSUnawareAttributeSupport {
+ public final String DOMNSUnawareAttribute.getName() {
+ return coreGetName();
+ }
+}
Propchange: webservices/axiom/branches/attrs-aspects/aspects/dom-aspects/src/main/java/org/apache/axiom/dom/DOMNSUnawareAttributeSupport.aj
------------------------------------------------------------------------------
svn:eol-style = native
Added: webservices/axiom/branches/attrs-aspects/aspects/dom-aspects/src/main/java/org/apache/axiom/dom/DOMNSUnawareNamedNode.java
URL: http://svn.apache.org/viewvc/webservices/axiom/branches/attrs-aspects/aspects/dom-aspects/src/main/java/org/apache/axiom/dom/DOMNSUnawareNamedNode.java?rev=1685295&view=auto
==============================================================================
--- webservices/axiom/branches/attrs-aspects/aspects/dom-aspects/src/main/java/org/apache/axiom/dom/DOMNSUnawareNamedNode.java (added)
+++ webservices/axiom/branches/attrs-aspects/aspects/dom-aspects/src/main/java/org/apache/axiom/dom/DOMNSUnawareNamedNode.java Sat Jun 13 18:02:01 2015
@@ -0,0 +1,25 @@
+/*
+ * 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.dom;
+
+import org.apache.axiom.core.CoreNSUnawareNamedNode;
+
+public interface DOMNSUnawareNamedNode extends CoreNSUnawareNamedNode, DOMNode {
+
+}
Propchange: webservices/axiom/branches/attrs-aspects/aspects/dom-aspects/src/main/java/org/apache/axiom/dom/DOMNSUnawareNamedNode.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: webservices/axiom/branches/attrs-aspects/aspects/dom-aspects/src/main/java/org/apache/axiom/dom/DOMNSUnawareNamedNodeSupport.aj
URL: http://svn.apache.org/viewvc/webservices/axiom/branches/attrs-aspects/aspects/dom-aspects/src/main/java/org/apache/axiom/dom/DOMNSUnawareNamedNodeSupport.aj?rev=1685295&view=auto
==============================================================================
--- webservices/axiom/branches/attrs-aspects/aspects/dom-aspects/src/main/java/org/apache/axiom/dom/DOMNSUnawareNamedNodeSupport.aj (added)
+++ webservices/axiom/branches/attrs-aspects/aspects/dom-aspects/src/main/java/org/apache/axiom/dom/DOMNSUnawareNamedNodeSupport.aj Sat Jun 13 18:02:01 2015
@@ -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.dom;
+
+import org.w3c.dom.DOMException;
+
+public aspect DOMNSUnawareNamedNodeSupport {
+ public final String DOMNSUnawareNamedNode.getNamespaceURI() {
+ return null;
+ }
+
+ public final String DOMNSUnawareNamedNode.getPrefix() {
+ return null;
+ }
+
+ public final void DOMNSUnawareNamedNode.setPrefix(String prefix) throws DOMException {
+ throw DOMExceptionUtil.newDOMException(DOMException.NAMESPACE_ERR);
+ }
+
+ public final String DOMNSUnawareNamedNode.getLocalName() {
+ return null;
+ }
+}
Propchange: webservices/axiom/branches/attrs-aspects/aspects/dom-aspects/src/main/java/org/apache/axiom/dom/DOMNSUnawareNamedNodeSupport.aj
------------------------------------------------------------------------------
svn:eol-style = native
Added: webservices/axiom/branches/attrs-aspects/aspects/dom-aspects/src/main/java/org/apache/axiom/dom/NSUtil.java
URL: http://svn.apache.org/viewvc/webservices/axiom/branches/attrs-aspects/aspects/dom-aspects/src/main/java/org/apache/axiom/dom/NSUtil.java?rev=1685295&view=auto
==============================================================================
--- webservices/axiom/branches/attrs-aspects/aspects/dom-aspects/src/main/java/org/apache/axiom/dom/NSUtil.java (added)
+++ webservices/axiom/branches/attrs-aspects/aspects/dom-aspects/src/main/java/org/apache/axiom/dom/NSUtil.java Sat Jun 13 18:02:01 2015
@@ -0,0 +1,128 @@
+/*
+ * 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.dom;
+
+import javax.xml.XMLConstants;
+
+import org.w3c.dom.DOMException;
+
+public final class NSUtil {
+ private NSUtil() {}
+
+ // This is the NameStartChar production from http://www.w3.org/TR/2008/REC-xml-20081126/
+ private static boolean isNameStartChar(char c) {
+ return c == ':' || 'A' <= c && c <= 'Z' || c == '_' || 'a' <= c && c <= 'z' || 0xC0 <= c && c <= 0xD6
+ || 0xD8 <= c && c <= 0xF6 || 0xF8 <= c && c <= 0x2FF || 0x370 <= c && c <= 0x37D
+ || 0x37F <= c && c <= 0x1FFF || 0x200C <= c && c <= 0x200D
+ || 0x2070 <= c && c <= 0x218F || 0x2C00 <= c && c <= 0x2FEF
+ || 0x3001 <= c && c <= 0xD7FF || 0xF900 <= c && c <= 0xFDCF
+ || 0xFDF0 <= c && c <= 0xFFFD || 0x10000 <= c && c <= 0xEFFFF;
+ }
+
+ // This is the NameChar production from http://www.w3.org/TR/2008/REC-xml-20081126/
+ private static boolean isNameChar(char c) {
+ return isNameStartChar(c) || c == '-' || c == '.' || '0' <= c && c <= '9' || c == 0xB7
+ || 0x0300 <= c && c <= 0x036F || 0x203F <= c && c <= 0x2040;
+ }
+
+ public static void validateName(String name) throws DOMException {
+ if (name.length() == 0) {
+ throw DOMExceptionUtil.newDOMException(DOMException.INVALID_CHARACTER_ERR);
+ }
+ for (int i=0; i<name.length(); i++) {
+ char c = name.charAt(i);
+ if (i == 0 && !isNameStartChar(c) || i > 0 && !isNameChar(c)) {
+ throw DOMExceptionUtil.newDOMException(DOMException.INVALID_CHARACTER_ERR);
+ }
+ }
+ }
+
+ public static void validatePrefix(String prefix) throws DOMException {
+ for (int i=0; i<prefix.length(); i++) {
+ char c = prefix.charAt(i);
+ if (c == ':') {
+ throw DOMExceptionUtil.newDOMException(DOMException.NAMESPACE_ERR);
+ }
+ if (i == 0 && !isNameStartChar(c) || i > 0 && !isNameChar(c)) {
+ throw DOMExceptionUtil.newDOMException(DOMException.INVALID_CHARACTER_ERR);
+ }
+ }
+ }
+
+ public static int validateQualifiedName(String qualifiedName) throws DOMException {
+ if (qualifiedName.length() == 0) {
+ throw DOMExceptionUtil.newDOMException(DOMException.INVALID_CHARACTER_ERR);
+ }
+ int colonPosition = -1;
+ boolean checkNameStart = true;
+ for (int i=0; i<qualifiedName.length(); i++) {
+ char c = qualifiedName.charAt(i);
+ if (c == ':') {
+ if (colonPosition == -1 && i > 0) {
+ colonPosition = i;
+ checkNameStart = true;
+ } else {
+ throw DOMExceptionUtil.newDOMException(DOMException.NAMESPACE_ERR);
+ }
+ } else if (checkNameStart && !isNameStartChar(c) || i > 0 && !isNameChar(c)) {
+ throw DOMExceptionUtil.newDOMException(DOMException.INVALID_CHARACTER_ERR);
+ } else {
+ checkNameStart = false;
+ }
+ }
+ if (checkNameStart) {
+ // If we get here, then the qualified name ends with a colon
+ throw DOMExceptionUtil.newDOMException(DOMException.NAMESPACE_ERR);
+ }
+ return colonPosition;
+ }
+
+ public static String normalizeNamespaceURI(String namespaceURI) {
+ return namespaceURI == null ? "" : namespaceURI;
+ }
+
+ public static void validateNamespace(String namespaceURI, String prefix) {
+ if (prefix.length() != 0 && namespaceURI.length() == 0) {
+ throw DOMExceptionUtil.newDOMException(DOMException.NAMESPACE_ERR);
+ }
+ if (XMLConstants.XML_NS_PREFIX.equals(prefix) && !XMLConstants.XML_NS_URI.equals(namespaceURI)) {
+ throw DOMExceptionUtil.newDOMException(DOMException.NAMESPACE_ERR);
+ }
+ }
+
+ public static void validateAttributeName(String namespaceURI, String localName, String prefix) {
+ validateNamespace(namespaceURI, prefix);
+ if (prefix.length() == 0 && localName.equals(XMLConstants.XMLNS_ATTRIBUTE) && !namespaceURI.equals(XMLConstants.XMLNS_ATTRIBUTE_NS_URI)) {
+ throw DOMExceptionUtil.newDOMException(DOMException.NAMESPACE_ERR);
+ }
+ if (XMLConstants.XMLNS_ATTRIBUTE.equals(prefix)) {
+ throw DOMExceptionUtil.newDOMException(DOMException.NAMESPACE_ERR);
+ }
+ }
+
+ public static String getDeclaredPrefix(String localName, String prefix) {
+ if (prefix.equals(XMLConstants.XMLNS_ATTRIBUTE)) {
+ return localName;
+ } else if (prefix.length() == 0 && localName.equals(XMLConstants.XMLNS_ATTRIBUTE)) {
+ return "";
+ } else {
+ throw DOMExceptionUtil.newDOMException(DOMException.NAMESPACE_ERR);
+ }
+ }
+}
Propchange: webservices/axiom/branches/attrs-aspects/aspects/dom-aspects/src/main/java/org/apache/axiom/dom/NSUtil.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: webservices/axiom/branches/attrs-aspects/aspects/dom-aspects/src/main/java/org/apache/axiom/dom/Policies.java
URL: http://svn.apache.org/viewvc/webservices/axiom/branches/attrs-aspects/aspects/dom-aspects/src/main/java/org/apache/axiom/dom/Policies.java?rev=1685295&r1=1685294&r2=1685295&view=diff
==============================================================================
--- webservices/axiom/branches/attrs-aspects/aspects/dom-aspects/src/main/java/org/apache/axiom/dom/Policies.java (original)
+++ webservices/axiom/branches/attrs-aspects/aspects/dom-aspects/src/main/java/org/apache/axiom/dom/Policies.java Sat Jun 13 18:02:01 2015
@@ -19,10 +19,53 @@
package org.apache.axiom.dom;
import org.apache.axiom.core.AttributeMatcher;
+import org.apache.axiom.core.CoreAttribute;
+import org.apache.axiom.core.CoreDocument;
import org.apache.axiom.core.NSAwareAttributeMatcher;
+import org.apache.axiom.core.NodeFactory;
public final class Policies {
private Policies() {}
+ /**
+ * {@link AttributeMatcher} implementation that matches attributes based on their name, i.e.
+ * based on the prefix and local name for namespace aware attributes. Parameters are defined as
+ * follows:
+ * <dl>
+ * <dt><code>namespaceURI</code>
+ * <dd>Not used.
+ * <dt><code>name</code>
+ * <dd>The qualified name of the attribute. This value may be in the form
+ * <code>prefix:localName</code>.
+ * <dt><code>value</code>
+ * <dd>The attribute value.
+ * <dt><code>prefix</code>
+ * <dd>Not used.
+ * </dl>
+ */
+ public static final AttributeMatcher DOM1_ATTRIBUTE_MATCHER = new AttributeMatcher() {
+ public boolean matches(CoreAttribute attr, String namespaceURI, String name) {
+ // Note: a lookup using DOM 1 methods may return any kind of attribute, including
+ // namespace declarations
+ return name.equals(((DOMAttribute)attr).getName());
+ }
+
+ public String getNamespaceURI(CoreAttribute attr) {
+ return null;
+ }
+
+ public String getName(CoreAttribute attr) {
+ return ((DOMAttribute)attr).getName();
+ }
+
+ public CoreAttribute createAttribute(NodeFactory nodeFactory, CoreDocument document, String namespaceURI, String name, String prefix, String value) {
+ return nodeFactory.createAttribute(document, name, value, null);
+ }
+
+ public void update(CoreAttribute attr, String prefix, String value) {
+ attr.coreSetValue(value);
+ }
+ };
+
public static final AttributeMatcher DOM2_ATTRIBUTE_MATCHER = new NSAwareAttributeMatcher(true, true);
}
Modified: webservices/axiom/branches/attrs-aspects/implementations/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/ElementImpl.java
URL: http://svn.apache.org/viewvc/webservices/axiom/branches/attrs-aspects/implementations/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/ElementImpl.java?rev=1685295&r1=1685294&r2=1685295&view=diff
==============================================================================
--- webservices/axiom/branches/attrs-aspects/implementations/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/ElementImpl.java (original)
+++ webservices/axiom/branches/attrs-aspects/implementations/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/ElementImpl.java Sat Jun 13 18:02:01 2015
@@ -22,6 +22,7 @@ package org.apache.axiom.om.impl.dom;
import static org.apache.axiom.dom.DOMExceptionUtil.newDOMException;
import org.apache.axiom.core.AttributeMatcher;
+import org.apache.axiom.core.CoreAttribute;
import org.apache.axiom.core.CoreModelException;
import org.apache.axiom.core.NodeMigrationException;
import org.apache.axiom.core.NodeMigrationPolicy;
@@ -228,28 +229,6 @@ public class ElementImpl extends ParentN
}
- /*
- * (non-Javadoc)
- *
- * @see org.w3c.dom.Element#setAttribute(java.lang.String, java.lang.String)
- */
- public void setAttribute(String name, String value) throws DOMException {
- // Check for invalid charaters
- if (!DOMUtil.isQualifiedName(name)) {
- throw newDOMException(DOMException.INVALID_CHARACTER_ERR);
- }
- if (name.startsWith(XMLConstants.XMLNS_ATTRIBUTE + ":")) {
- // This is a ns declaration
- this.declareNamespace(value, DOMUtil.getLocalName(name));
- } else if (name.equals(XMLConstants.XMLNS_ATTRIBUTE)) {
- this.declareDefaultNamespace(value);
- } else {
- this.setAttributeNode(new NSAwareAttribute(ownerDocument(), name, value,
- getOMFactory()));
- }
-
- }
-
public Attr setAttributeNodeNS(Attr attr) throws DOMException {
return setAttributeNodeNS(attr, true, false);
}
@@ -493,17 +472,21 @@ public class ElementImpl extends ParentN
}
public OMNamespace findNamespaceURI(String prefix) {
- if (attributes != null) {
- Attr decl = (Attr)attributes.getNamedItemNS(XMLConstants.XMLNS_ATTRIBUTE_NS_URI, prefix.length() == 0 ? XMLConstants.XMLNS_ATTRIBUTE : prefix);
- if (decl != null) {
- String namespaceURI = decl.getValue();
- if (prefix != null && prefix.length() > 0 && namespaceURI.length() == 0) {
- // Prefix undeclaring case (XML 1.1 only)
- return null;
- } else {
- return new OMNamespaceImpl(namespaceURI, prefix);
+ CoreAttribute attr = coreGetFirstAttribute();
+ while (attr != null) {
+ if (attr instanceof NamespaceDeclaration) {
+ NamespaceDeclaration nsDecl = (NamespaceDeclaration)attr;
+ if (nsDecl.coreGetDeclaredPrefix().equals(prefix)) {
+ OMNamespace ns = nsDecl.getDeclaredNamespace();
+ if (prefix != null && prefix.length() > 0 && ns.getNamespaceURI().length() == 0) {
+ // Prefix undeclaring case (XML 1.1 only)
+ return null;
+ } else {
+ return ns;
+ }
}
}
+ attr = attr.coreGetNextAttribute();
}
ParentNode parentNode = (ParentNode)coreGetParent();
if (parentNode instanceof OMElement) {
Modified: webservices/axiom/branches/attrs-aspects/implementations/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/NSAwareAttribute.java
URL: http://svn.apache.org/viewvc/webservices/axiom/branches/attrs-aspects/implementations/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/NSAwareAttribute.java?rev=1685295&r1=1685294&r2=1685295&view=diff
==============================================================================
--- webservices/axiom/branches/attrs-aspects/implementations/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/NSAwareAttribute.java (original)
+++ webservices/axiom/branches/attrs-aspects/implementations/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/NSAwareAttribute.java Sat Jun 13 18:02:01 2015
@@ -32,7 +32,7 @@ import org.apache.axiom.om.impl.common.A
import org.apache.axiom.om.impl.common.OMNamespaceImpl;
import org.w3c.dom.Attr;
-public final class NSAwareAttribute extends AttrImpl implements OMAttributeEx, AxiomAttribute, NamedNode, CoreNSAwareAttribute {
+public final class NSAwareAttribute extends TypedAttribute implements OMAttributeEx, AxiomAttribute, NamedNode, CoreNSAwareAttribute {
// TODO: copy isId?
NSAwareAttribute(String localName, OMNamespace namespace, String type, OMFactory factory) {
super(null, factory);
@@ -188,14 +188,4 @@ public final class NSAwareAttribute exte
// TODO
return new NSAwareAttribute(getLocalName(), getNamespace(), type, getOMFactory());
}
-
- public String coreGetType() {
- // TODO Auto-generated method stub
- throw new UnsupportedOperationException();
- }
-
- public void coreSetType(String type) {
- // TODO Auto-generated method stub
- throw new UnsupportedOperationException();
- }
}
Added: webservices/axiom/branches/attrs-aspects/implementations/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/NSUnawareAttribute.java
URL: http://svn.apache.org/viewvc/webservices/axiom/branches/attrs-aspects/implementations/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/NSUnawareAttribute.java?rev=1685295&view=auto
==============================================================================
--- webservices/axiom/branches/attrs-aspects/implementations/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/NSUnawareAttribute.java (added)
+++ webservices/axiom/branches/attrs-aspects/implementations/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/NSUnawareAttribute.java Sat Jun 13 18:02:01 2015
@@ -0,0 +1,42 @@
+/*
+ * 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.dom;
+
+import org.apache.axiom.core.NodeFactory;
+import org.apache.axiom.dom.DOMNSUnawareAttribute;
+import org.apache.axiom.om.OMCloneOptions;
+import org.apache.axiom.om.OMFactory;
+
+public class NSUnawareAttribute extends TypedAttribute implements DOMNSUnawareAttribute {
+ public NSUnawareAttribute(DocumentImpl ownerDocument, OMFactory factory) {
+ super(ownerDocument, factory);
+ }
+
+ public final NodeFactory coreGetNodeFactory() {
+ return ((NodeFactory)getOMFactory());
+ }
+
+ @Override
+ ParentNode shallowClone(OMCloneOptions options, ParentNode targetParent,
+ boolean namespaceRepairing) {
+ // TODO Auto-generated method stub
+ throw new UnsupportedOperationException();
+ }
+
+}
Propchange: webservices/axiom/branches/attrs-aspects/implementations/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/NSUnawareAttribute.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: webservices/axiom/branches/attrs-aspects/implementations/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/NamespaceDeclaration.java
URL: http://svn.apache.org/viewvc/webservices/axiom/branches/attrs-aspects/implementations/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/NamespaceDeclaration.java?rev=1685295&r1=1685294&r2=1685295&view=diff
==============================================================================
--- webservices/axiom/branches/attrs-aspects/implementations/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/NamespaceDeclaration.java (original)
+++ webservices/axiom/branches/attrs-aspects/implementations/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/NamespaceDeclaration.java Sat Jun 13 18:02:01 2015
@@ -46,6 +46,10 @@ final class NamespaceDeclaration extends
return getValue();
}
+ public final OMNamespace getDeclaredNamespace() {
+ return declaredNamespace;
+ }
+
@Override
final ParentNode shallowClone(OMCloneOptions options, ParentNode targetParent,
boolean namespaceRepairing) {
Added: webservices/axiom/branches/attrs-aspects/implementations/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/TypedAttribute.java
URL: http://svn.apache.org/viewvc/webservices/axiom/branches/attrs-aspects/implementations/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/TypedAttribute.java?rev=1685295&view=auto
==============================================================================
--- webservices/axiom/branches/attrs-aspects/implementations/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/TypedAttribute.java (added)
+++ webservices/axiom/branches/attrs-aspects/implementations/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/TypedAttribute.java Sat Jun 13 18:02:01 2015
@@ -0,0 +1,37 @@
+/*
+ * 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.dom;
+
+import org.apache.axiom.om.OMFactory;
+
+public abstract class TypedAttribute extends AttrImpl {
+ public TypedAttribute(DocumentImpl ownerDocument, OMFactory factory) {
+ super(ownerDocument, factory);
+ }
+
+ public String coreGetType() {
+ // TODO Auto-generated method stub
+ throw new UnsupportedOperationException();
+ }
+
+ public void coreSetType(String type) {
+ // TODO Auto-generated method stub
+ throw new UnsupportedOperationException();
+ }
+}
Propchange: webservices/axiom/branches/attrs-aspects/implementations/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/TypedAttribute.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: webservices/axiom/branches/attrs-aspects/implementations/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/factory/OMDOMFactory.java
URL: http://svn.apache.org/viewvc/webservices/axiom/branches/attrs-aspects/implementations/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/factory/OMDOMFactory.java?rev=1685295&r1=1685294&r2=1685295&view=diff
==============================================================================
--- webservices/axiom/branches/attrs-aspects/implementations/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/factory/OMDOMFactory.java (original)
+++ webservices/axiom/branches/attrs-aspects/implementations/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/factory/OMDOMFactory.java Sat Jun 13 18:02:01 2015
@@ -23,6 +23,7 @@ import org.apache.axiom.core.CoreCDATASe
import org.apache.axiom.core.CoreCharacterData;
import org.apache.axiom.core.CoreDocument;
import org.apache.axiom.core.CoreNSAwareAttribute;
+import org.apache.axiom.core.CoreNSUnawareAttribute;
import org.apache.axiom.core.CoreNamespaceDeclaration;
import org.apache.axiom.om.OMAttribute;
import org.apache.axiom.om.OMComment;
@@ -45,7 +46,6 @@ import org.apache.axiom.om.impl.OMContai
import org.apache.axiom.om.impl.builder.StAXOMBuilder;
import org.apache.axiom.om.impl.common.OMNamespaceImpl;
import org.apache.axiom.om.impl.common.factory.AxiomNodeFactory;
-import org.apache.axiom.om.impl.dom.AttrImpl;
import org.apache.axiom.om.impl.dom.CDATASectionImpl;
import org.apache.axiom.om.impl.dom.CommentImpl;
import org.apache.axiom.om.impl.dom.DocumentImpl;
@@ -53,6 +53,7 @@ import org.apache.axiom.om.impl.dom.Docu
import org.apache.axiom.om.impl.dom.ElementImpl;
import org.apache.axiom.om.impl.dom.EntityReferenceImpl;
import org.apache.axiom.om.impl.dom.NSAwareAttribute;
+import org.apache.axiom.om.impl.dom.NSUnawareAttribute;
import org.apache.axiom.om.impl.dom.OMDOMException;
import org.apache.axiom.om.impl.dom.ParentNode;
import org.apache.axiom.om.impl.dom.ProcessingInstructionImpl;
@@ -326,9 +327,17 @@ public class OMDOMFactory implements Axi
return new CDATASectionImpl(this);
}
- public CoreNSAwareAttribute createAttribute(CoreDocument document, String namespaceURI,
+ public final CoreNSUnawareAttribute createAttribute(CoreDocument document, String name, String value, String type) {
+ NSUnawareAttribute attr = new NSUnawareAttribute((DocumentImpl)document, this);
+ attr.coreSetName(name);
+ attr.coreSetValue(value);
+// attr.coreSetType(type);
+ return attr;
+ }
+
+ public final CoreNSAwareAttribute createAttribute(CoreDocument document, String namespaceURI,
String localName, String prefix, String value, String type) {
- return new NSAwareAttribute((DocumentImpl)document, localName, namespaceURI.isEmpty() ? null : new OMNamespaceImpl(namespaceURI, prefix), this);
+ return new NSAwareAttribute((DocumentImpl)document, localName, namespaceURI.isEmpty() ? null : new OMNamespaceImpl(namespaceURI, prefix), value, this);
}
public final CoreNamespaceDeclaration createNamespaceDeclaration(CoreDocument document,