use of org.whole.lang.xml.util.InputStreamInput in project whole by wholeplatform.
the class XsdRegistry method deploySchemaForSchema.
protected void deploySchemaForSchema() {
String location = "XMLSchema.xsd";
MappingStrategyRegistry.instance().putMappingModel(new SchemaMapping().create());
// FIXME replace with real schema for schema model with annotations
InputStream is = getClass().getResourceAsStream(location);
Schema schemaForSchema = SchemaUtils.load(new InputStreamInput(is));
putSchema(location, schemaForSchema, true);
}
use of org.whole.lang.xml.util.InputStreamInput in project whole by wholeplatform.
the class XsdRegistry method predeploySchemas.
protected void predeploySchemas(String... locations) {
IBindingManager args = BindingManagerFactory.instance.createArguments();
args.wDefValue("predeployed", true);
args.wDefValue("fileName", "");
args.wDefValue("fileExtension", "");
args.wDefValue("fileNameWithExtension", "");
args.wDefValue("fileLocationURI", "");
for (String location : locations) {
String fileNameWithExtension = location.replaceFirst("^.*/", "");
String filename = fileNameWithExtension.replaceFirst("\\.[^\\.]*$", "");
args.wSetValue("fileName", filename);
args.wSetValue("fileExtension", fileNameWithExtension.substring(filename.length() + 1));
args.wSetValue("fileNameWithExtension", fileNameWithExtension);
args.wSetValue("fileLocationURI", getClass().getResource(location).toExternalForm());
InputStream is = getClass().getResourceAsStream(location);
Schema schema = SchemaUtils.load(new InputStreamInput(is));
InterpreterOperation.interpret(schema, args);
}
}
use of org.whole.lang.xml.util.InputStreamInput in project whole by wholeplatform.
the class SchemaUtils method resolve.
// /* was LSInput, workaround for Android compatibility */
// private static InputStreamInput resolve(String namespaceURI, String schemaLocationURI, String folderLocation) {
// return resolve(namespaceURI, schemaLocationURI, folderLocation, null);
// }
/* was LSInput, workaround for Android compatibility */
private static InputStreamInput resolve(String namespaceURI, String schemaLocationURI, String folderLocation, /* was LSResourceResolver, workaround for Android compatibility */
ResourceResolver lsResourceResolver) {
try {
// try to resolve using provided LSResourceResolver
URI schemaLocation = new URI(schemaLocationURI);
URI folder = new File(folderLocation).toURI();
if (lsResourceResolver != null) {
/* was LSInput, workaround for Android compatibility */
InputStreamInput lsInput = lsResourceResolver.resolveResource(NamespaceUtils.XSD_NAMESPACE_URI, namespaceURI, null, schemaLocationURI, schemaLocation.isAbsolute() ? null : folder.toASCIIString());
if (lsInput != null)
return lsInput;
}
// try to resolve directly using provided schemaLocation
schemaLocation = folder.resolve(schemaLocation);
URLConnection connection = schemaLocation.toURL().openConnection();
InputStream is = connection.getInputStream();
return new InputStreamInput(is);
} catch (Exception e) {
// fail silently
}
return null;
}
Aggregations