You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commons-dev@ws.apache.org by ve...@apache.org on 2008/12/22 19:06:04 UTC
svn commit: r728734 - in /webservices/commons/trunk/modules/axiom/modules:
axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/ axiom-integration/
axiom-integration/src/test/java/org/apache/axiom/om/impl/dom/jaxp/
axiom-integration/src/test/resources/...
Author: veithen
Date: Mon Dec 22 10:06:04 2008
New Revision: 728734
URL: http://svn.apache.org/viewvc?rev=728734&view=rev
Log:
WSCOMMONS-420: Added test to validate integration between DOOM and javax.xml.validation. Implemented some more DOM methods to support this (with Xerces 2.9.1).
Added:
webservices/commons/trunk/modules/axiom/modules/axiom-integration/src/test/java/org/apache/axiom/om/impl/dom/jaxp/ValidatorTest.java (with props)
webservices/commons/trunk/modules/axiom/modules/axiom-integration/src/test/resources/org/apache/axiom/om/impl/dom/jaxp/ipo.xsd (with props)
webservices/commons/trunk/modules/axiom/modules/axiom-integration/src/test/resources/org/apache/axiom/om/impl/dom/jaxp/ipo_1.xml (with props)
Modified:
webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/DOMImplementationImpl.java
webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/DocumentImpl.java
webservices/commons/trunk/modules/axiom/modules/axiom-integration/pom.xml
Modified: webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/DOMImplementationImpl.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/DOMImplementationImpl.java?rev=728734&r1=728733&r2=728734&view=diff
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/DOMImplementationImpl.java (original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/DOMImplementationImpl.java Mon Dec 22 10:06:04 2008
@@ -27,9 +27,10 @@
public class DOMImplementationImpl implements DOMImplementation {
- public boolean hasFeature(String arg0, String arg1) {
- // TODO
- throw new UnsupportedOperationException("TODO");
+ public boolean hasFeature(String feature, String version) {
+ boolean anyVersion = version == null || version.length() == 0;
+ return (feature.equalsIgnoreCase("Core") || feature.equalsIgnoreCase("XML"))
+ && (anyVersion || version.equals("1.0") || version.equals("2.0"));
}
public Document createDocument(String namespaceURI, String qualifiedName,
Modified: webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/DocumentImpl.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/DocumentImpl.java?rev=728734&r1=728733&r2=728734&view=diff
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/DocumentImpl.java (original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/DocumentImpl.java Mon Dec 22 10:06:04 2008
@@ -275,8 +275,7 @@
}
public DOMImplementation getImplementation() {
- // TODO
- throw new UnsupportedOperationException("TODO");
+ return new DOMImplementationImpl();
}
public Node importNode(Node importedNode, boolean deep) throws DOMException {
Modified: webservices/commons/trunk/modules/axiom/modules/axiom-integration/pom.xml
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-integration/pom.xml?rev=728734&r1=728733&r2=728734&view=diff
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-integration/pom.xml (original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-integration/pom.xml Mon Dec 22 10:06:04 2008
@@ -68,6 +68,11 @@
<version>2.1.9</version>
</dependency>
<dependency>
+ <groupId>xerces</groupId>
+ <artifactId>xercesImpl</artifactId>
+ <version>2.9.1</version>
+ </dependency>
+ <dependency>
<groupId>xalan</groupId>
<artifactId>xalan</artifactId>
<version>2.7.1</version>
Added: webservices/commons/trunk/modules/axiom/modules/axiom-integration/src/test/java/org/apache/axiom/om/impl/dom/jaxp/ValidatorTest.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-integration/src/test/java/org/apache/axiom/om/impl/dom/jaxp/ValidatorTest.java?rev=728734&view=auto
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-integration/src/test/java/org/apache/axiom/om/impl/dom/jaxp/ValidatorTest.java (added)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-integration/src/test/java/org/apache/axiom/om/impl/dom/jaxp/ValidatorTest.java Mon Dec 22 10:06:04 2008
@@ -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.om.impl.dom.jaxp;
+
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.transform.dom.DOMSource;
+import javax.xml.validation.Schema;
+import javax.xml.validation.SchemaFactory;
+import javax.xml.validation.Validator;
+
+import org.apache.xerces.jaxp.validation.XMLSchemaFactory;
+
+import junit.framework.TestCase;
+
+public class ValidatorTest extends TestCase {
+ public void test() throws Exception {
+ SchemaFactory factory = new XMLSchemaFactory();
+ DocumentBuilderFactory dbf = new DOOMDocumentBuilderFactory();
+ DocumentBuilder builder = dbf.newDocumentBuilder();
+ Schema schema = factory.newSchema(new DOMSource(
+ builder.parse(ValidatorTest.class.getResourceAsStream("ipo.xsd"))));
+ Validator validator = schema.newValidator();
+ validator.validate(new DOMSource(
+ builder.parse(ValidatorTest.class.getResourceAsStream("ipo_1.xml"))));
+ }
+}
Propchange: webservices/commons/trunk/modules/axiom/modules/axiom-integration/src/test/java/org/apache/axiom/om/impl/dom/jaxp/ValidatorTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: webservices/commons/trunk/modules/axiom/modules/axiom-integration/src/test/resources/org/apache/axiom/om/impl/dom/jaxp/ipo.xsd
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-integration/src/test/resources/org/apache/axiom/om/impl/dom/jaxp/ipo.xsd?rev=728734&view=auto
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-integration/src/test/resources/org/apache/axiom/om/impl/dom/jaxp/ipo.xsd (added)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-integration/src/test/resources/org/apache/axiom/om/impl/dom/jaxp/ipo.xsd Mon Dec 22 10:06:04 2008
@@ -0,0 +1,126 @@
+<xsd:schema targetNamespace="http://www.example.com/IPO"
+ xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+ xmlns:ipo="http://www.example.com/IPO">
+
+ <xsd:element name="purchaseOrder" type="ipo:PurchaseOrderType"/>
+
+ <xsd:element name="comment" type="xsd:string"/>
+ <xsd:element name="shipComment" type="xsd:string"
+ substitutionGroup="ipo:comment"/>
+ <xsd:element name="customerComment" type="xsd:string"
+ substitutionGroup="ipo:comment"/>
+
+ <xsd:complexType name="PurchaseOrderType">
+ <xsd:sequence>
+ <xsd:choice>
+ <xsd:group ref="ipo:shipAndBill"/>
+ <xsd:element name="singleAddress" type="ipo:AddressType"/>
+ </xsd:choice>
+ <xsd:element ref="ipo:comment" minOccurs="0"/>
+ <xsd:element name="items" type="ipo:ItemsType"/>
+ </xsd:sequence>
+ <xsd:attribute name="orderDate" type="xsd:date"/>
+ </xsd:complexType>
+
+ <xsd:group name="shipAndBill">
+ <xsd:sequence>
+ <xsd:element name="shipTo" type="ipo:AddressType"/>
+ <xsd:element name="billTo" type="ipo:AddressType"/>
+ </xsd:sequence>
+ </xsd:group>
+
+
+ <xsd:complexType name="AddressType">
+ <xsd:sequence>
+ <xsd:element name="name" type="xsd:string"/>
+ <xsd:element name="street" type="xsd:string"/>
+ <xsd:element name="city" type="xsd:string"/>
+ </xsd:sequence>
+ </xsd:complexType>
+
+ <xsd:complexType name="USAddress">
+ <xsd:complexContent>
+ <xsd:extension base="ipo:AddressType">
+ <xsd:sequence>
+ <xsd:element name="state" type="ipo:USState"/>
+ <xsd:element name="zip" type="xsd:positiveInteger"/>
+ </xsd:sequence>
+ </xsd:extension>
+ </xsd:complexContent>
+ </xsd:complexType>
+
+ <xsd:complexType name="UKAddress">
+ <xsd:complexContent>
+ <xsd:extension base="ipo:AddressType">
+ <xsd:sequence>
+ <xsd:element name="postcode" type="ipo:UKPostcode"/>
+ </xsd:sequence>
+ <xsd:attribute name="exportCode" type="xsd:positiveInteger" fixed="1"/>
+ </xsd:extension>
+ </xsd:complexContent>
+ </xsd:complexType>
+
+ <!-- other Address derivations for more countries -->
+ <xsd:simpleType name="USState">
+ <xsd:restriction base="xsd:string">
+ <xsd:enumeration value="AK"/>
+ <xsd:enumeration value="AL"/>
+ <xsd:enumeration value="AR"/>
+ <xsd:enumeration value="CA"/>
+ <!-- and so on ... -->
+ <xsd:enumeration value="PA"/>
+ </xsd:restriction>
+ </xsd:simpleType>
+
+ <!-- simple type definition for UKPostcode -->
+ <xsd:simpleType name="UKPostcode">
+ <xsd:restriction base="xsd:string">
+ <xsd:pattern value="[A-Z]{2}\d\s\d[A-Z]{2}"/>
+ </xsd:restriction>
+ </xsd:simpleType>
+
+<xsd:complexType name="ItemsType" mixed="true">
+ <xsd:sequence>
+ <xsd:element name="item" minOccurs="0" maxOccurs="unbounded">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="productName" type="xsd:string"/>
+ <xsd:element name="quantity">
+ <xsd:simpleType>
+ <xsd:restriction base="xsd:positiveInteger">
+ <xsd:maxExclusive value="100"/>
+ </xsd:restriction>
+ </xsd:simpleType>
+ </xsd:element>
+ <xsd:element name="USPrice" type="xsd:decimal"/>
+ <xsd:element ref="ipo:comment" minOccurs="0" maxOccurs="2"/>
+ <xsd:element name="shipDate" type="xsd:date" minOccurs="0"/>
+ </xsd:sequence>
+ <!-- attributeGroup replaces individual declarations -->
+ <xsd:attributeGroup ref="ipo:ItemDelivery"/>
+ </xsd:complexType>
+ </xsd:element>
+ </xsd:sequence>
+</xsd:complexType>
+
+<xsd:attributeGroup name="ItemDelivery">
+ <xsd:attribute name="partNum" type="ipo:SKU" use="required"/>
+ <xsd:attribute name="weightKg" type="xsd:decimal"/>
+ <xsd:attribute name="shipBy">
+ <xsd:simpleType>
+ <xsd:restriction base="xsd:string">
+ <xsd:enumeration value="air"/>
+ <xsd:enumeration value="land"/>
+ <xsd:enumeration value="any"/>
+ </xsd:restriction>
+ </xsd:simpleType>
+ </xsd:attribute>
+</xsd:attributeGroup>
+
+ <xsd:simpleType name="SKU">
+ <xsd:restriction base="xsd:string">
+ <xsd:pattern value="\d{3}-[A-Z]{2}"/>
+ </xsd:restriction>
+ </xsd:simpleType>
+
+</xsd:schema>
\ No newline at end of file
Propchange: webservices/commons/trunk/modules/axiom/modules/axiom-integration/src/test/resources/org/apache/axiom/om/impl/dom/jaxp/ipo.xsd
------------------------------------------------------------------------------
svn:eol-style = native
Added: webservices/commons/trunk/modules/axiom/modules/axiom-integration/src/test/resources/org/apache/axiom/om/impl/dom/jaxp/ipo_1.xml
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-integration/src/test/resources/org/apache/axiom/om/impl/dom/jaxp/ipo_1.xml?rev=728734&view=auto
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-integration/src/test/resources/org/apache/axiom/om/impl/dom/jaxp/ipo_1.xml (added)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-integration/src/test/resources/org/apache/axiom/om/impl/dom/jaxp/ipo_1.xml Mon Dec 22 10:06:04 2008
@@ -0,0 +1,34 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<ipo:purchaseOrder xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ipo="http://www.example.com/IPO" orderDate="2002-10-20" xsi:schemaLocation="http://www.example.com/IPO ipo.xsd">
+ <shipTo xsi:type="ipo:USAddress">
+ <name>Alice Smith</name>
+ <street>123 Maple Street</street>
+ <city>Mill Valley</city>
+ <state>AL</state>
+ <zip>90952</zip>
+ </shipTo>
+ <billTo xsi:type="ipo:USAddress">
+ <name>Robert Smith</name>
+ <street>8 Oak Avenue</street>
+ <city>Old Town</city>
+ <state>AK</state>
+ <zip>95800</zip>
+ </billTo>
+ <ipo:comment>Hurry, my sister loves Boeing!</ipo:comment>
+ <items>
+ <item partNum="777-BA" weightKg="4.5" shipBy="land">
+ <productName>777 Model</productName>
+ <quantity>1</quantity>
+ <USPrice>99.95</USPrice>
+ <ipo:shipComment> Use gold wrap if possible </ipo:shipComment>
+ <ipo:customerComment> Want this for the holidays! </ipo:customerComment>
+ <shipDate>1999-12-05</shipDate>
+ </item>
+ <item partNum="833-AA">
+ <productName>833 Model</productName>
+ <quantity>2</quantity>
+ <USPrice>199.95</USPrice>
+ <shipDate>2000-02-28</shipDate>
+ </item>
+ </items>
+</ipo:purchaseOrder>
Propchange: webservices/commons/trunk/modules/axiom/modules/axiom-integration/src/test/resources/org/apache/axiom/om/impl/dom/jaxp/ipo_1.xml
------------------------------------------------------------------------------
svn:eol-style = native