// Equivalent to getSchema().getSchemaDocument(), but allows us to support older versions of XmlSchema
Document schemaDom = xsdDefinition.getSchema().getAllSchemas()[0];
String valueSchema = null;
Schema schema = null;
if (componentProperty.getXSDType().getNamespaceURI().equals(Constants.SCA11_NS)){
// include the referenced schema as it's already in the OASIS namespace
valueSchema = "<?xml version=\"1.0\" encoding=\"UTF-8\"?> " +
"<schema xmlns=\"http://www.w3.org/2001/XMLSchema\" "+
"xmlns:sca=\"http://docs.oasis-open.org/ns/opencsa/sca/200912\" "+
"xmlns:__tmp=\"" + componentProperty.getXSDType().getNamespaceURI() + "\" "+
"targetNamespace=\"http://docs.oasis-open.org/ns/opencsa/sca/200912\" " +
"elementFormDefault=\"qualified\">" +
"<include schemaLocation=\"" + xsdDefinition.getLocation() + "\"/>" +
// "<element name=\"value\" type=\"" + "__tmp:" + componentProperty.getXSDType().getLocalPart() + "\"/>" +
"</schema>";
// Source sources[] = {new StreamSource(new StringReader(valueSchema))};
Source sources[] = {new DOMSource(schemaDom)};
schema = factory.newSchema(sources);
// The SCA schema already contains a "value" element so I can't create this schema
// the SCA value element is an any so return assuming that it validates.
return;
} else {
// import the referenced schema
valueSchema = "<?xml version=\"1.0\" encoding=\"UTF-8\"?> " +
"<schema xmlns=\"http://www.w3.org/2001/XMLSchema\" "+
"xmlns:sca=\"http://docs.oasis-open.org/ns/opencsa/sca/200912\" "+
"xmlns:__tmp=\"" + componentProperty.getXSDType().getNamespaceURI() + "\" "+
"targetNamespace=\"http://docs.oasis-open.org/ns/opencsa/sca/200912\" " +
"elementFormDefault=\"qualified\">" +
"<import namespace=\"" + componentProperty.getXSDType().getNamespaceURI() + "\"/>" +
"<element name=\"value\" type=\"" + "__tmp:" + componentProperty.getXSDType().getLocalPart() + "\"/>" +
"</schema>";
Source sources[] = {new DOMSource(schemaDom), new StreamSource(new StringReader(valueSchema))};
schema = factory.newSchema(sources);
}
// get the value child of the property element
Document property = (Document)componentProperty.getValue();
Element value = (Element)property.getDocumentElement().getFirstChild();
// validate the element property/value from the DOM
Validator validator = schema.newValidator();
validator.validate(new DOMSource(value));
} catch (Exception e) {
Monitor.error(monitor,
this,