You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by sebge2 <se...@cyberplongeurs.be> on 2010/08/23 14:45:14 UTC

XmlBeans & Schema Location

Hello,

I use XmlBeans as the default databinder. WSDL files are generated at the
runtime. Some XSD files depends on other XSD files defined in other maven
modules. That looks like:

    <xsd:import namespace="http://www.myCompany.com/sf/scheduler/core"
           
schemaLocation="http://www.myCompany.com/schemas/sf/scheduler/core/scheduler-core.xsd"/>

Unfortunately when XmlBeansDataBinding adds the schema importing another
one, it looks for every "import" element, and tries to get the schema based
on its location. Unfortunately, it's considering my schema location (which
is a URL) as a classpath entry
(org.apache.cxf.xmlbeans.XmlBeansSchemaInitializer:130):

        while (elem != null) {
            if (elem.getLocalName().equals("import")) {
                URI uri = new URI(file);
                String loc = elem.getAttribute("schemaLocation");
                if (!StringUtils.isEmpty(loc)) {
                    URI locUri = uri.resolve(loc);
                    String newLoc = locUri.toString();
                    getSchema(sts, newLoc);
                }
            }                 
            elem = DOMUtils.getNextElement(elem);
        }



Where the getSchema method starts with:

    XmlSchema getSchema(SchemaTypeSystem sts, String file) {
        if (schemaMap.containsKey(file)) {
            return schemaMap.get(file);
        }
        InputStream ins = sts.getSourceAsStream(file);
        ......
     }


For instance:
loc = newLoc =
http://www.myCompany.com/schemas/sf/scheduler/core/scheduler-core.xsd


The method getSourceAsStream() will try to read the following resource:
schemaorg_apache_xmlbeans/src/http://www.myCompany.com/schemas/sf/scheduler/core/scheduler-core.xsd

Of course, this is not a classpath resource, but a URL!


So, how is it possible to use URL in imports when XML Beans is used as the
default databinder?


Thanks !
-- 
View this message in context: http://cxf.547215.n5.nabble.com/XmlBeans-Schema-Location-tp2644585p2644585.html
Sent from the cxf-user mailing list archive at Nabble.com.