use of org.eclipse.wst.xsd.contentmodel.internal.util.XSDSchemaLocatorAdapterFactory in project webtools.sourceediting by eclipse.
the class XSDImpl method buildXSDModel.
/**
* Given uri for an XML Schema document, parse the document and build
* corresponding CMDocument node.
*
* @param uri -
* the uri for an XML Schema document
* @return the corresponding CMDocument node.
*/
public static XSDSchema buildXSDModel(String uriString) {
XSDSchema xsdSchema = null;
try {
// if XML Schema for Schema is requested, get it through schema model
if (uriString.endsWith("2001/XMLSchema.xsd")) {
xsdSchema = XSDSchemaImpl.getSchemaForSchema(XSDConstants.SCHEMA_FOR_SCHEMA_URI_2001);
} else {
ResourceSet resourceSet = new ResourceSetImpl();
// resourceSet.getAdapterFactories().add(new XSDSchemaLocationResolverAdapterFactory());
resourceSet.getAdapterFactories().add(new XSDSchemaLocatorAdapterFactory());
URI uri = createURI(uriString);
// CS : bug 113537 ensure we perform physical resolution before opening a stream for the resource
//
String physicalLocation = URIResolverPlugin.createResolver().resolvePhysicalLocation("", "", uriString);
InputStream inputStream = resourceSet.getURIConverter().createInputStream(URI.createURI(physicalLocation));
XSDResourceImpl resource = (XSDResourceImpl) resourceSet.createResource(URI.createURI("*.xsd"));
resource.setURI(uri);
resource.load(inputStream, null);
xsdSchema = resource.getSchema();
}
} catch (Exception e) {
}
return xsdSchema;
}
Aggregations