use of org.whole.lang.xsd.model.Schema in project whole by wholeplatform.
the class AttributesPreprocessor method processNoNamespaceSchemaLocation.
protected void processNoNamespaceSchemaLocation(String schemaLocationUrl) {
String targetNamespace = calculateInternalNamespace(true);
Schema schema = SchemaUtils.load(targetNamespace, schemaLocationUrl, getFolderLocation(), getLSResourceResolver());
// add the generated default namespace to the schema
final XsdEntityFactory xef = XsdEntityFactory.instance;
NamespaceDecl namespaceDecl = xef.createNamespaceDecl();
namespaceDecl.setUri(xef.createAnyURI(targetNamespace));
schema.getNamespaces().add(namespaceDecl);
schema.setTargetNamespace(xef.createAnyURI(targetNamespace));
if (XsdDeployStrategies.shouldDeploy(bindings, targetNamespace))
SchemaUtils.deploy(schema, BindingManagerFactory.instance.createArguments());
redefineDefaultNamespace(namespaces, targetNamespace);
}
use of org.whole.lang.xsd.model.Schema in project whole by wholeplatform.
the class XsdModelBuilderTest method testBuilderAPI.
@Category(KnownFailingTests.class)
@Test
public void testBuilderAPI() throws Exception {
Schema xsdFromInputStream = (Schema) XsdPersistenceKit.instance().readModel(new StreamPersistenceProvider(getInputStream("datatypes.xsd")));
Document document = (Document) XmlSourcePersistenceKit.instance().readModel(new StreamPersistenceProvider(getInputStream("datatypes.xsd")));
IBindingManager bm = BindingManagerFactory.instance.createBindingManager();
bm.wDefValue("mergeCDataSect", true);
XsdDeployStrategies.setDeployStrategy(bm, XsdDeployStrategies.ALL);
ModelBuilderOperation mop = new ModelBuilderOperation();
IBuilderOperation xsdBuilderOperation = new XmlSpecific2XsdBuilderAdapterOperation(mop, bm);
XmlNormalizerBuilderOperation normalizerOp = new XmlNormalizerBuilderOperation(xsdBuilderOperation, bm);
ModelTemplate template = new ModelTemplate(document);
template.apply(new XmlGenericBuilderAdapter((IXmlBuilder) normalizerOp.wGetBuilder(XmlLanguageKit.URI)));
Schema xsdFromXmlModel = (Schema) mop.wGetResult();
Assert.assertTrue(Matcher.match(xsdFromInputStream, xsdFromXmlModel));
}
use of org.whole.lang.xsd.model.Schema in project whole by wholeplatform.
the class XsdLanguageTest method testXsdNormalization.
@Test
public void testXsdNormalization() {
try {
Schema xsdNormalized1 = NormalizerOperation.normalize(loadXsd("schema-to-normalize.xsd"));
Schema xsdNormalized2 = loadXsd("schema-normalized.xsd");
Assert.assertTrue(OrderedMatcher.match(xsdNormalized2, xsdNormalized1, comparatorsMap));
} catch (Exception e) {
Assert.fail(e.getMessage());
}
}
use of org.whole.lang.xsd.model.Schema in project whole by wholeplatform.
the class XsdLanguageTest method loadSchemaInstance.
private void loadSchemaInstance(String schemaFileName, String... instanceFileNames) throws Exception {
IBindingManager bm = BindingManagerFactory.instance.createArguments();
String folderLocation = new File("test/org/whole/lang/xsd/util").getAbsolutePath();
bm.wDefValue("folderLocation", folderLocation);
bm.wDefValue("packageName", "");
Schema xsd = loadXsd(schemaFileName);
InterpreterOperation.interpret(xsd, bm);
for (String instanceFileName : instanceFileNames) XsiPersistenceKit.instance().readModel(new StreamPersistenceProvider(getInputStream(instanceFileName)));
}
use of org.whole.lang.xsd.model.Schema 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);
}
Aggregations