Undefined XSD element (test + fix)

Project: http://git-wip-us.apache.org/repos/asf/ode/repo
Commit: http://git-wip-us.apache.org/repos/asf/ode/commit/274a89c0
Tree: http://git-wip-us.apache.org/repos/asf/ode/tree/274a89c0
Diff: http://git-wip-us.apache.org/repos/asf/ode/diff/274a89c0

Branch: refs/heads/ode-1.3.x
Commit: 274a89c0c388fe9255c84312191a4d6848f45591
Parents: eb46426
Author: Rafal Konrad Rusin <[email protected]>
Authored: Thu Jul 22 07:22:14 2010 +0000
Committer: Tammo van Lessen <[email protected]>
Committed: Tue Jun 9 17:56:04 2015 +0200

----------------------------------------------------------------------
 Rakefile                                        |  1 +
 .../apache/ode/bpel/compiler/BpelCompiler.java  |  2 +-
 .../apache/ode/bpel/compiler/WSDLRegistry.java  | 11 ++++-
 .../ode/bpel/compiler_2_0/GoodCompileTest.java  |  4 +-
 .../bpel/compiler/MultipleEmbeddedSchemas.bpel  | 33 +++++++++++++
 .../bpel/compiler/MultipleEmbeddedSchemas.wsdl  | 49 ++++++++++++++++++++
 .../apache/ode/utils/xsd/SchemaModelImpl.java   |  2 +
 .../java/org/apache/ode/utils/xsd/XSUtils.java  |  6 ++-
 .../apache/ode/utils/xsd/SchemaCaptureTest.java |  2 +-
 9 files changed, 102 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ode/blob/274a89c0/Rakefile
----------------------------------------------------------------------
diff --git a/Rakefile b/Rakefile
index 7996ef0..3736586 100644
--- a/Rakefile
+++ b/Rakefile
@@ -180,6 +180,7 @@ define "ode" do
     compile.with projects("bpel-api", "bpel-obj", "bpel-schemas", "utils"),
       COMMONS.logging, JAVAX.stream, JAXEN, SAXON, WSDL4J, XALAN, XERCES, 
COMMONS.collections
     test.resources { 
filter(project("bpel-scripts").path_to("src/main/resources")).into(test.resources.target).run
 }
+    test.with LOG4J
     package :jar
     test.with SLF4J, LOG4J
   end

http://git-wip-us.apache.org/repos/asf/ode/blob/274a89c0/bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/BpelCompiler.java
----------------------------------------------------------------------
diff --git 
a/bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/BpelCompiler.java 
b/bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/BpelCompiler.java
index bf42c2e..e8b20bb 100644
--- a/bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/BpelCompiler.java
+++ b/bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/BpelCompiler.java
@@ -226,7 +226,7 @@ public abstract class BpelCompiler implements 
CompilerContext {
                 xsdStream.close();
             }
             
-            Map<URI, byte[]> schemas = XSUtils.captureSchema(resFrom, data, 
resolver);
+            Map<URI, byte[]> schemas = XSUtils.captureSchema(resFrom, data, 
resolver, 0);
             _wsdlRegistry.addSchemas(schemas);
         } catch (XsdException e) {
             CompilationException ce =  new 
CompilationException(__cmsgs.errInvalidImport(location.toString()));

http://git-wip-us.apache.org/repos/asf/ode/blob/274a89c0/bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/WSDLRegistry.java
----------------------------------------------------------------------
diff --git 
a/bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/WSDLRegistry.java 
b/bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/WSDLRegistry.java
index b7e9077..319666d 100644
--- a/bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/WSDLRegistry.java
+++ b/bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/WSDLRegistry.java
@@ -213,6 +213,7 @@ class WSDLRegistry {
         Types types = def.getTypes();
 
         if (types != null) {
+            int localSchemaId = 0;
             for (Iterator<ExtensibilityElement> iter =
                     
((List<ExtensibilityElement>)def.getTypes().getExtensibilityElements()).iterator();
                  iter.hasNext();) {
@@ -222,8 +223,13 @@ class WSDLRegistry {
                     byte[] schema = ((XMLSchemaType)ee).getXMLSchema();
                     WsdlFinderXMLEntityResolver resolver = new 
WsdlFinderXMLEntityResolver(rf, defuri, _internalSchemas, false);
                     try {
-                        Map<URI, byte[]> capture = 
XSUtils.captureSchema(defuri, schema, resolver);
-                        _schemas.putAll(capture);
+                        Map<URI, byte[]> capture = 
XSUtils.captureSchema(defuri, schema, resolver, localSchemaId);
+                        for (URI uri : capture.keySet()) {
+                            if (!_schemas.containsKey(uri)) {
+                                _schemas.put(uri, capture.get(uri));
+                            }
+                        }
+//                        _schemas.putAll(capture);
 
                         try {
                             Document doc = DOMUtils.parse(new InputSource(new 
ByteArrayInputStream(schema)));
@@ -258,6 +264,7 @@ class WSDLRegistry {
                     // invalidate model
                     _model = null;
 
+                    localSchemaId ++;
                 }
             }
         }

http://git-wip-us.apache.org/repos/asf/ode/blob/274a89c0/bpel-compiler/src/test/java/org/apache/ode/bpel/compiler_2_0/GoodCompileTest.java
----------------------------------------------------------------------
diff --git 
a/bpel-compiler/src/test/java/org/apache/ode/bpel/compiler_2_0/GoodCompileTest.java
 
b/bpel-compiler/src/test/java/org/apache/ode/bpel/compiler_2_0/GoodCompileTest.java
index 785d2be..4f53b2b 100644
--- 
a/bpel-compiler/src/test/java/org/apache/ode/bpel/compiler_2_0/GoodCompileTest.java
+++ 
b/bpel-compiler/src/test/java/org/apache/ode/bpel/compiler_2_0/GoodCompileTest.java
@@ -78,8 +78,8 @@ public class GoodCompileTest extends TestCase {
         suite.addTest(new 
GoodCompileTCase("/2.0/good/xpath20-func/GetVariableData4-xp2.0.bpel"));
         suite.addTest(new 
GoodCompileTCase("/2.0/good/xpath20-func/GetVariableProperty1-xp2.0.bpel"));
         suite.addTest(new 
GoodCompileTCase("/2.0/good/xsd-import/helloworld-Server.bpel"));
-        
+        suite.addTest(new 
GoodCompileTCase("/org/apache/ode/bpel/compiler/MultipleEmbeddedSchemas.bpel"));
+
         return suite;
     }
-
 }

http://git-wip-us.apache.org/repos/asf/ode/blob/274a89c0/bpel-compiler/src/test/resources/org/apache/ode/bpel/compiler/MultipleEmbeddedSchemas.bpel
----------------------------------------------------------------------
diff --git 
a/bpel-compiler/src/test/resources/org/apache/ode/bpel/compiler/MultipleEmbeddedSchemas.bpel
 
b/bpel-compiler/src/test/resources/org/apache/ode/bpel/compiler/MultipleEmbeddedSchemas.bpel
new file mode 100644
index 0000000..0c87d15
--- /dev/null
+++ 
b/bpel-compiler/src/test/resources/org/apache/ode/bpel/compiler/MultipleEmbeddedSchemas.bpel
@@ -0,0 +1,33 @@
+<!--
+  ~ Licensed to the Apache Software Foundation (ASF) under one
+  ~ or more contributor license agreements.  See the NOTICE file
+  ~ distributed with this work for additional information
+  ~ regarding copyright ownership.  The ASF licenses this file
+  ~ to you under the Apache License, Version 2.0 (the
+  ~ "License"); you may not use this file except in compliance
+  ~ with the License.  You may obtain a copy of the License at
+  ~
+  ~    http://www.apache.org/licenses/LICENSE-2.0
+  ~
+  ~ Unless required by applicable law or agreed to in writing,
+  ~ software distributed under the License is distributed on an
+  ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+  ~ KIND, either express or implied.  See the License for the
+  ~ specific language governing permissions and limitations
+  ~ under the License.
+  -->
+
+<process
+    name="InvalidBpelFunction" suppressJoinFailure="yes"
+    targetNamespace="http://ode/test/compile";
+    xmlns="http://docs.oasis-open.org/wsbpel/2.0/process/executable";
+    xmlns:bpws="http://docs.oasis-open.org/wsbpel/2.0/process/executable";
+    xmlns:tns="http://ode/test/compile";
+    xmlns:xsd="http://www.w3.org/2001/XMLSchema";
+    xmlns:test="http://ode/test/compile.wsdl";>
+    <import namespace="http://ode/test/compile.wsdl"; 
location="MultipleEmbeddedSchemas.wsdl" 
importType="http://schemas.xmlsoap.org/wsdl/"/>
+    <variables>
+        <variable name="var1" messageType="test:TestMessage" />
+    </variables>
+    <empty/>
+</process>

http://git-wip-us.apache.org/repos/asf/ode/blob/274a89c0/bpel-compiler/src/test/resources/org/apache/ode/bpel/compiler/MultipleEmbeddedSchemas.wsdl
----------------------------------------------------------------------
diff --git 
a/bpel-compiler/src/test/resources/org/apache/ode/bpel/compiler/MultipleEmbeddedSchemas.wsdl
 
b/bpel-compiler/src/test/resources/org/apache/ode/bpel/compiler/MultipleEmbeddedSchemas.wsdl
new file mode 100644
index 0000000..593592c
--- /dev/null
+++ 
b/bpel-compiler/src/test/resources/org/apache/ode/bpel/compiler/MultipleEmbeddedSchemas.wsdl
@@ -0,0 +1,49 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+  ~ Licensed to the Apache Software Foundation (ASF) under one
+  ~ or more contributor license agreements.  See the NOTICE file
+  ~ distributed with this work for additional information
+  ~ regarding copyright ownership.  The ASF licenses this file
+  ~ to you under the Apache License, Version 2.0 (the
+  ~ "License"); you may not use this file except in compliance
+  ~ with the License.  You may obtain a copy of the License at
+  ~
+  ~    http://www.apache.org/licenses/LICENSE-2.0
+  ~
+  ~ Unless required by applicable law or agreed to in writing,
+  ~ software distributed under the License is distributed on an
+  ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+  ~ KIND, either express or implied.  See the License for the
+  ~ specific language governing permissions and limitations
+  ~ under the License.
+  -->
+<wsdl:definitions xmlns="http://schemas.xmlsoap.org/wsdl/"; 
xmlns:tns="http://ode/test/compile.wsdl"; 
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"; 
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"; 
xmlns:xsd="http://www.w3.org/2001/XMLSchema"; 
xmlns:bpws="http://schemas.xmlsoap.org/ws/2003/03/business-process/"; 
xmlns:plnk="http://schemas.xmlsoap.org/ws/2003/05/partner-link/"; 
xmlns:t1="http://mytest1"; xmlns:t2="http://mytest2"; 
targetNamespace="http://ode/test/compile.wsdl";>
+  <wsdl:types>
+    <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"; 
attributeFormDefault="qualified" elementFormDefault="qualified" 
targetNamespace="http://mytest1";>
+      <xsd:complexType name="MyBean1">
+        <xsd:sequence>
+          <xsd:element minOccurs="0" name="bubble" type="xsd:string"/>
+        </xsd:sequence>
+      </xsd:complexType>
+    </xsd:schema>
+    <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"; 
attributeFormDefault="qualified" elementFormDefault="qualified" 
targetNamespace="http://mytest2";>
+      <xsd:complexType name="MyBean2">
+        <xsd:sequence>
+          <xsd:element minOccurs="0" name="bubble" type="xsd:string"/>
+        </xsd:sequence>
+      </xsd:complexType>
+    </xsd:schema>
+  </wsdl:types>
+  <wsdl:message name="TestMessage">
+    <wsdl:part name="TestPart" type="xsd:string"/>
+    <wsdl:part name="TestPart2" type="t1:MyBean1"/>
+    <wsdl:part name="TestPart3" type="t2:MyBean2"/>
+  </wsdl:message>
+  <wsdl:portType name="TestPortType">
+    <wsdl:operation name="testOperation">
+      <wsdl:input message="tns:TestMessage" name="TestIn"/>
+      <wsdl:output message="tns:TestMessage" name="TestOut"/>
+    </wsdl:operation>
+  </wsdl:portType>
+  <bpws:property name="testProp" type="xsd:string"/>
+</wsdl:definitions>

http://git-wip-us.apache.org/repos/asf/ode/blob/274a89c0/utils/src/main/java/org/apache/ode/utils/xsd/SchemaModelImpl.java
----------------------------------------------------------------------
diff --git a/utils/src/main/java/org/apache/ode/utils/xsd/SchemaModelImpl.java 
b/utils/src/main/java/org/apache/ode/utils/xsd/SchemaModelImpl.java
index eb12d49..6a04057 100644
--- a/utils/src/main/java/org/apache/ode/utils/xsd/SchemaModelImpl.java
+++ b/utils/src/main/java/org/apache/ode/utils/xsd/SchemaModelImpl.java
@@ -193,6 +193,8 @@ public class SchemaModelImpl implements SchemaModel {
                 location = resourceIdentifier.getLiteralSystemId();
             else if (resourceIdentifier.getExpandedSystemId() != null && 
_schemas.get(resourceIdentifier.getExpandedSystemId()) != null)
                 location = resourceIdentifier.getExpandedSystemId();
+            else if (resourceIdentifier.getBaseSystemId() != null && 
_schemas.get(resourceIdentifier.getBaseSystemId()) != null)
+                location = resourceIdentifier.getBaseSystemId();
             else {
                 if (__log.isDebugEnabled()) {
                     __log.debug("Available schemas " + _schemas.keySet());

http://git-wip-us.apache.org/repos/asf/ode/blob/274a89c0/utils/src/main/java/org/apache/ode/utils/xsd/XSUtils.java
----------------------------------------------------------------------
diff --git a/utils/src/main/java/org/apache/ode/utils/xsd/XSUtils.java 
b/utils/src/main/java/org/apache/ode/utils/xsd/XSUtils.java
index 3bec8bc..841bf00 100644
--- a/utils/src/main/java/org/apache/ode/utils/xsd/XSUtils.java
+++ b/utils/src/main/java/org/apache/ode/utils/xsd/XSUtils.java
@@ -58,7 +58,7 @@ public class XSUtils {
      * @return
      */
     public static Map<URI, byte[]> captureSchema(URI systemURI, byte[] 
schemaData,
-                                                 XMLEntityResolver resolver) 
throws XsdException {
+                                                 XMLEntityResolver resolver, 
int localSchemaId) throws XsdException {
         if (__log.isDebugEnabled())
             __log.debug("captureSchema(URI,Text,...): systemURI=" + systemURI);
 
@@ -67,7 +67,9 @@ public class XSUtils {
         input.setByteStream(new ByteArrayInputStream(schemaData));
 
         Map<URI, byte[]> ret = captureSchema(input, resolver);
-        ret.put(systemURI, schemaData);
+        
+        URI localURI = localSchemaId == 0 ? systemURI : 
URI.create(systemURI.toString() + '.' + localSchemaId);
+        ret.put(localURI, schemaData);
         return ret;
     }
 

http://git-wip-us.apache.org/repos/asf/ode/blob/274a89c0/utils/src/test/java/org/apache/ode/utils/xsd/SchemaCaptureTest.java
----------------------------------------------------------------------
diff --git 
a/utils/src/test/java/org/apache/ode/utils/xsd/SchemaCaptureTest.java 
b/utils/src/test/java/org/apache/ode/utils/xsd/SchemaCaptureTest.java
index bdd20d4..be1f953 100644
--- a/utils/src/test/java/org/apache/ode/utils/xsd/SchemaCaptureTest.java
+++ b/utils/src/test/java/org/apache/ode/utils/xsd/SchemaCaptureTest.java
@@ -62,7 +62,7 @@ public class SchemaCaptureTest extends TestCase {
             
             return src;
         }
-    });
+    }, 0);
     // we expect the root schema and three includes
     __log.debug("loaded " + s.keySet());
     assertEquals(5, s.size());

Reply via email to