Author: slaws
Date: Thu May 13 20:26:32 2010
New Revision: 944004
URL: http://svn.apache.org/viewvc?rev=944004&view=rev
Log:
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.
Modified:
tuscany/sca-java-2.x/trunk/modules/assembly-xsd/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.ValidationSchema
tuscany/sca-java-2.x/trunk/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/ComponentBuilderImpl.java
tuscany/sca-java-2.x/trunk/modules/deployment/src/main/java/org/apache/tuscany/sca/deployment/impl/DeployerImpl.java
Modified:
tuscany/sca-java-2.x/trunk/modules/assembly-xsd/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.ValidationSchema
URL:
http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/modules/assembly-xsd/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.ValidationSchema?rev=944004&r1=944003&r2=944004&view=diff
==============================================================================
---
tuscany/sca-java-2.x/trunk/modules/assembly-xsd/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.ValidationSchema
(original)
+++
tuscany/sca-java-2.x/trunk/modules/assembly-xsd/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.ValidationSchema
Thu May 13 20:26:32 2010
@@ -15,4 +15,5 @@
# specific language governing permissions and limitations
# under the License.
#
-tuscany-sca-1.1.xsd
+tuscany-sca-1.1.xsd
+sca-1.1-cd05.xsd
Modified:
tuscany/sca-java-2.x/trunk/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/ComponentBuilderImpl.java
URL:
http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/ComponentBuilderImpl.java?rev=944004&r1=944003&r2=944004&view=diff
==============================================================================
---
tuscany/sca-java-2.x/trunk/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/ComponentBuilderImpl.java
(original)
+++
tuscany/sca-java-2.x/trunk/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/ComponentBuilderImpl.java
Thu May 13 20:26:32 2010
@@ -63,6 +63,7 @@ import org.apache.tuscany.sca.assembly.b
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.Mo
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 = "<?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))};
-
- // 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 = "<?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();
Modified:
tuscany/sca-java-2.x/trunk/modules/deployment/src/main/java/org/apache/tuscany/sca/deployment/impl/DeployerImpl.java
URL:
http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/modules/deployment/src/main/java/org/apache/tuscany/sca/deployment/impl/DeployerImpl.java?rev=944004&r1=944003&r2=944004&view=diff
==============================================================================
---
tuscany/sca-java-2.x/trunk/modules/deployment/src/main/java/org/apache/tuscany/sca/deployment/impl/DeployerImpl.java
(original)
+++
tuscany/sca-java-2.x/trunk/modules/deployment/src/main/java/org/apache/tuscany/sca/deployment/impl/DeployerImpl.java
Thu May 13 20:26:32 2010
@@ -404,10 +404,10 @@ public class DeployerImpl implements Dep
scaSchema.setLocation(scaSchemaURL.toURI());
scaSchema.setUnresolved(false);
// modelResolver.addModel(scaSchema, context);
-
+ } else if (namespace.equals(Constants.SCA11_NS)) {
// we know that the SCA schema's are referenced form the
Tuscany schemas so
- // register the schema under the SCA namsepace too
- scaSchema = xsdFactory.createXSDefinition();
+ // register the schema under the SCA namespace too
+ XSDefinition scaSchema = xsdFactory.createXSDefinition();
scaSchema.setUnresolved(true);
scaSchema.setNamespace(Constants.SCA11_NS);
scaSchema.setLocation(scaSchemaURL.toURI());