SWS-339
This commit is contained in:
@@ -159,12 +159,12 @@ public class CommonsXsdSchemaCollection implements XsdSchemaCollection, Initiali
|
||||
|
||||
private void findImports(XmlSchema schema, List processedSchemas) {
|
||||
processedSchemas.add(schema);
|
||||
XmlSchemaObjectCollection includes = schema.getIncludes();
|
||||
for (int i = 0; i < includes.getCount(); i++) {
|
||||
XmlSchemaExternal external = (XmlSchemaExternal) includes.getItem(i);
|
||||
XmlSchemaObjectCollection imports = schema.getIncludes();
|
||||
for (int i = 0; i < imports.getCount(); i++) {
|
||||
XmlSchemaExternal external = (XmlSchemaExternal) imports.getItem(i);
|
||||
if (external instanceof XmlSchemaImport) {
|
||||
XmlSchema importedSchema = external.getSchema();
|
||||
if (!processedSchemas.contains(importedSchema)) {
|
||||
if (importedSchema != null && !processedSchemas.contains(importedSchema)) {
|
||||
inlineIncludes(importedSchema, processedSchemas);
|
||||
findImports(importedSchema, processedSchemas);
|
||||
xmlSchemas.add(importedSchema);
|
||||
|
||||
@@ -85,6 +85,19 @@ public abstract class AbstractXsdSchemaTestCase extends XMLTestCase {
|
||||
assertXMLEqual("Invalid Source returned", expected, result);
|
||||
}
|
||||
|
||||
public void testXmlNamespace() throws Exception {
|
||||
Resource resource = new ClassPathResource("xmlNamespace.xsd", AbstractXsdSchemaTestCase.class);
|
||||
XsdSchema importing = createSchema(resource);
|
||||
String namespace = "http://www.springframework.org/spring-ws/xmlNamespace";
|
||||
assertEquals("Invalid target namespace", namespace, importing.getTargetNamespace());
|
||||
resource = new ClassPathResource("xmlNamespace.xsd", AbstractXsdSchemaTestCase.class);
|
||||
Document expected = documentBuilder.parse(SaxUtils.createInputSource(resource));
|
||||
DOMResult domResult = new DOMResult();
|
||||
transformer.transform(importing.getSource(), domResult);
|
||||
Document result = (Document) domResult.getNode();
|
||||
assertXMLEqual("Invalid Source returned", expected, result);
|
||||
}
|
||||
|
||||
public void testCreateValidator() throws Exception {
|
||||
Resource resource = new ClassPathResource("single.xsd", AbstractXsdSchemaTestCase.class);
|
||||
XsdSchema single = createSchema(resource);
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
|
||||
targetNamespace="http://www.springframework.org/spring-ws/xmlNamespace"
|
||||
xmlns="http://www.springframework.org/spring-ws/xmlNamespace" elementFormDefault="qualified"
|
||||
attributeFormDefault="unqualified">
|
||||
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace"/>
|
||||
|
||||
<xsd:element name="GetOrderRequest">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="child" type="xsd:string"/>
|
||||
</xsd:sequence>
|
||||
<xsd:attribute ref="xml:lang" use="required"/>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
|
||||
</xsd:schema>
|
||||
Reference in New Issue
Block a user