Author: veithen
Date: Sun Jan 23 11:31:22 2011
New Revision: 1062395
URL: http://svn.apache.org/viewvc?rev=1062395&view=rev
Log:
AXIS2-3229: Support compilation of schemas that assume that
http://www.w3.org/XML/1998/namespace is a known namespace and that no
schemaLocation is required when importing it.
Added:
axis/axis2/java/core/trunk/modules/adb-codegen/src/org/apache/axis2/schema/namespace.xsd
axis/axis2/java/core/trunk/modules/adb-codegen/test-resources/testsuite/std-schemas.xsd
Modified:
axis/axis2/java/core/trunk/modules/adb-codegen/src/org/apache/axis2/schema/SchemaCompiler.java
axis/axis2/java/core/trunk/modules/adb-codegen/sub-build.xml
Modified:
axis/axis2/java/core/trunk/modules/adb-codegen/src/org/apache/axis2/schema/SchemaCompiler.java
URL:
http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/adb-codegen/src/org/apache/axis2/schema/SchemaCompiler.java?rev=1062395&r1=1062394&r2=1062395&view=diff
==============================================================================
---
axis/axis2/java/core/trunk/modules/adb-codegen/src/org/apache/axis2/schema/SchemaCompiler.java
(original)
+++
axis/axis2/java/core/trunk/modules/adb-codegen/src/org/apache/axis2/schema/SchemaCompiler.java
Sun Jan 23 11:31:22 2011
@@ -37,6 +37,7 @@ import org.apache.ws.commons.schema.XmlS
import org.apache.ws.commons.schema.XmlSchemaAttributeGroup;
import org.apache.ws.commons.schema.XmlSchemaAttributeGroupRef;
import org.apache.ws.commons.schema.XmlSchemaChoice;
+import org.apache.ws.commons.schema.XmlSchemaCollection;
import org.apache.ws.commons.schema.XmlSchemaComplexContent;
import org.apache.ws.commons.schema.XmlSchemaComplexContentExtension;
import org.apache.ws.commons.schema.XmlSchemaComplexContentRestriction;
@@ -73,6 +74,7 @@ import org.apache.ws.commons.schema.XmlS
import org.apache.ws.commons.schema.XmlSchemaSimpleTypeRestriction;
import org.apache.ws.commons.schema.XmlSchemaSimpleTypeUnion;
import org.apache.ws.commons.schema.XmlSchemaType;
+import org.xml.sax.InputSource;
import javax.xml.namespace.QName;
import java.util.ArrayList;
@@ -373,8 +375,23 @@ public class SchemaCompiler {
while (tempIterator.hasNext()) {
Object o = tempIterator.next();
if (o instanceof XmlSchemaImport) {
- XmlSchema schema1 = ((XmlSchemaImport) o).getSchema();
- if (schema1 != null) compile(schema1, isPartofGroup);
+ XmlSchemaImport schemaImport = (XmlSchemaImport)o;
+ XmlSchema schema1 = schemaImport.getSchema();
+ if (schema1 != null) {
+ compile(schema1, isPartofGroup);
+ } else if
(schemaImport.getNamespace().equals(Constants.NS_URI_XML)) {
+ // AXIS2-3229: some Web services (e.g. MS Exchange)
assume that
+ // http://www.w3.org/XML/1998/namespace is a known
namespace and that
+ // no schemaLocation is required when importing it.
Load a local copy of
+ // the schema in that case.
+ schema1 = new XmlSchemaCollection().read(new
InputSource(
+
SchemaCompiler.class.getResource("namespace.xsd").toExternalForm()), null);
+ schemaImport.setSchema(schema1);
+ compile(schema1, isPartofGroup);
+ } else if
(!schemaImport.getNamespace().equals(Constants.URI_2001_SCHEMA_XSD)) {
+ // Give the user a hint why the schema compilation
fails...
+ log.warn("No schemaLocation for import of " +
schemaImport.getNamespace() + "; compilation may fail");
+ }
}
if (o instanceof XmlSchemaInclude) {
XmlSchema schema1 = ((XmlSchemaInclude) o).getSchema();
Added:
axis/axis2/java/core/trunk/modules/adb-codegen/src/org/apache/axis2/schema/namespace.xsd
URL:
http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/adb-codegen/src/org/apache/axis2/schema/namespace.xsd?rev=1062395&view=auto
==============================================================================
---
axis/axis2/java/core/trunk/modules/adb-codegen/src/org/apache/axis2/schema/namespace.xsd
(added)
+++
axis/axis2/java/core/trunk/modules/adb-codegen/src/org/apache/axis2/schema/namespace.xsd
Sun Jan 23 11:31:22 2011
@@ -0,0 +1,40 @@
+<?xml version='1.0'?>
+<!--
+ ~ 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.
+ -->
+<schema targetNamespace="http://www.w3.org/XML/1998/namespace"
xmlns="http://www.w3.org/2001/XMLSchema">
+ <annotation>
+ <documentation>
+ This is a simplified version of the schema for
http://www.w3.org/XML/1998/namespace
+ located at http://www.w3.org/2001/xml.xsd. It is actually closer
to the original
+ (but outdated) schema located at
http://www.w3.org/XML/1998/namespace.xsd.
+ In particular, it avoids usage of a union to represent the "lang"
attribute.
+ </documentation>
+ </annotation>
+
+ <attribute name="lang" type="language"/>
+
+ <attribute name="space" default="preserve">
+ <simpleType>
+ <restriction base="NCName">
+ <enumeration value="default"/>
+ <enumeration value="preserve"/>
+ </restriction>
+ </simpleType>
+ </attribute>
+</schema>
Modified: axis/axis2/java/core/trunk/modules/adb-codegen/sub-build.xml
URL:
http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/adb-codegen/sub-build.xml?rev=1062395&r1=1062394&r2=1062395&view=diff
==============================================================================
--- axis/axis2/java/core/trunk/modules/adb-codegen/sub-build.xml (original)
+++ axis/axis2/java/core/trunk/modules/adb-codegen/sub-build.xml Sun Jan 23
11:31:22 2011
@@ -38,7 +38,7 @@
<mkdir dir="${schema.generated.src.dir}"/>
<mkdir dir="${schema.generated.classes.dir}"/>
<!-- Run schema compiler with designated schemas -->
- <java classname="org.apache.axis2.schema.XSD2Java" fork="true">
+ <java classname="org.apache.axis2.schema.XSD2Java" fork="true"
failonerror="true">
<jvmarg line="${maven.junit.jvmargs}"/>
<classpath refid="maven.dependency.classpath"/>
<classpath location="${compiled.classes.dir}"/>
@@ -84,9 +84,10 @@
<arg file="${testsuite.source.dir}/unqualified.xsd"/>
<arg
file="${testsuite.source.dir}/unqualified/companyservice.xsd"/>
<arg file="${testsuite.source.dir}/names.xsd"/> <!--
compile only; no tests -->
+ <arg file="${testsuite.source.dir}/std-schemas.xsd"/>
<!-- compile only; no tests -->
<arg file="${schema.generated.src.dir}"/>
</java>
- <java classname="org.apache.axis2.schema.XSD2Java" fork="true">
+ <java classname="org.apache.axis2.schema.XSD2Java" fork="true"
failonerror="true">
<jvmarg line="${maven.junit.jvmargs}"/>
<classpath refid="maven.dependency.classpath"/>
<classpath location="${compiled.classes.dir}"/>
@@ -97,7 +98,7 @@
<arg file="${testsuite.source.dir}/nonamespace.xsd"/>
<arg file="${schema.generated.src.dir}"/>
</java>
- <java classname="org.apache.axis2.schema.XSD2Java" fork="true">
+ <java classname="org.apache.axis2.schema.XSD2Java" fork="true"
failonerror="true">
<jvmarg line="${maven.junit.jvmargs}"/>
<classpath refid="maven.dependency.classpath"/>
<classpath location="${compiled.classes.dir}"/>
Added:
axis/axis2/java/core/trunk/modules/adb-codegen/test-resources/testsuite/std-schemas.xsd
URL:
http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/adb-codegen/test-resources/testsuite/std-schemas.xsd?rev=1062395&view=auto
==============================================================================
---
axis/axis2/java/core/trunk/modules/adb-codegen/test-resources/testsuite/std-schemas.xsd
(added)
+++
axis/axis2/java/core/trunk/modules/adb-codegen/test-resources/testsuite/std-schemas.xsd
Sun Jan 23 11:31:22 2011
@@ -0,0 +1,29 @@
+<?xml version="1.0"?>
+<!--
+ ~ 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.
+ -->
+<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+ targetNamespace="http://apache.org/axis2/schema/std">
+ <xsd:import namespace="http://www.w3.org/XML/1998/namespace"/>
+ <xsd:complexType name="reply">
+ <xsd:sequence>
+ <xsd:element name="message" type="xsd:string" />
+ </xsd:sequence>
+ <xsd:attribute ref="xml:lang" use="optional"/>
+ </xsd:complexType>
+</xsd:schema>