From e8b552deb4ad4b7ace30355fcd8cca1653c4a7a2 Mon Sep 17 00:00:00 2001 From: Arjen Poutsma Date: Sat, 3 May 2008 21:06:35 +0000 Subject: [PATCH] SWS-339 --- .../xml/xsd/commons/CommonsXsdSchemaCollection.java | 6 ++++-- .../xml/xsd/commons/CommonsXsdSchemaCollectionTest.java | 9 +++++++++ .../org/springframework/xml/xsd/xmlNamespace.xsd | 2 +- 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/xml/src/main/java/org/springframework/xml/xsd/commons/CommonsXsdSchemaCollection.java b/xml/src/main/java/org/springframework/xml/xsd/commons/CommonsXsdSchemaCollection.java index c1c1338d..0a624f76 100644 --- a/xml/src/main/java/org/springframework/xml/xsd/commons/CommonsXsdSchemaCollection.java +++ b/xml/src/main/java/org/springframework/xml/xsd/commons/CommonsXsdSchemaCollection.java @@ -163,8 +163,10 @@ public class CommonsXsdSchemaCollection implements XsdSchemaCollection, Initiali for (int i = 0; i < imports.getCount(); i++) { XmlSchemaExternal external = (XmlSchemaExternal) imports.getItem(i); if (external instanceof XmlSchemaImport) { - XmlSchema importedSchema = external.getSchema(); - if (importedSchema != null && !processedSchemas.contains(importedSchema)) { + XmlSchemaImport schemaImport = (XmlSchemaImport) external; + XmlSchema importedSchema = schemaImport.getSchema(); + if (!"http://www.w3.org/XML/1998/namespace".equals(schemaImport.getNamespace()) && + importedSchema != null && !processedSchemas.contains(importedSchema)) { inlineIncludes(importedSchema, processedSchemas); findImports(importedSchema, processedSchemas); xmlSchemas.add(importedSchema); diff --git a/xml/src/test/java/org/springframework/xml/xsd/commons/CommonsXsdSchemaCollectionTest.java b/xml/src/test/java/org/springframework/xml/xsd/commons/CommonsXsdSchemaCollectionTest.java index 43b18eb6..631ab27e 100644 --- a/xml/src/test/java/org/springframework/xml/xsd/commons/CommonsXsdSchemaCollectionTest.java +++ b/xml/src/test/java/org/springframework/xml/xsd/commons/CommonsXsdSchemaCollectionTest.java @@ -90,6 +90,15 @@ public class CommonsXsdSchemaCollectionTest extends XMLTestCase { assertEquals("Invalid amount of XSDs loaded", 1, schemas.length); } + public void testXmlNamespace() throws Exception { + Resource resource = new ClassPathResource("xmlNamespace.xsd", AbstractXsdSchemaTestCase.class); + collection.setXsds(new Resource[]{resource}); + collection.setInline(true); + collection.afterPropertiesSet(); + XsdSchema[] schemas = collection.getXsdSchemas(); + assertEquals("Invalid amount of XSDs loaded", 1, schemas.length); + } + public void testCreateValidator() throws Exception { Resource a = new ClassPathResource("A.xsd", AbstractXsdSchemaTestCase.class); collection.setXsds(new Resource[]{a}); diff --git a/xml/src/test/resources/org/springframework/xml/xsd/xmlNamespace.xsd b/xml/src/test/resources/org/springframework/xml/xsd/xmlNamespace.xsd index 398b0ccd..eebd4bc5 100644 --- a/xml/src/test/resources/org/springframework/xml/xsd/xmlNamespace.xsd +++ b/xml/src/test/resources/org/springframework/xml/xsd/xmlNamespace.xsd @@ -4,7 +4,7 @@ xmlns="http://www.springframework.org/spring-ws/xmlNamespace" elementFormDefault="qualified" attributeFormDefault="unqualified"> - +