From 2912ae3afa482f0e4dfe81fc450d29b268337edb Mon Sep 17 00:00:00 2001 From: Arjen Poutsma Date: Sun, 28 Oct 2007 14:24:45 +0000 Subject: [PATCH] Moved xsd to schema package. --- .../springframework/xml/schema/Schema.java | 31 +++ .../xml/schema/SchemaException.java | 36 ++++ .../springframework/xml/schema/package.html | 5 + .../xml/schema/xsd/SimpleXsdSchema.java | 161 ++++++++++++++++ .../xml/schema/xsd/WsCommonsXsdSchema.java | 176 ++++++++++++++++++ .../xml/schema/xsd/XsdElement.java | 33 ++++ .../xml/schema/xsd/XsdSchema.java | 33 ++++ .../xml/schema/xsd/XsdSchemaDocument.java | 27 +++ .../xml/schema/xsd/XsdSchemaException.java | 36 ++++ .../xml/schema/xsd/package.html | 6 + .../xsd/AbstractXsdSchemaTestCase.java | 26 +-- .../{ => schema}/xsd/SimpleXsdSchemaTest.java | 2 +- .../xsd/WsCommonsXsdSchemaTest.java | 2 +- .../xml/{ => schema}/xsd/imported.xsd | 0 .../xml/{ => schema}/xsd/importing.xsd | 0 .../xml/{ => schema}/xsd/included.xsd | 0 .../xml/{ => schema}/xsd/including.xsd | 0 .../xml/{ => schema}/xsd/single.xsd | 0 18 files changed, 559 insertions(+), 15 deletions(-) create mode 100644 xml/src/main/java/org/springframework/xml/schema/Schema.java create mode 100644 xml/src/main/java/org/springframework/xml/schema/SchemaException.java create mode 100644 xml/src/main/java/org/springframework/xml/schema/package.html create mode 100644 xml/src/main/java/org/springframework/xml/schema/xsd/SimpleXsdSchema.java create mode 100644 xml/src/main/java/org/springframework/xml/schema/xsd/WsCommonsXsdSchema.java create mode 100644 xml/src/main/java/org/springframework/xml/schema/xsd/XsdElement.java create mode 100644 xml/src/main/java/org/springframework/xml/schema/xsd/XsdSchema.java create mode 100644 xml/src/main/java/org/springframework/xml/schema/xsd/XsdSchemaDocument.java create mode 100644 xml/src/main/java/org/springframework/xml/schema/xsd/XsdSchemaException.java create mode 100644 xml/src/main/java/org/springframework/xml/schema/xsd/package.html rename xml/src/test/java/org/springframework/xml/{ => schema}/xsd/AbstractXsdSchemaTestCase.java (91%) rename xml/src/test/java/org/springframework/xml/{ => schema}/xsd/SimpleXsdSchemaTest.java (95%) rename xml/src/test/java/org/springframework/xml/{ => schema}/xsd/WsCommonsXsdSchemaTest.java (95%) rename xml/src/test/resources/org/springframework/xml/{ => schema}/xsd/imported.xsd (100%) rename xml/src/test/resources/org/springframework/xml/{ => schema}/xsd/importing.xsd (100%) rename xml/src/test/resources/org/springframework/xml/{ => schema}/xsd/included.xsd (100%) rename xml/src/test/resources/org/springframework/xml/{ => schema}/xsd/including.xsd (100%) rename xml/src/test/resources/org/springframework/xml/{ => schema}/xsd/single.xsd (100%) diff --git a/xml/src/main/java/org/springframework/xml/schema/Schema.java b/xml/src/main/java/org/springframework/xml/schema/Schema.java new file mode 100644 index 00000000..fd1901b4 --- /dev/null +++ b/xml/src/main/java/org/springframework/xml/schema/Schema.java @@ -0,0 +1,31 @@ +/* + * Copyright 2007 the original author or authors. + * + * Licensed 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.springframework.xml.schema; + +import org.springframework.xml.validation.XmlValidator; + +/** + * Represents an abstraction for XML schemas. + * + * @author Arjen Poutsma + * @since 1.0.2 + */ +public interface Schema { + + /** Returns the {@link XmlValidator} based on this schema. */ + XmlValidator getValidator(); +} diff --git a/xml/src/main/java/org/springframework/xml/schema/SchemaException.java b/xml/src/main/java/org/springframework/xml/schema/SchemaException.java new file mode 100644 index 00000000..f2e7e77c --- /dev/null +++ b/xml/src/main/java/org/springframework/xml/schema/SchemaException.java @@ -0,0 +1,36 @@ +/* + * Copyright 2007 the original author or authors. + * + * Licensed 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.springframework.xml.schema; + +import org.springframework.xml.XmlException; + +/** + * Base class for all schema exceptions. + * + * @author Arjen Poutsma + * @since 1.0.2 + */ +public class SchemaException extends XmlException { + + public SchemaException(String message) { + super(message); + } + + public SchemaException(String message, Throwable throwable) { + super(message, throwable); + } +} diff --git a/xml/src/main/java/org/springframework/xml/schema/package.html b/xml/src/main/java/org/springframework/xml/schema/package.html new file mode 100644 index 00000000..73890526 --- /dev/null +++ b/xml/src/main/java/org/springframework/xml/schema/package.html @@ -0,0 +1,5 @@ + + +Provides the schema functionality of the Spring Web Services framework. Contains the Schema interface. + + diff --git a/xml/src/main/java/org/springframework/xml/schema/xsd/SimpleXsdSchema.java b/xml/src/main/java/org/springframework/xml/schema/xsd/SimpleXsdSchema.java new file mode 100644 index 00000000..87aab214 --- /dev/null +++ b/xml/src/main/java/org/springframework/xml/schema/xsd/SimpleXsdSchema.java @@ -0,0 +1,161 @@ +/* + * Copyright 2007 the original author or authors. + * + * Licensed 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.springframework.xml.schema.xsd; + +import java.util.ArrayList; +import java.util.List; +import javax.xml.namespace.QName; +import javax.xml.parsers.DocumentBuilder; +import javax.xml.parsers.DocumentBuilderFactory; +import javax.xml.transform.Source; +import javax.xml.transform.dom.DOMSource; + +import org.springframework.beans.factory.InitializingBean; +import org.springframework.core.io.Resource; +import org.springframework.util.Assert; +import org.springframework.util.StringUtils; +import org.springframework.xml.namespace.QNameUtils; +import org.springframework.xml.sax.SaxUtils; +import org.springframework.xml.validation.XmlValidator; +import org.springframework.xml.validation.XmlValidatorFactory; +import org.w3c.dom.Document; +import org.w3c.dom.Element; +import org.w3c.dom.Node; +import org.w3c.dom.NodeList; + +/** + * Simple implementation of the {@link XsdSchema} interface. Only wraps a single {@link XsdSchemaDocument}, and does not + * follow <xsd:include/> nor <xsd:import/> elements. + *

+ * Allows an XSD {@link Resource resource} to be set by the {@link #setSchema(Resource) schema} property, or directly in + * the {@link #SimpleXsdSchema(Resource) constructor}. + * + * @author Arjen Poutsma + * @since 1.0.2 + */ +public class SimpleXsdSchema implements XsdSchema, InitializingBean { + + private static final String SCHEMA_NAMESPACE = "http://www.w3.org/2001/XMLSchema"; + + /** The schema qualified name. */ + private static final QName SCHEMA_NAME = QNameUtils.createQName(SCHEMA_NAMESPACE, "schema", "xsd"); + + /** The element declaration qualified name. */ + private static final QName ELEMENT_NAME = QNameUtils.createQName(SCHEMA_NAMESPACE, "element", "xsd"); + + private final XsdSchemaDocument[] schemaDocuments = new XsdSchemaDocument[]{new SimpleXsdSchemaDocument()}; + + private Resource schemaResource; + + private Element schemaElement; + + private XmlValidator validator; + + /** + * Create a new instance of the {@link SimpleXsdSchema} class. + *

+ * A subsequent call to the {@link #setSchema(Resource)} method is required. + */ + public SimpleXsdSchema() { + } + + /** + * Create a new instance of the {@link SimpleXsdSchema} class with the specified resource. + * + * @param schemaResource the XSD resource; must not be null + * @throws IllegalArgumentException if the supplied schemaResource is null + */ + public SimpleXsdSchema(Resource schemaResource) { + setSchema(schemaResource); + } + + /** Set the XSD resource to be used. */ + public void setSchema(Resource schemaResource) { + this.schemaResource = schemaResource; + } + + public XsdSchemaDocument[] getSchemaDocuments() { + return schemaDocuments; + } + + public XmlValidator getValidator() { + return validator; + } + + public void afterPropertiesSet() throws Exception { + Assert.notNull(schemaResource, "'schema' is required"); + Assert.isTrue(schemaResource.exists(), "schema '" + schemaResource + "' does not exit"); + DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance(); + documentBuilderFactory.setNamespaceAware(true); + DocumentBuilder documentBuilder = documentBuilderFactory.newDocumentBuilder(); + Document document = documentBuilder.parse(SaxUtils.createInputSource(schemaResource)); + schemaElement = document.getDocumentElement(); + QName name = QNameUtils.getQNameForNode(schemaElement); + Assert.isTrue(SCHEMA_NAME.equals(name), + "schema document has invalid qualified name: " + name + ". " + "Epected " + SCHEMA_NAME); + Assert.hasLength(schemaElement.getAttribute("targetNamespace"), "schema does not define targetNamespace"); + validator = XmlValidatorFactory.createValidator(schemaResource, XmlValidatorFactory.SCHEMA_W3C_XML); + } + + /** Inner definition of {@link SimpleXsdSchemaDocument}. */ + private class SimpleXsdSchemaDocument implements XsdSchemaDocument { + + public String getFilename() { + return schemaResource.getFilename(); + } + + public Source getSource() { + return new DOMSource(schemaElement); + } + + public XsdElement[] getElements() { + NodeList children = schemaElement.getChildNodes(); + List declarations = new ArrayList(children.getLength()); + for (int i = 0; i < children.getLength(); i++) { + if (children.item(i).getNodeType() == Node.ELEMENT_NODE) { + Element childElement = (Element) children.item(i); + QName childName = QNameUtils.getQNameForNode(childElement); + if (ELEMENT_NAME.equals(childName)) { + declarations.add(new SimpleXsdElement(childElement)); + } + } + } + return (XsdElement[]) declarations.toArray(new XsdElement[declarations.size()]); + } + + public String getTargetNamespace() { + return schemaElement.getAttribute("targetNamespace"); + } + + /** Inner definition of {@link SimpleXsdElement}. */ + private class SimpleXsdElement implements XsdElement { + + private final Element element; + + private SimpleXsdElement(Element element) { + this.element = element; + } + + public QName getName() { + String attributeValue = element.getAttribute("name"); + return StringUtils.hasLength(attributeValue) ? new QName(getTargetNamespace(), attributeValue) : null; + } + } + + } + +} \ No newline at end of file diff --git a/xml/src/main/java/org/springframework/xml/schema/xsd/WsCommonsXsdSchema.java b/xml/src/main/java/org/springframework/xml/schema/xsd/WsCommonsXsdSchema.java new file mode 100644 index 00000000..e5adac9a --- /dev/null +++ b/xml/src/main/java/org/springframework/xml/schema/xsd/WsCommonsXsdSchema.java @@ -0,0 +1,176 @@ +/* + * Copyright 2007 the original author or authors. + * + * Licensed 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.springframework.xml.schema.xsd; + +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; +import javax.xml.namespace.QName; +import javax.xml.transform.Source; +import javax.xml.transform.stream.StreamSource; + +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.XmlSchemaObjectTable; +import org.springframework.beans.factory.InitializingBean; +import org.springframework.core.io.Resource; +import org.springframework.util.Assert; +import org.springframework.util.StringUtils; +import org.springframework.xml.sax.SaxUtils; +import org.springframework.xml.validation.XmlValidator; +import org.springframework.xml.validation.XmlValidatorFactory; + +/** + * Implementation of the {@link XsdSchema} interface that uses Apache + * WS Commons XMLSchema. Allows for multiple {@link XsdSchemaDocument}s, and follows + * <xsd:include/> and <xsd:import/> elements. + *

+ * Allows an XSD {@link Resource resource} to be set by the {@link #setSchema(Resource) schema} or {@link + * #setSchemas(Resource[]) schemas} properties, or directly in the {@link #WsCommonsXsdSchema(Resource)} or {@link + * #WsCommonsXsdSchema(Resource[])} constructors. + * + * @author Arjen Poutsma + * @since 1.0.2 + */ +public class WsCommonsXsdSchema implements XsdSchema, InitializingBean { + + private Resource[] schemaResources; + + private XsdSchemaDocument[] schemaDocuments; + + private XmlValidator validator; + + /** + * Create a new instance of the {@link WsCommonsXsdSchema} class. + *

+ * A subsequent call to the {@link #setSchema(Resource)} or {@link #setSchemas(Resource[])} method is required. + */ + public WsCommonsXsdSchema() { + } + + /** + * Create a new instance of the {@link WsCommonsXsdSchema} class with the specified single resource. + * + * @param schemaResource the XSD resource; must not be null + * @throws IllegalArgumentException if the supplied schemaResource is null + */ + public WsCommonsXsdSchema(Resource schemaResource) { + setSchema(schemaResource); + } + + /** + * Create a new instance of the {@link WsCommonsXsdSchema} class with the specified resources. + * + * @param schemaResources the XSD resources; must not be null or empty + * @throws IllegalArgumentException if the supplied schemaResource is null + */ + public WsCommonsXsdSchema(Resource[] schemaResources) { + setSchemas(schemaResources); + } + + /** Set the XSD resource to be used. */ + public void setSchema(Resource schemaResource) { + this.schemaResources = new Resource[]{schemaResource}; + } + + /** Set the XSD resources to be used. */ + public void setSchemas(Resource[] schemaResources) { + this.schemaResources = schemaResources; + } + + public XmlValidator getValidator() { + return validator; + } + + public void afterPropertiesSet() throws Exception { + Assert.notEmpty(schemaResources, "'schemaResources' must not be empty"); + XmlSchemaCollection schemaCollection = new XmlSchemaCollection(); + for (int i = 0; i < schemaResources.length; i++) { + Resource schemaResource = schemaResources[i]; + Assert.notNull(schemaResource, "'schemaResource' must not be null"); + Assert.isTrue(schemaResource.exists(), "schema \"" + schemaResource + "\" does not exist"); + schemaCollection.read(SaxUtils.createInputSource(schemaResource), null); + } + XmlSchema[] schemas = schemaCollection.getXmlSchemas(); + List schemaList = new ArrayList(schemaResources.length); + for (int i = 0; i < schemas.length; i++) { + if (!schemas[i].getTargetNamespace().equals("http://www.w3.org/2001/XMLSchema")) { + schemaList.add(new WsCommonsXsdSchemaDocument(schemas[i])); + } + } + this.schemaDocuments = (XsdSchemaDocument[]) schemaList.toArray(new XsdSchemaDocument[schemaList.size()]); + validator = XmlValidatorFactory.createValidator(schemaResources, XmlValidatorFactory.SCHEMA_W3C_XML); + } + + public XsdSchemaDocument[] getSchemaDocuments() { + return schemaDocuments; + } + + /** Inner definition of {@link WsCommonsXsdSchemaDocument}. */ + private static class WsCommonsXsdSchemaDocument implements XsdSchemaDocument { + + private final XmlSchema commonsSchema; + + private WsCommonsXsdSchemaDocument(XmlSchema commonsSchema) { + this.commonsSchema = commonsSchema; + } + + public String getFilename() { + return StringUtils.getFilename(commonsSchema.getSourceURI()); + } + + public Source getSource() { + ByteArrayOutputStream bos = new ByteArrayOutputStream(); + commonsSchema.write(bos); + ByteArrayInputStream bis = new ByteArrayInputStream(bos.toByteArray()); + return new StreamSource(bis); + } + + public XsdElement[] getElements() { + XmlSchemaObjectTable elements = commonsSchema.getElements(); + XsdElement[] declarations = new XsdElement[elements.getCount()]; + int i = 0; + for (Iterator iterator = elements.getValues(); iterator.hasNext();) { + XmlSchemaElement element = (XmlSchemaElement) iterator.next(); + declarations[i] = new WsCommonsXsdElement(element); + i++; + } + return declarations; + } + + public String getTargetNamespace() { + return commonsSchema.getTargetNamespace(); + } + + } + + private static class WsCommonsXsdElement implements XsdElement { + + private final XmlSchemaElement element; + + private WsCommonsXsdElement(XmlSchemaElement element) { + this.element = element; + } + + public QName getName() { + return element.getQName(); + } + } +} diff --git a/xml/src/main/java/org/springframework/xml/schema/xsd/XsdElement.java b/xml/src/main/java/org/springframework/xml/schema/xsd/XsdElement.java new file mode 100644 index 00000000..d010a50a --- /dev/null +++ b/xml/src/main/java/org/springframework/xml/schema/xsd/XsdElement.java @@ -0,0 +1,33 @@ +/* + * Copyright 2007 the original author or authors. + * + * Licensed 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.springframework.xml.schema.xsd; + +import javax.xml.namespace.QName; + +/** + * Represents an abstraction for an XSD element declaration. + * + * @author Arjen Poutsma + * @see XsdSchemaDocument#getElements() + * @since 1.0.2 + */ +public interface XsdElement { + + /** Returns the qualified name of the element declaration. */ + QName getName(); + +} diff --git a/xml/src/main/java/org/springframework/xml/schema/xsd/XsdSchema.java b/xml/src/main/java/org/springframework/xml/schema/xsd/XsdSchema.java new file mode 100644 index 00000000..a76b0b35 --- /dev/null +++ b/xml/src/main/java/org/springframework/xml/schema/xsd/XsdSchema.java @@ -0,0 +1,33 @@ +/* + * Copyright 2007 the original author or authors. + * + * Licensed 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.springframework.xml.schema.xsd; + +import org.springframework.xml.schema.Schema; + +/** + * Represents an abstraction for an XSD schema. An XSD schema is made up of one or more schema documents. + * + * @author Arjen Poutsma + * @see XsdSchemaDocument + * @since 1.0.2 + */ +public interface XsdSchema extends Schema { + + /** Returns the {@link XsdSchemaDocument} objects this schema consists of. */ + XsdSchemaDocument[] getSchemaDocuments(); + +} diff --git a/xml/src/main/java/org/springframework/xml/schema/xsd/XsdSchemaDocument.java b/xml/src/main/java/org/springframework/xml/schema/xsd/XsdSchemaDocument.java new file mode 100644 index 00000000..84bf8536 --- /dev/null +++ b/xml/src/main/java/org/springframework/xml/schema/xsd/XsdSchemaDocument.java @@ -0,0 +1,27 @@ +package org.springframework.xml.schema.xsd; + +import javax.xml.transform.Source; + +/** + * Represents an abstraction for an individual XSD schema document. A schema is made up of one or more schema + * documents. + * + * @author Arjen Poutsma + * @see XsdSchema + * @since 1.0.2 + */ +public interface XsdSchemaDocument { + + /** Return a filename for this schema document. For example, schema.xsd. */ + String getFilename(); + + /** Returns the target namespace of the schema document. */ + String getTargetNamespace(); + + /** Returns the {@link Source} of the schema document. */ + Source getSource(); + + /** Returns the {@link XsdElement} objects of the schema document. */ + XsdElement[] getElements(); + +} diff --git a/xml/src/main/java/org/springframework/xml/schema/xsd/XsdSchemaException.java b/xml/src/main/java/org/springframework/xml/schema/xsd/XsdSchemaException.java new file mode 100644 index 00000000..25b5d6f3 --- /dev/null +++ b/xml/src/main/java/org/springframework/xml/schema/xsd/XsdSchemaException.java @@ -0,0 +1,36 @@ +/* + * Copyright 2006 the original author or authors. + * + * Licensed 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.springframework.xml.schema.xsd; + +import org.springframework.xml.schema.SchemaException; + +/** + * Base class for all XSD schema exceptions. + * + * @author Arjen Poutsma + * @since 1.0.2 + */ +public class XsdSchemaException extends SchemaException { + + public XsdSchemaException(String reason) { + super(reason); + } + + public XsdSchemaException(String reason, Throwable throwable) { + super(reason, throwable); + } +} \ No newline at end of file diff --git a/xml/src/main/java/org/springframework/xml/schema/xsd/package.html b/xml/src/main/java/org/springframework/xml/schema/xsd/package.html new file mode 100644 index 00000000..31fa13c5 --- /dev/null +++ b/xml/src/main/java/org/springframework/xml/schema/xsd/package.html @@ -0,0 +1,6 @@ + + +Provides the XSD Schema functionality of the Spring Web Services framework. Contains the XsdSchema and XsdSchemaDocument +interfaces. + + diff --git a/xml/src/test/java/org/springframework/xml/xsd/AbstractXsdSchemaTestCase.java b/xml/src/test/java/org/springframework/xml/schema/xsd/AbstractXsdSchemaTestCase.java similarity index 91% rename from xml/src/test/java/org/springframework/xml/xsd/AbstractXsdSchemaTestCase.java rename to xml/src/test/java/org/springframework/xml/schema/xsd/AbstractXsdSchemaTestCase.java index 55101edb..537e9912 100644 --- a/xml/src/test/java/org/springframework/xml/xsd/AbstractXsdSchemaTestCase.java +++ b/xml/src/test/java/org/springframework/xml/schema/xsd/AbstractXsdSchemaTestCase.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.xml.xsd; +package org.springframework.xml.schema.xsd; import java.io.IOException; import java.io.InputStream; @@ -72,9 +72,9 @@ public abstract class AbstractXsdSchemaTestCase extends XMLTestCase { assertEquals("Invalid target namespace", "http://www.springframework.org/spring-ws/single", document.getTargetNamespace()); verifyDocument("single.xsd", document); - XsdElementDeclaration[] declarations = document.getElementDeclarations(); + XsdElement[] declarations = document.getElements(); assertEquals("Invalid amount of element declarations", 1, declarations.length); - XsdElementDeclaration declaration = declarations[0]; + XsdElement declaration = declarations[0]; assertEquals("Invalid element declaration name", new QName("http://www.springframework.org/spring-ws/single", "root"), declaration.getName()); } @@ -89,24 +89,24 @@ public abstract class AbstractXsdSchemaTestCase extends XMLTestCase { for (int i = 0; i < documents.length; i++) { XsdSchemaDocument document = documents[i]; assertNotNull("Document is null", document); - XsdElementDeclaration[] elementDeclarations = document.getElementDeclarations(); + XsdElement[] elements = document.getElements(); if ("including.xsd".equals(document.getFilename())) { assertEquals("Invalid target namespace", "http://www.springframework.org/spring-ws/include", document.getTargetNamespace()); verifyDocument("including.xsd", document); - assertEquals("Invalid amount of element declarations", 1, elementDeclarations.length); + assertEquals("Invalid amount of element declarations", 1, elements.length); assertEquals("Invalid element declaration name", new QName("http://www.springframework.org/spring-ws/include", "customElement"), - elementDeclarations[0].getName()); + elements[0].getName()); } else if ("included.xsd".equals(document.getFilename())) { assertEquals("Invalid target namespace", "http://www.springframework.org/spring-ws/include", document.getTargetNamespace()); verifyDocument("included.xsd", document); - assertEquals("Invalid amount of element declarations", 1, elementDeclarations.length); + assertEquals("Invalid amount of element declarations", 1, elements.length); assertEquals("Invalid element declaration name", new QName("http://www.springframework.org/spring-ws/include", "stringElement"), - elementDeclarations[0].getName()); + elements[0].getName()); } else { fail("Invalid filename: " + document.getFilename()); @@ -124,24 +124,24 @@ public abstract class AbstractXsdSchemaTestCase extends XMLTestCase { for (int i = 0; i < documents.length; i++) { XsdSchemaDocument document = documents[i]; assertNotNull("Document is null", document); - XsdElementDeclaration[] elementDeclarations = document.getElementDeclarations(); + XsdElement[] elements = document.getElements(); if ("importing.xsd".equals(document.getFilename())) { assertEquals("Invalid target namespace", "http://www.springframework.org/spring-ws/importing", document.getTargetNamespace()); verifyDocument("importing.xsd", document); - assertEquals("Invalid amount of element declarations", 1, elementDeclarations.length); + assertEquals("Invalid amount of element declarations", 1, elements.length); assertEquals("Invalid element declaration name", new QName("http://www.springframework.org/spring-ws/importing", "customElement"), - elementDeclarations[0].getName()); + elements[0].getName()); } else if ("imported.xsd".equals(document.getFilename())) { assertEquals("Invalid target namespace", "http://www.springframework.org/spring-ws/imported", document.getTargetNamespace()); verifyDocument("imported.xsd", document); - assertEquals("Invalid amount of element declarations", 1, elementDeclarations.length); + assertEquals("Invalid amount of element declarations", 1, elements.length); assertEquals("Invalid element declaration name", new QName("http://www.springframework.org/spring-ws/imported", "stringElement"), - elementDeclarations[0].getName()); + elements[0].getName()); } else { fail("Invalid filename: " + document.getFilename()); diff --git a/xml/src/test/java/org/springframework/xml/xsd/SimpleXsdSchemaTest.java b/xml/src/test/java/org/springframework/xml/schema/xsd/SimpleXsdSchemaTest.java similarity index 95% rename from xml/src/test/java/org/springframework/xml/xsd/SimpleXsdSchemaTest.java rename to xml/src/test/java/org/springframework/xml/schema/xsd/SimpleXsdSchemaTest.java index ff04a0d9..75c5e404 100644 --- a/xml/src/test/java/org/springframework/xml/xsd/SimpleXsdSchemaTest.java +++ b/xml/src/test/java/org/springframework/xml/schema/xsd/SimpleXsdSchemaTest.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.xml.xsd; +package org.springframework.xml.schema.xsd; import org.springframework.core.io.Resource; diff --git a/xml/src/test/java/org/springframework/xml/xsd/WsCommonsXsdSchemaTest.java b/xml/src/test/java/org/springframework/xml/schema/xsd/WsCommonsXsdSchemaTest.java similarity index 95% rename from xml/src/test/java/org/springframework/xml/xsd/WsCommonsXsdSchemaTest.java rename to xml/src/test/java/org/springframework/xml/schema/xsd/WsCommonsXsdSchemaTest.java index 443a0937..a93aa240 100644 --- a/xml/src/test/java/org/springframework/xml/xsd/WsCommonsXsdSchemaTest.java +++ b/xml/src/test/java/org/springframework/xml/schema/xsd/WsCommonsXsdSchemaTest.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.xml.xsd; +package org.springframework.xml.schema.xsd; import java.io.IOException; diff --git a/xml/src/test/resources/org/springframework/xml/xsd/imported.xsd b/xml/src/test/resources/org/springframework/xml/schema/xsd/imported.xsd similarity index 100% rename from xml/src/test/resources/org/springframework/xml/xsd/imported.xsd rename to xml/src/test/resources/org/springframework/xml/schema/xsd/imported.xsd diff --git a/xml/src/test/resources/org/springframework/xml/xsd/importing.xsd b/xml/src/test/resources/org/springframework/xml/schema/xsd/importing.xsd similarity index 100% rename from xml/src/test/resources/org/springframework/xml/xsd/importing.xsd rename to xml/src/test/resources/org/springframework/xml/schema/xsd/importing.xsd diff --git a/xml/src/test/resources/org/springframework/xml/xsd/included.xsd b/xml/src/test/resources/org/springframework/xml/schema/xsd/included.xsd similarity index 100% rename from xml/src/test/resources/org/springframework/xml/xsd/included.xsd rename to xml/src/test/resources/org/springframework/xml/schema/xsd/included.xsd diff --git a/xml/src/test/resources/org/springframework/xml/xsd/including.xsd b/xml/src/test/resources/org/springframework/xml/schema/xsd/including.xsd similarity index 100% rename from xml/src/test/resources/org/springframework/xml/xsd/including.xsd rename to xml/src/test/resources/org/springframework/xml/schema/xsd/including.xsd diff --git a/xml/src/test/resources/org/springframework/xml/xsd/single.xsd b/xml/src/test/resources/org/springframework/xml/schema/xsd/single.xsd similarity index 100% rename from xml/src/test/resources/org/springframework/xml/xsd/single.xsd rename to xml/src/test/resources/org/springframework/xml/schema/xsd/single.xsd