From 6793cfe485255d5bfe5881aa2e7698de335b6bd0 Mon Sep 17 00:00:00 2001 From: slaws Date: Thu, 13 May 2010 20:26:32 +0000 Subject: Allow direct access to the SCA schema. Rather than via the Tuscany schema. At the moment I've turned off validation of sca namespace schema as the OASIS sca schema already includes a "value" element which is an any. So values should validate against anything. Am raising with OASIS but didn't want to do any more fiddling until I get an answer as the guts of this stuff is proving surprisingly frustrating. git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@944004 13f79535-47bb-0310-9956-ffa450edef68 --- .../sca/builder/impl/ComponentBuilderImpl.java | 55 +++++++++++++++------- 1 file changed, 38 insertions(+), 17 deletions(-) (limited to 'sca-java-2.x/trunk/modules/builder/src/main') diff --git a/sca-java-2.x/trunk/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/ComponentBuilderImpl.java b/sca-java-2.x/trunk/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/ComponentBuilderImpl.java index 372a802036..846d45403f 100644 --- a/sca-java-2.x/trunk/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/ComponentBuilderImpl.java +++ b/sca-java-2.x/trunk/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/ComponentBuilderImpl.java @@ -63,6 +63,7 @@ import org.apache.tuscany.sca.assembly.builder.BuilderContext; import org.apache.tuscany.sca.assembly.builder.BuilderExtensionPoint; import org.apache.tuscany.sca.assembly.builder.ImplementationBuilder; import org.apache.tuscany.sca.assembly.builder.Messages; +import org.apache.tuscany.sca.assembly.xsd.Constants; import org.apache.tuscany.sca.core.ExtensionPointRegistry; import org.apache.tuscany.sca.core.FactoryExtensionPoint; import org.apache.tuscany.sca.core.UtilityExtensionPoint; @@ -82,6 +83,7 @@ import org.apache.tuscany.sca.monitor.Monitor; import org.apache.tuscany.sca.policy.ExtensionType; import org.apache.tuscany.sca.policy.PolicySubject; import org.apache.tuscany.sca.xsd.XSDefinition; +import org.apache.ws.commons.schema.XmlSchema; import org.w3c.dom.Document; import org.w3c.dom.Element; import org.w3c.dom.Node; @@ -690,7 +692,7 @@ public class ComponentBuilderImpl { if (propertyXSDType != null){ if (propertyXSDType.getNamespaceURI().equals("http://www.w3.org/2001/XMLSchema")) { - // The property has a simple schema type so we can uses the + // The property has a simple schema type so we can use the // data binding framework to see if the XML value can be transformed // into a simple Java value Document source = (Document)componentProperty.getValue(); @@ -723,23 +725,42 @@ public class ComponentBuilderImpl { Document schemaDom = xsdDefinition.getSchema().getSchemaDocument(); - String valueSchema = " " + - "" + - "" + - "" + - ""; - - Source sources[] = {new DOMSource(schemaDom), new StreamSource(new StringReader(valueSchema))}; - - // create a schema for the property based on all the DOMs from the schema collection - // of the namspace of the property type - // TODO - only getting the top level document here - Schema schema = factory.newSchema(sources); + 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 = " " + + "" + + "" + +// "" + + ""; +// 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 = " " + + "" + + "" + + "" + + ""; + 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(); -- cgit v1.2.3