Announcement Announcement Module
Collapse
No announcement yet.
CommonsXsdSchemaCollection and local schemas Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • CommonsXsdSchemaCollection and local schemas

    Hi,

    I'm trying to use CommonsXsdSchemaCollection to perform some XML validation using local schemas, but I'm having problems when validating against a schema which imports another one. The latter is fetched from the internet even if it's available locally; if the network is not available, then a org.apache.ws.commons.schema.XmlSchemaException is thrown.

    The only thread I found with some connections to this problem is http://forum.springsource.org/showpo...04&postcount=6, mentioning something wrong with the underlying URIResolver. Was there any following to the discussion (JIRA issues, etc.)?

    I'm using Spring Web Services 2.0.0.RELEASE and Apache XmlSchema 1.4.7. I can provide a small example class and XML code if needed.

    thanks,
    Gianluca

  • #2
    sample code

    Since there was no response, I'll post a small example, just to clarify what my issue is.

    the class below:

    Code:
    import org.springframework.core.io.ClassPathResource;
    import org.springframework.core.io.Resource;
    import org.springframework.xml.xsd.commons.CommonsXsdSchemaCollection;
    
    public class ImportedSchemaTest {
    
        public static void main(String[] args) throws Exception {
    
            // downloaded from:
            // - http://www.openarchives.org/OAI/2.0/oai_dc.xsd
            // - http://dublincore.org/schemas/xmls/simpledc20021212.xsd
            // - http://www.w3.org/2001/xml.xsd
            Resource[] resources = {
                    new ClassPathResource("oai_dc.xsd")  ,
                    new ClassPathResource("simpledc20021212.xsd"),
                    new ClassPathResource("xml.xsd")
            };
            CommonsXsdSchemaCollection schemaCollection = new CommonsXsdSchemaCollection(resources);
            schemaCollection.setXsds(resources);
            schemaCollection.afterPropertiesSet();
            schemaCollection.createValidator();
        }
    
    }
    will throw an exception if executed without internet connectivity. oai_dc.xsd contains an import to http://dublincore.org/schemas/xmls/simpledc20021212.xsd, but CommonsXsdSchemaCollection doesn't realize that the XSD is available locally and tries to download it.

    Comment

    Working...
    X