Author: lmandel
Date: Mon Mar 6 16:14:33 2006
New Revision: 383722
URL: http://svn.apache.org/viewcvs?rev=383722&view=rev
Log:
[WODEN-1] Added a temporary fix to implicitly include schema types in the Woden
model.
Modified:
incubator/woden/java/src/org/apache/woden/internal/DOMWSDLReader.java
incubator/woden/java/test/org/apache/woden/internal/wsdl20/validation/WSDLDocumentValidatorTest.java
Modified: incubator/woden/java/src/org/apache/woden/internal/DOMWSDLReader.java
URL:
http://svn.apache.org/viewcvs/incubator/woden/java/src/org/apache/woden/internal/DOMWSDLReader.java?rev=383722&r1=383721&r2=383722&view=diff
==============================================================================
--- incubator/woden/java/src/org/apache/woden/internal/DOMWSDLReader.java
(original)
+++ incubator/woden/java/src/org/apache/woden/internal/DOMWSDLReader.java Mon
Mar 6 16:14:33 2006
@@ -27,6 +27,7 @@
import java.util.Map;
import javax.xml.namespace.QName;
+import javax.xml.parsers.DocumentBuilderFactory;
import org.apache.woden.ErrorHandler;
import org.apache.woden.ErrorReporter;
@@ -316,6 +317,34 @@
tempEl = DOMUtils.getNextSiblingElement(tempEl);
}
+
+ // Parse the schema for schema to include the built in schema types in
the Woden model.
+ // TODO: As there are a finite number of built in schema types it may
be better to create
+ // constants rather than reading the schema for schema on the creation
of every model.
+ // Also, this method currently requires that the schema elements exist
in the types element.
+ // This may not be the best idea as it may imply that this schema
contains an actual import
+ // statement in a WSDL 2.0 document. This method also does not work
for when building the
+ // model programmatically.
+ // This method should be reevaluated at a later point.
+ if(desc.getTypesElement() == null)
+ {
+ TypesElement types = desc.createTypesElement();
+ types.setTypeSystem(Constants.TYPE_XSD_2001);
+ desc.setTypesElement(types);
+ }
+ try
+ {
+ Document schemaDoc =
DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument();
+ Element schemaElem =
schemaDoc.createElementNS("http://www.w3.org/2001/XMLSchema", "import");
+ schemaElem.setAttribute("namespace",
"http://www.w3.org/2001/XMLSchema");
+ schemaElem.setAttribute("schemaLocation",
"http://www.w3.org/2001/XMLSchema.xsd");
+ desc.getTypesElement().addSchema(parseSchemaImport(schemaElem,
desc));
+ }
+ catch(Exception e)
+ {
+ System.out.println("A problem was encountered while creating the
build in XML schema types: " + e);
+ }
+
return desc;
}
Modified:
incubator/woden/java/test/org/apache/woden/internal/wsdl20/validation/WSDLDocumentValidatorTest.java
URL:
http://svn.apache.org/viewcvs/incubator/woden/java/test/org/apache/woden/internal/wsdl20/validation/WSDLDocumentValidatorTest.java?rev=383722&r1=383721&r2=383722&view=diff
==============================================================================
---
incubator/woden/java/test/org/apache/woden/internal/wsdl20/validation/WSDLDocumentValidatorTest.java
(original)
+++
incubator/woden/java/test/org/apache/woden/internal/wsdl20/validation/WSDLDocumentValidatorTest.java
Mon Mar 6 16:14:33 2006
@@ -1201,6 +1201,31 @@
{
fail("There was a problem running the test assertion method " + e);
}
+
+ // Test that a reference to a built in XML schema type such as
xs:string returns an error.
+ // TODO: Enable this test once the workaround for schema types has been
resolved.
+// handler.reset();
+// try
+// {
+//
+// DescriptionElement descElem = new DescriptionImpl();
+// InterfaceElement interfaceElem = descElem.createInterfaceElement();
+// InterfaceOperationElement interfaceOperation =
descElem.createInterfaceOperationElement();
+// InterfaceMessageReferenceElement messageRef =
descElem.createInterfaceMessageReferenceElement();
+// messageRef.setElementName(new
QName("http://www.w3.org/2001/XMLSchema", "string"));
+// interfaceOperation.addInterfaceMessageReferenceElement(messageRef);
+// interfaceElem.addInterfaceOperationElement(interfaceOperation);
+// descElem.addInterfaceElement(interfaceElem);
+//
+// if(val.testAssertionSchema0020(descElem, messageRef, reporter))
+// {
+// fail("The testAssertionSchema0020 method returned true for an
message reference that refers to a built in XML schema type.");
+// }
+// }
+// catch(WSDLException e)
+// {
+// fail("There was a problem running the test assertion method " + e);
+// }
}
/**
@@ -1308,6 +1333,28 @@
{
fail("There was a problem running the test assertion method " + e);
}
+
+ // Test that a reference to a built in XML schema type such as
xs:string returns an error.
+ // TODO: Enable this test once the workaround for schema types has been
resolved.
+// handler.reset();
+// try
+// {
+// DescriptionElement descElem = new DescriptionImpl();
+// InterfaceElement interfaceElem = descElem.createInterfaceElement();
+// InterfaceFaultElement fault = descElem.createInterfaceFaultElement();
+// fault.setElementName(new QName("http://www.w3.org/2001/XMLSchema",
"string"));
+// interfaceElem.addInterfaceFaultElement(fault);
+// descElem.addInterfaceElement(interfaceElem);
+//
+// if(val.testAssertionSchema0020b(descElem, fault, reporter))
+// {
+// fail("The testAssertionSchema0020b method returned true for a fault
that refers to a built in XML schema type.");
+// }
+// }
+// catch(WSDLException e)
+// {
+// fail("There was a problem running the test assertion method " + e);
+// }
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]