Problem reading imported schemas with absolute path [message #602753] |
Wed, 12 December 2007 22:48 |
Eclipse User |
|
|
|
Originally posted by: sdjuricic.galdosinc.com
Hello,
I have a problem when loading imported schemas that have schemaLocation
set with an absolute path without the file protocol prefix. The main
schema will be loaded but the imported schemas will not be loaded. All
the xsd files are located on my file system. If I change the
schemaLocation to be a relative path to the main schema then I do not have
an issue. The only way how all schemas will be loaded with absolute path
is if schemaLocation contains the file protocol prefix
example. file://C:/folderA/A.xsd
Is there a way to load all resources when the schemaLocation contains only
the absolute path without the file:// prefix? When loading without the
file:// even though schemas do not get loaded I don't get any error
messages about not being able to load imported schemas. Is there a way to
specify an error listener or to check for error if a particular imported
resource was not loaded.
I am using the following method to load the schemas. This method was just
copied from the example given.
URI uri;
String filePath = "C:/projects/test.xsd"
File file = new File(filePath);
if (file.isFile()) {
uri = URI.createFileURI(file.getCanonicalFile().toString());
} else {
uri = URI.createURI(filePath);
}
Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap( )
.put("xsd", new XSDResourceFactoryImpl());
ResourceSet resourceSet = new ResourceSetImpl();
XSDResourceImpl xsdMainResource =
(XSDResourceImpl)resourceSet.createResource(URI.createURI("*.xsd "));
xsdMainResource.setURI(uri);
xsdMainResource.load(resourceSet.getLoadOptions());
for (Iterator resources = resourceSet.getResources().iterator();
resources.hasNext(); ) {
Object resource = resources.next();
if (resource instanceof XSDResourceImpl) {
XSDResourceImpl xsdResource = (XSDResourceImpl)resource;
XSDSchema xsdSchema = xsdResource.getSchema();
}
|
|
|
Powered by
FUDForum. Page generated in 0.02729 seconds