1. Fixed issue WSCOMMONS-273. Also added a test case and the relevant schema file
git-svn-id: https://svn.apache.org/repos/asf/webservices/commons/branches/modules/XmlSchema/1.3.3@600703 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/pom.xml b/pom.xml
index 5a19276..99475d0 100644
--- a/pom.xml
+++ b/pom.xml
@@ -25,6 +25,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>org.apache.ws.commons.schema</groupId>
<artifactId>XmlSchema</artifactId>
+ <packaging>bundle</packaging>
<name>XmlSchema</name>
<version>1.3.3-RC2</version>
<description>Commons XMLSchema is a light weight schema object model that can be used to manipualte or
@@ -311,6 +312,19 @@
<attach>true</attach>
</configuration>
</plugin>
+ <plugin>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>maven-bundle-plugin</artifactId>
+ <version>1.0.0</version>
+ <extensions>true</extensions>
+ <configuration>
+ <instructions>
+ <Bundle-SymbolicName>${pom.artifactId}</Bundle-SymbolicName>
+ <Export-Package>org.apache.ws.commons.schema*</Export-Package>
+ <Import-Package>*</Import-Package>
+ </instructions>
+ </configuration>
+ </plugin>
</plugins>
</build>
<profiles>
@@ -346,95 +360,95 @@
<activeByDefault>true</activeByDefault>
<property>
<name>isIBM</name>
- <value>false</value>
- </property>
- </activation>
- <build>
- <plugins>
- <plugin>
- <artifactId>maven-surefire-plugin</artifactId>
- <!--
- Required to run the TestW3CSchemaBucket test
- <version>2.3-SNAPSHOT</version>
- -->
- <configuration>
- <includes>
- <include>**/*Test.java</include>
- <!-- Fails in about half of the tests
- <include>tests/w3c/TestW3CSchemaBucket.java</include>
- -->
- </includes>
- <excludes>
- <exclude>
- tests/w3c/SchemaTest.java
- </exclude>
- </excludes>
- <systemProperties>
- <!-- The default xalan TransformerFactory on the ibm jdk is
- org.apache.xalan.processor.TransformerFactoryImpl which
- has a known issue with implicit namespaces. Set this
- property to use the xsltc TransformerFactory (which
- the sun jdk seems to default to).
- -->
- <!-- <property>
- <name>javax.xml.transform.TransformerFactory</name>
- <value>com.sun.org.apache.xalan.internal.xsltc.trax.TransformerFactoryImpl</value>
- </property> -->
- </systemProperties>
- </configuration>
- </plugin>
- </plugins>
- </build>
- </profile>
- <profile>
- <id>IBMTest</id>
- <activation>
- <property>
- <name>isIBM</name>
- <value>true</value>
- </property>
- </activation>
- <build>
- <plugins>
- <plugin>
- <artifactId>maven-surefire-plugin</artifactId>
- <!--
- Required to run the TestW3CSchemaBucket test
- <version>2.3-SNAPSHOT</version>
- -->
- <configuration>
- <includes>
- <include>**/*Test.java</include>
- <!-- Fails in about half of the tests
- <include>tests/w3c/TestW3CSchemaBucket.java</include>
- -->
- </includes>
- <excludes>
- <exclude>
- tests/w3c/SchemaTest.java
- </exclude>
- </excludes>
- <systemProperties>
- <!-- The default xalan TransformerFactory on the ibm jdk is
- org.apache.xalan.processor.TransformerFactoryImpl which
- has a known issue with implicit namespaces. Set this
- property to use the xsltc TransformerFactory (which
- the sun jdk seems to default to).
- -->
- <property>
- <name>
- javax.xml.transform.TransformerFactory
- </name>
- <value>
- org.apache.xalan.xsltc.trax.TransformerFactoryImpl
- </value>
- </property>
- </systemProperties>
- </configuration>
- </plugin>
- </plugins>
- </build>
- </profile>
+ <value>false</value>
+ </property>
+ </activation>
+ <build>
+ <plugins>
+ <plugin>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <!--
+ Required to run the TestW3CSchemaBucket test
+ <version>2.3-SNAPSHOT</version>
+ -->
+ <configuration>
+ <includes>
+ <include>**/*Test.java</include>
+ <!-- Fails in about half of the tests
+ <include>tests/w3c/TestW3CSchemaBucket.java</include>
+ -->
+ </includes>
+ <excludes>
+ <exclude>
+ tests/w3c/SchemaTest.java
+ </exclude>
+ </excludes>
+ <systemProperties>
+ <!-- The default xalan TransformerFactory on the ibm jdk is
+ org.apache.xalan.processor.TransformerFactoryImpl which
+ has a known issue with implicit namespaces. Set this
+ property to use the xsltc TransformerFactory (which
+ the sun jdk seems to default to).
+ -->
+ <!-- <property>
+ <name>javax.xml.transform.TransformerFactory</name>
+ <value>com.sun.org.apache.xalan.internal.xsltc.trax.TransformerFactoryImpl</value>
+ </property> -->
+ </systemProperties>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
+ <profile>
+ <id>IBMTest</id>
+ <activation>
+ <property>
+ <name>isIBM</name>
+ <value>true</value>
+ </property>
+ </activation>
+ <build>
+ <plugins>
+ <plugin>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <!--
+ Required to run the TestW3CSchemaBucket test
+ <version>2.3-SNAPSHOT</version>
+ -->
+ <configuration>
+ <includes>
+ <include>**/*Test.java</include>
+ <!-- Fails in about half of the tests
+ <include>tests/w3c/TestW3CSchemaBucket.java</include>
+ -->
+ </includes>
+ <excludes>
+ <exclude>
+ tests/w3c/SchemaTest.java
+ </exclude>
+ </excludes>
+ <systemProperties>
+ <!-- The default xalan TransformerFactory on the ibm jdk is
+ org.apache.xalan.processor.TransformerFactoryImpl which
+ has a known issue with implicit namespaces. Set this
+ property to use the xsltc TransformerFactory (which
+ the sun jdk seems to default to).
+ -->
+ <property>
+ <name>
+ javax.xml.transform.TransformerFactory
+ </name>
+ <value>
+ org.apache.xalan.xsltc.trax.TransformerFactoryImpl
+ </value>
+ </property>
+ </systemProperties>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
</profiles>
<pluginRepositories>
<pluginRepository>
diff --git a/src/main/java/org/apache/ws/commons/schema/SchemaBuilder.java b/src/main/java/org/apache/ws/commons/schema/SchemaBuilder.java
index 6e2d49b..79a8f92 100644
--- a/src/main/java/org/apache/ws/commons/schema/SchemaBuilder.java
+++ b/src/main/java/org/apache/ws/commons/schema/SchemaBuilder.java
@@ -69,7 +69,7 @@
this.extReg = collection.getExtReg();
}
- schema = new XmlSchema(collection);
+ schema = new XmlSchema();
}
/**
@@ -99,6 +99,9 @@
schema.logicalTargetNamespace, uri);
if (!collection.containsSchema(schemaKey)) {
collection.addSchema(schemaKey, schema);
+ schema.parent = collection; // establish parentage now.
+ } else {
+ throw new XmlSchemaException("Schema name conflict in collection. Namespace: " + schema.logicalTargetNamespace);
}
schema.setElementFormDefault(this.getFormDefault(schemaEl,
diff --git a/src/main/java/org/apache/ws/commons/schema/ValidationEvent.java b/src/main/java/org/apache/ws/commons/schema/ValidationEvent.java
index df3cb39..679be22 100644
--- a/src/main/java/org/apache/ws/commons/schema/ValidationEvent.java
+++ b/src/main/java/org/apache/ws/commons/schema/ValidationEvent.java
@@ -24,6 +24,11 @@
public class ValidationEvent extends EventObject {
/**
+ *
+ */
+ private static final long serialVersionUID = 1L;
+
+ /**
* Creates new ValidationEvent
*/
public ValidationEvent(Object source) {
diff --git a/src/main/java/org/apache/ws/commons/schema/XmlSchema.java b/src/main/java/org/apache/ws/commons/schema/XmlSchema.java
index b175c3c..f580449 100644
--- a/src/main/java/org/apache/ws/commons/schema/XmlSchema.java
+++ b/src/main/java/org/apache/ws/commons/schema/XmlSchema.java
@@ -76,8 +76,35 @@
}
/**
* Creates new XmlSchema
+ * Create a new XmlSchema. The schema is <i>not</i> added to the parent collection,
+ * since it has no target namespace when created through this constructor.
+ * Call {@link XmlSchema#XmlSchema(String, XmlSchemaCollection)} instead.
+ *
+ * @param parent the parent XmlSchemaCollection
+ * @deprecated
+ */
+ public XmlSchema(XmlSchemaCollection parent) {
+ this(null, null, parent);
+ }
+
+ /**
+ * Create a schema that is not a member of a collection.
*/
- public XmlSchema(XmlSchemaCollection parent) {
+ public XmlSchema() {
+ this(null, null, null);
+ }
+
+ /**
+ * Create a new schema and record it as a member of a schema collection.
+ * @param namespace the target namespace.
+ * @param systemId the system ID for the schema.
+ * @param parent the parent collection.
+ */
+ public XmlSchema(String namespace, String systemId, XmlSchemaCollection parent) {
+ this.parent = parent;
+ if (namespace == null) {
+ namespace = "";
+ }
this.parent = parent;
attributeFormDefault = new XmlSchemaForm(XmlSchemaForm.UNQUALIFIED);
elementFormDefault = new XmlSchemaForm(XmlSchemaForm.UNQUALIFIED);
@@ -91,11 +118,22 @@
groups = new XmlSchemaObjectTable();
notations = new XmlSchemaObjectTable();
schemaTypes = new XmlSchemaObjectTable();
+
+ syntacticalTargetNamespace = logicalTargetNamespace = namespace;
+ if(parent != null) {
+ XmlSchemaCollection.SchemaKey schemaKey =
+ new XmlSchemaCollection.SchemaKey(this.logicalTargetNamespace, systemId);
+ if (parent.containsSchema(schemaKey)) {
+ throw new XmlSchemaException("Schema name conflict in collection");
+ } else {
+ parent.addSchema(schemaKey, this);
+ }
+ }
}
public XmlSchema(String namespace, XmlSchemaCollection parent) {
- this(parent);
- syntacticalTargetNamespace = logicalTargetNamespace = namespace;
+ this(namespace, namespace, parent);
+
}
public XmlSchemaForm getAttributeFormDefault() {
@@ -176,23 +214,23 @@
}
/**
- * get an element by the qname
+ * get an element by the name in the local schema
*
* @param name
- * @param deep
* @return
*/
- public XmlSchemaElement getElementByName(QName name, boolean deep) {
- return this.getElementByName(name, deep, null);
+ public XmlSchemaElement getElementByName(String name) {
+ QName nameToSearchFor = new QName(this.getTargetNamespace(),name);
+ return this.getElementByName(nameToSearchFor, false, null);
}
/**
- * @deprecated use the {@link #getElementByName(QName, boolean)} method
+ * Look for a element by its qname. Searches through all the schemas
* @param name
* @return
*/
public XmlSchemaElement getElementByName(QName name) {
- return this.getElementByName(name, false, null);
+ return this.getElementByName(name, true, null);
}
/**
@@ -243,22 +281,23 @@
}
/**
- * @deprecated use the {@link #getTypeByName(QName, boolean)}
+ * Search this schema and all the imported/included ones
+ * for the given Qname
* @param name
* @return
*/
public XmlSchemaType getTypeByName(QName name) {
- return getTypeByName(name, false, null);
+ return getTypeByName(name, true, null);
}
/**
*
* @param name
- * @param deep
* @return
*/
- public XmlSchemaType getTypeByName(QName name, boolean deep) {
- return getTypeByName(name, deep, null);
+ public XmlSchemaType getTypeByName(String name) {
+ QName nameToSearchFor = new QName(this.getTargetNamespace(),name);
+ return getTypeByName(nameToSearchFor, false, null);
}
/**
diff --git a/src/main/java/org/apache/ws/commons/schema/XmlSchemaCollection.java b/src/main/java/org/apache/ws/commons/schema/XmlSchemaCollection.java
index 7885a48..9ca8b0c 100644
--- a/src/main/java/org/apache/ws/commons/schema/XmlSchemaCollection.java
+++ b/src/main/java/org/apache/ws/commons/schema/XmlSchemaCollection.java
@@ -269,8 +269,8 @@
addSimpleType(xsd, Constants.XSD_LANGUAGE.getLocalPart());
addSimpleType(xsd, Constants.XSD_TOKEN.getLocalPart());
- SchemaKey key = new SchemaKey(XmlSchema.SCHEMA_NS, null);
- addSchema(key, xsd);
+ //SchemaKey key = new SchemaKey(XmlSchema.SCHEMA_NS, null);
+ //addSchema(key, xsd);
// look for a system property to see whether we have a registered
// extension registry class. if so we'll instantiate a new one
diff --git a/src/main/java/org/apache/ws/commons/schema/XmlSchemaException.java b/src/main/java/org/apache/ws/commons/schema/XmlSchemaException.java
index 941828e..1f819ac 100644
--- a/src/main/java/org/apache/ws/commons/schema/XmlSchemaException.java
+++ b/src/main/java/org/apache/ws/commons/schema/XmlSchemaException.java
@@ -27,6 +27,11 @@
public class XmlSchemaException extends RuntimeException {
/**
+ *
+ */
+ private static final long serialVersionUID = 1L;
+
+ /**
* Creates new XmlSchemaException
*/
public XmlSchemaException() {
diff --git a/src/main/java/org/apache/ws/commons/schema/XmlSchemaSerializer.java b/src/main/java/org/apache/ws/commons/schema/XmlSchemaSerializer.java
index dc61e55..f3322af 100644
--- a/src/main/java/org/apache/ws/commons/schema/XmlSchemaSerializer.java
+++ b/src/main/java/org/apache/ws/commons/schema/XmlSchemaSerializer.java
@@ -1000,7 +1000,8 @@
sequence.setAttribute("id", sequenceObj.id);
- if (sequenceObj.maxOccurs < Long.MAX_VALUE && sequenceObj.maxOccurs > 1)
+ if (sequenceObj.maxOccurs < Long.MAX_VALUE &&
+ (sequenceObj.maxOccurs > 1 || sequenceObj.maxOccurs == 0))
sequence.setAttribute("maxOccurs",
sequenceObj.maxOccurs + "");
else if (sequenceObj.maxOccurs == Long.MAX_VALUE)
@@ -1008,8 +1009,9 @@
"unbounded");
//else not serialized
-
- if (sequenceObj.minOccurs > 1)
+ //1 is the default and hence not serialized
+ //there is no valid case where min occurs can be unbounded!
+ if (sequenceObj.minOccurs > 1 || sequenceObj.minOccurs == 0)
sequence.setAttribute("minOccurs",
sequenceObj.minOccurs + "");
@@ -2688,7 +2690,12 @@
public static class XmlSchemaSerializerException extends Exception {
- public XmlSchemaSerializerException(String msg) {
+ /**
+ *
+ */
+ private static final long serialVersionUID = 1L;
+
+ public XmlSchemaSerializerException(String msg) {
super(msg);
}
}
diff --git a/src/main/java/org/apache/ws/commons/schema/constants/Enum.java b/src/main/java/org/apache/ws/commons/schema/constants/Enum.java
index 70d72c0..77f743c 100644
--- a/src/main/java/org/apache/ws/commons/schema/constants/Enum.java
+++ b/src/main/java/org/apache/ws/commons/schema/constants/Enum.java
@@ -39,15 +39,23 @@
if (value.equals(Enum.NULL))
this.value = Enum.NULL;
else {
- String values[] = getValues();
- for (int i = 0; i < values.length; i++) {
- if (values[i].equals(value)) {
- this.value = value;
- break;
+ //the value can be a list of space seperated items
+ String possibleValues[] = getValues();
+ String[] valuesToBeTested = value.split("\\s");
+ for (int i = 0; i < valuesToBeTested.length; i++) {
+ for (int j = 0; j < possibleValues.length; j++) {
+ if (possibleValues[j].equals(valuesToBeTested[i])) {
+ break;
+ }
+ if (i == possibleValues.length - 1)
+ throw new EnumValueException("Bad Enumeration value '" + value + "'");
}
- if (i == values.length - 1)
- throw new EnumValueException("Bad Enumeration value '" + value + "'");
}
+
+ //when we reach here we have tested all the values to be correct (applicable)
+ this.value = value;
+
+
}
}
@@ -65,6 +73,11 @@
}
public static class EnumValueException extends RuntimeException {
+ /**
+ *
+ */
+ private static final long serialVersionUID = 1L;
+
public EnumValueException(String mesg) {
super(mesg);
}
@@ -79,3 +92,4 @@
}
}
+
diff --git a/src/main/java/org/apache/ws/commons/schema/resolver/DefaultURIResolver.java b/src/main/java/org/apache/ws/commons/schema/resolver/DefaultURIResolver.java
index bb47d85..30ca176 100644
--- a/src/main/java/org/apache/ws/commons/schema/resolver/DefaultURIResolver.java
+++ b/src/main/java/org/apache/ws/commons/schema/resolver/DefaultURIResolver.java
@@ -18,9 +18,6 @@
*/
package org.apache.ws.commons.schema.resolver;
-import org.xml.sax.InputSource;
-import org.xml.sax.SAXException;
-
import java.io.File;
import java.io.IOException;
import java.net.MalformedURLException;
@@ -28,6 +25,8 @@
import java.net.URISyntaxException;
import java.net.URL;
+import org.xml.sax.InputSource;
+
/**
* This resolver provides the means of resolving the imports and includes of a
diff --git a/src/main/java/org/apache/ws/commons/schema/utils/DOMUtil.java b/src/main/java/org/apache/ws/commons/schema/utils/DOMUtil.java
index c7e9db7..4cc4778 100644
--- a/src/main/java/org/apache/ws/commons/schema/utils/DOMUtil.java
+++ b/src/main/java/org/apache/ws/commons/schema/utils/DOMUtil.java
@@ -22,7 +22,6 @@
import org.w3c.dom.*;
import java.lang.reflect.Method;
-import java.lang.reflect.InvocationTargetException;
/**
* Some useful utility methods.
diff --git a/src/main/java/org/apache/ws/commons/schema/utils/NamespaceMap.java b/src/main/java/org/apache/ws/commons/schema/utils/NamespaceMap.java
index 91fcd68..c5ce041 100644
--- a/src/main/java/org/apache/ws/commons/schema/utils/NamespaceMap.java
+++ b/src/main/java/org/apache/ws/commons/schema/utils/NamespaceMap.java
@@ -22,7 +22,12 @@
public class NamespaceMap extends HashMap implements NamespacePrefixList {
- public NamespaceMap() {
+ /**
+ *
+ */
+ private static final long serialVersionUID = 1L;
+
+ public NamespaceMap() {
}
public NamespaceMap(Map map) {
diff --git a/src/test/java/tests/AnnotationTest.java b/src/test/java/tests/AnnotationTest.java
index 0020341..5187fe7 100644
--- a/src/test/java/tests/AnnotationTest.java
+++ b/src/test/java/tests/AnnotationTest.java
@@ -59,7 +59,7 @@
"emptyAppinfo");
InputStream is = new FileInputStream(Resources.asURI("annotation.xsd"));
XmlSchemaCollection schemaCol = new XmlSchemaCollection();
- XmlSchema schema = schemaCol.read(new StreamSource(is), null);
+ schemaCol.read(new StreamSource(is), null);
XmlSchemaSimpleType simpleType =
(XmlSchemaSimpleType)schemaCol.getTypeByQName(TYPE_QNAME);
@@ -125,7 +125,7 @@
"emptyDocumentation");
InputStream is = new FileInputStream(Resources.asURI("annotation.xsd"));
XmlSchemaCollection schemaCol = new XmlSchemaCollection();
- XmlSchema schema = schemaCol.read(new StreamSource(is), null);
+ schemaCol.read(new StreamSource(is), null);
XmlSchemaSimpleType simpleType =
(XmlSchemaSimpleType)schemaCol.getTypeByQName(TYPE_QNAME);
@@ -189,7 +189,7 @@
"emptyAppinfoDocumentation");
InputStream is = new FileInputStream(Resources.asURI("annotation.xsd"));
XmlSchemaCollection schemaCol = new XmlSchemaCollection();
- XmlSchema schema = schemaCol.read(new StreamSource(is), null);
+ schemaCol.read(new StreamSource(is), null);
XmlSchemaSimpleType simpleType =
(XmlSchemaSimpleType)schemaCol.getTypeByQName(TYPE_QNAME);
@@ -227,7 +227,7 @@
"annotationTest");
InputStream is = new FileInputStream(Resources.asURI("annotation.xsd"));
XmlSchemaCollection schemaCol = new XmlSchemaCollection();
- XmlSchema schema = schemaCol.read(new StreamSource(is), null);
+ schemaCol.read(new StreamSource(is), null);
XmlSchemaSimpleType simpleType =
(XmlSchemaSimpleType)schemaCol.getTypeByQName(TYPE_QNAME);
diff --git a/src/test/java/tests/AnyTest.java b/src/test/java/tests/AnyTest.java
index 5063b61..c8424f5 100644
--- a/src/test/java/tests/AnyTest.java
+++ b/src/test/java/tests/AnyTest.java
@@ -79,7 +79,7 @@
"department");
InputStream is = new FileInputStream(Resources.asURI("any.xsd"));
XmlSchemaCollection schemaCol = new XmlSchemaCollection();
- XmlSchema schema = schemaCol.read(new StreamSource(is), null);
+ schemaCol.read(new StreamSource(is), null);
XmlSchemaElement elem = schemaCol.getElementByQName(ELEMENT_QNAME);
assertNotNull(elem);
@@ -130,4 +130,4 @@
}
-}
\ No newline at end of file
+}
diff --git a/src/test/java/tests/AppInfoMarkupTest.java b/src/test/java/tests/AppInfoMarkupTest.java
index 7c3c32c..d877c9a 100644
--- a/src/test/java/tests/AppInfoMarkupTest.java
+++ b/src/test/java/tests/AppInfoMarkupTest.java
@@ -18,24 +18,20 @@
*/
package tests;
-import junit.framework.TestCase;
-
-import java.io.InputStream;
-import java.io.FileInputStream;
-import java.io.ByteArrayOutputStream;
import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.FileInputStream;
+import java.io.InputStream;
-import org.apache.ws.commons.schema.XmlSchemaCollection;
-import org.apache.ws.commons.schema.XmlSchema;
-import org.custommonkey.xmlunit.XMLUnit;
-import org.custommonkey.xmlunit.XMLTestCase;
-import org.w3c.dom.Document;
-
-import javax.xml.transform.stream.StreamSource;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.transform.stream.StreamSource;
-import sun.management.counter.ByteArrayCounter;
+import org.apache.ws.commons.schema.XmlSchema;
+import org.apache.ws.commons.schema.XmlSchemaCollection;
+import org.custommonkey.xmlunit.XMLTestCase;
+import org.custommonkey.xmlunit.XMLUnit;
+import org.w3c.dom.Document;
public class AppInfoMarkupTest extends XMLTestCase {
diff --git a/src/test/java/tests/ChoiceTest.java b/src/test/java/tests/ChoiceTest.java
index f33cf6e..f46298f 100644
--- a/src/test/java/tests/ChoiceTest.java
+++ b/src/test/java/tests/ChoiceTest.java
@@ -81,7 +81,7 @@
InputStream is = new FileInputStream(Resources.asURI("choice.xsd"));
XmlSchemaCollection schemaCol = new XmlSchemaCollection();
- XmlSchema schema = schemaCol.read(new StreamSource(is), null);
+ schemaCol.read(new StreamSource(is), null);
QName WRONG_QNAME = new QName("http://soapinterop.org/types",
"machine");
@@ -142,4 +142,4 @@
}
-}
\ No newline at end of file
+}
diff --git a/src/test/java/tests/ComplexContentRestrictionTest.java b/src/test/java/tests/ComplexContentRestrictionTest.java
index c380155..60b6856 100644
--- a/src/test/java/tests/ComplexContentRestrictionTest.java
+++ b/src/test/java/tests/ComplexContentRestrictionTest.java
@@ -89,7 +89,7 @@
"NoAssemblyRequiredProduct");
InputStream is = new FileInputStream(Resources.asURI("deriverestriction.xsd"));
XmlSchemaCollection schemaCol = new XmlSchemaCollection();
- XmlSchema schema = schemaCol.read(new StreamSource(is), null);
+ schemaCol.read(new StreamSource(is), null);
XmlSchemaComplexType cType =
(XmlSchemaComplexType)schemaCol.getTypeByQName(TYPE_QNAME);
@@ -150,4 +150,4 @@
}
-}
\ No newline at end of file
+}
diff --git a/src/test/java/tests/ConstraintsTest.java b/src/test/java/tests/ConstraintsTest.java
index 9ec9a64..e63f199 100644
--- a/src/test/java/tests/ConstraintsTest.java
+++ b/src/test/java/tests/ConstraintsTest.java
@@ -132,7 +132,7 @@
"constraintTest");
InputStream is = new FileInputStream(Resources.asURI("constraints.xsd"));
XmlSchemaCollection schemaCol = new XmlSchemaCollection();
- XmlSchema schema = schemaCol.read(new StreamSource(is), null);
+ schemaCol.read(new StreamSource(is), null);
XmlSchemaElement elem = schemaCol.getElementByQName(ELEMENT_QNAME);
assertNotNull(elem);
@@ -214,4 +214,4 @@
}
-}
\ No newline at end of file
+}
diff --git a/src/test/java/tests/EncodingTest.java b/src/test/java/tests/EncodingTest.java
index 4abf061..1b98724 100644
--- a/src/test/java/tests/EncodingTest.java
+++ b/src/test/java/tests/EncodingTest.java
@@ -22,7 +22,6 @@
import junit.framework.TestCase;
import org.apache.ws.commons.schema.XmlSchema;
import org.apache.ws.commons.schema.XmlSchemaCollection;
-import org.apache.ws.commons.schema.constants.Constants;
import org.w3c.dom.Document;
import javax.xml.parsers.DocumentBuilder;
@@ -59,8 +58,7 @@
ByteArrayOutputStream baos = new ByteArrayOutputStream();
s1.write(baos,options);
-
-
+ schemaCol = new XmlSchemaCollection();
Document doc2 = newDocumentBuilder.parse(new ByteArrayInputStream(baos.toByteArray()));
XmlSchema s2 = schemaCol.read(doc2.getDocumentElement());
assertNotNull(s2);
diff --git a/src/test/java/tests/EnumValueTest.java b/src/test/java/tests/EnumValueTest.java
new file mode 100644
index 0000000..5e57d71
--- /dev/null
+++ b/src/test/java/tests/EnumValueTest.java
@@ -0,0 +1,30 @@
+package tests;
+
+import junit.framework.TestCase;
+
+import javax.xml.parsers.DocumentBuilderFactory;
+
+import org.w3c.dom.Document;
+import org.apache.ws.commons.schema.XmlSchemaCollection;
+import org.apache.ws.commons.schema.XmlSchema;
+
+/**
+ * Created by IntelliJ IDEA.
+ * User: ajith
+ */
+public class EnumValueTest extends TestCase {
+
+
+ public void testValue() throws Exception{
+ //create a DOM document
+ DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance();
+ documentBuilderFactory.setNamespaceAware(true);
+ Document doc = documentBuilderFactory.newDocumentBuilder().
+ parse(Resources.asURI("enum.xsd"));
+
+ XmlSchemaCollection schemaCol = new XmlSchemaCollection();
+ XmlSchema s = schemaCol.read(doc.getDocumentElement());
+
+ assertNotNull(s);
+ }
+}
diff --git a/src/test/java/tests/FacetsTest.java b/src/test/java/tests/FacetsTest.java
index e865690..31bc805 100644
--- a/src/test/java/tests/FacetsTest.java
+++ b/src/test/java/tests/FacetsTest.java
@@ -52,7 +52,7 @@
"myZipCode");
InputStream is = new FileInputStream(Resources.asURI("facets.xsd"));
XmlSchemaCollection schemaCol = new XmlSchemaCollection();
- XmlSchema schema = schemaCol.read(new StreamSource(is), null);
+ schemaCol.read(new StreamSource(is), null);
XmlSchemaElement elem = schemaCol.getElementByQName(ELEMENT_QNAME);
assertNotNull(elem);
@@ -126,7 +126,7 @@
"myCreditCardNumber");
InputStream is = new FileInputStream(Resources.asURI("facets.xsd"));
XmlSchemaCollection schemaCol = new XmlSchemaCollection();
- XmlSchema schema = schemaCol.read(new StreamSource(is), null);
+ schemaCol.read(new StreamSource(is), null);
XmlSchemaElement elem = schemaCol.getElementByQName(ELEMENT_QNAME);
assertNotNull(elem);
@@ -192,7 +192,7 @@
"myAge");
InputStream is = new FileInputStream(Resources.asURI("facets.xsd"));
XmlSchemaCollection schemaCol = new XmlSchemaCollection();
- XmlSchema schema = schemaCol.read(new StreamSource(is), null);
+ schemaCol.read(new StreamSource(is), null);
XmlSchemaElement elem = schemaCol.getElementByQName(ELEMENT_QNAME);
assertNotNull(elem);
@@ -259,7 +259,7 @@
"myDistance");
InputStream is = new FileInputStream(Resources.asURI("facets.xsd"));
XmlSchemaCollection schemaCol = new XmlSchemaCollection();
- XmlSchema schema = schemaCol.read(new StreamSource(is), null);
+ schemaCol.read(new StreamSource(is), null);
XmlSchemaElement elem = schemaCol.getElementByQName(ELEMENT_QNAME);
assertNotNull(elem);
@@ -334,7 +334,7 @@
"myWeight");
InputStream is = new FileInputStream(Resources.asURI("facets.xsd"));
XmlSchemaCollection schemaCol = new XmlSchemaCollection();
- XmlSchema schema = schemaCol.read(new StreamSource(is), null);
+ schemaCol.read(new StreamSource(is), null);
XmlSchemaElement elem = schemaCol.getElementByQName(ELEMENT_QNAME);
assertNotNull(elem);
@@ -408,7 +408,7 @@
"myWhiteSpace");
InputStream is = new FileInputStream(Resources.asURI("facets.xsd"));
XmlSchemaCollection schemaCol = new XmlSchemaCollection();
- XmlSchema schema = schemaCol.read(new StreamSource(is), null);
+ schemaCol.read(new StreamSource(is), null);
XmlSchemaElement elem = schemaCol.getElementByQName(ELEMENT_QNAME);
assertNotNull(elem);
@@ -475,7 +475,7 @@
"myHeight");
InputStream is = new FileInputStream(Resources.asURI("facets.xsd"));
XmlSchemaCollection schemaCol = new XmlSchemaCollection();
- XmlSchema schema = schemaCol.read(new StreamSource(is), null);
+ schemaCol.read(new StreamSource(is), null);
XmlSchemaElement elem = schemaCol.getElementByQName(ELEMENT_QNAME);
assertNotNull(elem);
@@ -550,7 +550,7 @@
"myYardLength");
InputStream is = new FileInputStream(Resources.asURI("facets.xsd"));
XmlSchemaCollection schemaCol = new XmlSchemaCollection();
- XmlSchema schema = schemaCol.read(new StreamSource(is), null);
+ schemaCol.read(new StreamSource(is), null);
XmlSchemaElement elem = schemaCol.getElementByQName(ELEMENT_QNAME);
assertNotNull(elem);
@@ -625,7 +625,7 @@
"layoutComponent");
InputStream is = new FileInputStream(Resources.asURI("facets.xsd"));
XmlSchemaCollection schemaCol = new XmlSchemaCollection();
- XmlSchema schema = schemaCol.read(new StreamSource(is), null);
+ schemaCol.read(new StreamSource(is), null);
XmlSchemaElement elem = schemaCol.getElementByQName(ELEMENT_QNAME);
assertNotNull(elem);
diff --git a/src/test/java/tests/GroupTest.java b/src/test/java/tests/GroupTest.java
index 8808ee4..31bd442 100644
--- a/src/test/java/tests/GroupTest.java
+++ b/src/test/java/tests/GroupTest.java
@@ -111,8 +111,6 @@
XmlSchemaObjectTable t = schema.getGroups();
assertEquals(1, t.getCount());
- XmlSchemaObject o = t.getItem(ref.getRefName());
-
Set s = new HashSet();
s.add("priceGroup");
for (Iterator i = t.getNames(); i.hasNext(); ) {
@@ -173,4 +171,4 @@
}
-}
\ No newline at end of file
+}
diff --git a/src/test/java/tests/ImportTest.java b/src/test/java/tests/ImportTest.java
index e858aad..f1e9627 100644
--- a/src/test/java/tests/ImportTest.java
+++ b/src/test/java/tests/ImportTest.java
@@ -83,7 +83,7 @@
XmlSchema schema = schemaCol.read(doc,file.toURL().toString(),null);
assertNotNull(schema);
- assertNotNull(schema.getTypeByName(new QName("http://soapinterop.org/xsd2","SOAPStruct"),true));
- assertNotNull(schema.getElementByName(new QName("http://soapinterop.org/xsd2","SOAPWrapper"),true));
+ assertNotNull(schema.getTypeByName(new QName("http://soapinterop.org/xsd2","SOAPStruct")));
+ assertNotNull(schema.getElementByName(new QName("http://soapinterop.org/xsd2","SOAPWrapper")));
}
}
diff --git a/src/test/java/tests/IncludeTest.java b/src/test/java/tests/IncludeTest.java
index 7917c6c..0ecc4f8 100644
--- a/src/test/java/tests/IncludeTest.java
+++ b/src/test/java/tests/IncludeTest.java
@@ -88,8 +88,6 @@
</schema>
*/
- QName ELEMENT_QNAME = new QName("http://soapinterop.org/types",
- "test1include");
InputStream is = new FileInputStream(Resources.asURI("include.xsd"));
XmlSchemaCollection schemaCol = new XmlSchemaCollection();
XmlSchema schema = schemaCol.read(new StreamSource(is), null);
@@ -170,4 +168,4 @@
XmlSchema schema = schemaCol.read(isource, null);
assertNotNull(schema);
}
-}
\ No newline at end of file
+}
diff --git a/src/test/java/tests/ListTest.java b/src/test/java/tests/ListTest.java
index fd4fda1..b0591ce 100644
--- a/src/test/java/tests/ListTest.java
+++ b/src/test/java/tests/ListTest.java
@@ -78,7 +78,7 @@
"workDays");
InputStream is = new FileInputStream(Resources.asURI("list.xsd"));
XmlSchemaCollection schemaCol = new XmlSchemaCollection();
- XmlSchema schema = schemaCol.read(new StreamSource(is), null);
+ schemaCol.read(new StreamSource(is), null);
XmlSchemaElement elem = schemaCol.getElementByQName(ELEMENT_QNAME);
assertNotNull(elem);
@@ -104,4 +104,4 @@
}
-}
\ No newline at end of file
+}
diff --git a/src/test/java/tests/RecursiveImportTest.java b/src/test/java/tests/RecursiveImportTest.java
index 0555ea2..2a03e56 100644
--- a/src/test/java/tests/RecursiveImportTest.java
+++ b/src/test/java/tests/RecursiveImportTest.java
@@ -45,8 +45,9 @@
//these qnames are *not* there in these schemas
- assertNull(schema.getTypeByName(new QName("http://soapinterop.org/xsd2","SOAPStruct"),true));
- assertNull(schema.getElementByName(new QName("http://soapinterop.org/xsd2","SOAPWrapper"),true));
+ assertNull(schema.getTypeByName(new QName("http://soapinterop.org/xsd2","SOAPStruct")));
+ assertNull(schema.getElementByName(new QName("http://soapinterop.org/xsd2","SOAPWrapper")));
+
}
diff --git a/src/test/java/tests/SequenceTest.java b/src/test/java/tests/SequenceTest.java
index 929f7d0..6cd9b4e 100644
--- a/src/test/java/tests/SequenceTest.java
+++ b/src/test/java/tests/SequenceTest.java
@@ -19,17 +19,18 @@
package tests;
-import junit.framework.TestCase;
+import java.io.FileInputStream;
+import java.io.InputStream;
import javax.xml.namespace.QName;
import javax.xml.transform.stream.StreamSource;
-import java.io.InputStream;
-import java.io.FileInputStream;
-import java.util.Set;
-import java.util.HashSet;
-import java.util.Iterator;
-import org.apache.ws.commons.schema.*;
+import junit.framework.TestCase;
+
+import org.apache.ws.commons.schema.XmlSchemaCollection;
+import org.apache.ws.commons.schema.XmlSchemaComplexType;
+import org.apache.ws.commons.schema.XmlSchemaElement;
+import org.apache.ws.commons.schema.XmlSchemaSequence;
/*
* Copyright 2004,2007 The Apache Software Foundation.
@@ -81,7 +82,7 @@
InputStream is = new FileInputStream(Resources.asURI("sequence.xsd"));
XmlSchemaCollection schemaCol = new XmlSchemaCollection();
- XmlSchema schema = schemaCol.read(new StreamSource(is), null);
+ schemaCol.read(new StreamSource(is), null);
QName WRONG_QNAME = new QName("http://soapinterop.org/types",
"machine");
diff --git a/src/test/java/tests/TestSimpleRestriction.java b/src/test/java/tests/TestSimpleRestriction.java
index 7dda02c..bcf082f 100644
--- a/src/test/java/tests/TestSimpleRestriction.java
+++ b/src/test/java/tests/TestSimpleRestriction.java
@@ -19,7 +19,6 @@
package tests;
import junit.framework.TestCase;
-import org.apache.ws.commons.schema.XmlSchema;
import org.apache.ws.commons.schema.XmlSchemaCollection;
import org.apache.ws.commons.schema.XmlSchemaElement;
import org.apache.ws.commons.schema.XmlSchemaType;
@@ -38,7 +37,7 @@
InputStream is = new FileInputStream(Resources.asURI("SimpleContentRestriction.xsd"));
XmlSchemaCollection schema = new XmlSchemaCollection();
- XmlSchema s = schema.read(new StreamSource(is), null);
+ schema.read(new StreamSource(is), null);
XmlSchemaType simpleType = schema.getTypeByQName(TYPE_QNAME);
assertNotNull(simpleType);
@@ -53,7 +52,7 @@
public void testSimpleTypeRestrictionWithoutNamespace() throws Exception {
InputStream is = new FileInputStream(Resources.asURI("includedWithoutNamespace.xsd"));
XmlSchemaCollection schema = new XmlSchemaCollection();
- XmlSchema s = schema.read(new StreamSource(is), null);
+ schema.read(new StreamSource(is), null);
XmlSchemaType principalId = schema.getTypeByQName(new QName("", "XdwsPrincipalId"));
assertNotNull(principalId);
XmlSchemaType groupId = schema.getTypeByQName(new QName("", "XdwsGroupId"));
diff --git a/src/test/java/tests/UnionTest.java b/src/test/java/tests/UnionTest.java
index a1fd90c..1a0ce11 100644
--- a/src/test/java/tests/UnionTest.java
+++ b/src/test/java/tests/UnionTest.java
@@ -74,7 +74,7 @@
"unionTest");
InputStream is = new FileInputStream(Resources.asURI("union.xsd"));
XmlSchemaCollection schemaCol = new XmlSchemaCollection();
- XmlSchema schema = schemaCol.read(new StreamSource(is), null);
+ schemaCol.read(new StreamSource(is), null);
XmlSchemaElement elem = schemaCol.getElementByQName(ELEMENT_QNAME);
@@ -105,4 +105,4 @@
}
-}
\ No newline at end of file
+}
diff --git a/src/test/java/tests/customext/attrib/CustomExtensionSerializerTest.java b/src/test/java/tests/customext/attrib/CustomExtensionSerializerTest.java
index 66c7546..aaba47f 100644
--- a/src/test/java/tests/customext/attrib/CustomExtensionSerializerTest.java
+++ b/src/test/java/tests/customext/attrib/CustomExtensionSerializerTest.java
@@ -61,6 +61,7 @@
Document doc2 = documentBuilderFactory.newDocumentBuilder().
parse(new ByteArrayInputStream(baos.toByteArray()));
+ schemaCol = new XmlSchemaCollection();
schema = schemaCol.read(doc2,null);
assertNotNull(schema);
diff --git a/src/test/java/tests/customext/elt/CustomExtElementSerializerTest.java b/src/test/java/tests/customext/elt/CustomExtElementSerializerTest.java
index 9e76195..6583fa7 100644
--- a/src/test/java/tests/customext/elt/CustomExtElementSerializerTest.java
+++ b/src/test/java/tests/customext/elt/CustomExtElementSerializerTest.java
@@ -60,6 +60,8 @@
Document doc2 = documentBuilderFactory.newDocumentBuilder().
parse(new ByteArrayInputStream(baos.toByteArray()));
+ // we can't have two copies in the same collection.
+ schemaCol = new XmlSchemaCollection();
schema = schemaCol.read(doc2,null);
assertNotNull(schema);
diff --git a/src/test/java/tests/ext/PlainExtensionSerializerTest.java b/src/test/java/tests/ext/PlainExtensionSerializerTest.java
index 025851d..2a69a49 100644
--- a/src/test/java/tests/ext/PlainExtensionSerializerTest.java
+++ b/src/test/java/tests/ext/PlainExtensionSerializerTest.java
@@ -18,19 +18,17 @@
*/
package tests.ext;
-import junit.framework.TestCase;
+import java.io.ByteArrayOutputStream;
import javax.xml.parsers.DocumentBuilderFactory;
-import org.w3c.dom.Document;
-import org.apache.ws.commons.schema.XmlSchemaCollection;
-import org.apache.ws.commons.schema.XmlSchema;
-import org.apache.ws.commons.schema.XmlSchemaElement;
-import tests.Resources;
+import junit.framework.TestCase;
-import java.util.Iterator;
-import java.util.Map;
-import java.io.ByteArrayOutputStream;
+import org.apache.ws.commons.schema.XmlSchema;
+import org.apache.ws.commons.schema.XmlSchemaCollection;
+import org.w3c.dom.Document;
+
+import tests.Resources;
/**
* try writing the schemas after they are built
diff --git a/src/test/test-resources/enum.xsd b/src/test/test-resources/enum.xsd
new file mode 100644
index 0000000..0a85b2f
--- /dev/null
+++ b/src/test/test-resources/enum.xsd
@@ -0,0 +1,28 @@
+<!--
+ ~ 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="http://soapinterop.org/types"
+ xmlns:xsd="http://www.w3.org/2001/XMLSchema">
+ <xsd:complexType name="foo" final="extension restriction">
+ <xsd:sequence>
+ <xsd:element name="bar" type="xsd:int"/>
+ </xsd:sequence>
+ </xsd:complexType>
+</xsd:schema>