scheu 02/03/26 14:51:25
Modified: java/src/org/apache/axis/wsdl/toJava SchemaUtils.java
java/test/wsdl/types ComprehensiveTypes.wsdl
Log:
Added processing to support choice syntax underneath complexType. For example:
<xsd:complexType name="foo">
<xsd:choice>
<xsd:element name="one" type="xsd:string"/>
<xsd:element name="two" type="xsd:string" />
<xsd:element name="three" type="xsd:string" />
</xsd:choice>
</xsd:complexType>
This involved simplifying the code in SchemaUtils.
Enjoy.
Revision Changes Path
1.17 +15 -35 xml-axis/java/src/org/apache/axis/wsdl/toJava/SchemaUtils.java
Index: SchemaUtils.java
===================================================================
RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/wsdl/toJava/SchemaUtils.java,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -r1.16 -r1.17
--- SchemaUtils.java 19 Mar 2002 23:29:28 -0000 1.16
+++ SchemaUtils.java 26 Mar 2002 22:51:24 -0000 1.17
@@ -179,46 +179,26 @@
node = extension; // Skip over complexContent and extension
}
- // Under the complexType (or extension) there should be a sequence or
all group node.
+ // Under the complexType there may be choice, sequence, group and/or
all nodes.
// (There may be other #text nodes, which we will ignore).
children = node.getChildNodes();
- Node groupNode = null;
- for (int j = 0; j < children.getLength() && groupNode == null; j++) {
- QName groupKind = Utils.getNodeQName(children.item(j));
- if (groupKind != null &&
- (groupKind.getLocalPart().equals("sequence") ||
- groupKind.getLocalPart().equals("all")) &&
- Constants.isSchemaXSD(groupKind.getNamespaceURI()))
- groupNode = children.item(j);
- }
-
- if (groupNode == null) {
- // didn't find anything
- return new Vector();
- }
-
- if (groupNode != null) {
- // Process each of the choice or element nodes under the
sequence/all node
- Vector v = new Vector();
- NodeList elements = groupNode.getChildNodes();
- for (int i=0; i < elements.getLength(); i++) {
- QName elementKind = Utils.getNodeQName(elements.item(i));
- if (elementKind != null &&
- Constants.isSchemaXSD(elementKind.getNamespaceURI())) {
- if ( elementKind.getLocalPart().equals("element")) {
- ElementDecl elem =
- processChildElementNode(elements.item(i),
- symbolTable);
- if (elem != null)
- v.add(elem);
- } else if (elementKind.getLocalPart().equals("choice")) {
- Vector choiceElems =
processChoiceNode(elements.item(i), symbolTable);
- v.addAll(choiceElems);
- }
+ Vector v = new Vector();
+ for (int j = 0; j < children.getLength(); j++) {
+ QName subNodeKind = Utils.getNodeQName(children.item(j));
+ if (subNodeKind != null &&
+ Constants.isSchemaXSD(subNodeKind.getNamespaceURI())) {
+ if (subNodeKind.getLocalPart().equals("sequence")) {
+ v.addAll(processSequenceNode(children.item(j),
symbolTable));
+ } else if (subNodeKind.getLocalPart().equals("all")) {
+ v.addAll(processAllNode(children.item(j), symbolTable));
+ } else if (subNodeKind.getLocalPart().equals("choice")) {
+ v.addAll(processChoiceNode(children.item(j), symbolTable));
+ } else if (subNodeKind.getLocalPart().equals("group")) {
+ v.addAll(processGroupNode(children.item(j), symbolTable));
}
}
- return v;
}
+ return v;
} else {
// This may be a simpleType, return the type with the name "value"
QName simpleQName = getSimpleTypeBase(node, symbolTable);
1.21 +9 -0 xml-axis/java/test/wsdl/types/ComprehensiveTypes.wsdl
Index: ComprehensiveTypes.wsdl
===================================================================
RCS file: /home/cvs/xml-axis/java/test/wsdl/types/ComprehensiveTypes.wsdl,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -r1.20 -r1.21
--- ComprehensiveTypes.wsdl 20 Mar 2002 20:53:57 -0000 1.20
+++ ComprehensiveTypes.wsdl 26 Mar 2002 22:51:25 -0000 1.21
@@ -62,6 +62,14 @@
</xsd:sequence>
</xsd:complexType>
+ <xsd:complexType name="complexChoice">
+ <xsd:choice>
+ <xsd:element name="choiceA" type="xsd:int"/>
+ <xsd:element name="choiceB" type="xsd:string"/>
+ <xsd:element name="choiceC" type="xsd:string"/>
+ </xsd:choice>
+ </xsd:complexType>
+
<xsd:element name="elemWComplex">
<xsd:complexType>
<xsd:all>
@@ -103,6 +111,7 @@
<xsd:element name="pctchange" type="xsd:string"/>
<xsd:element name="bid" type="xsd:string"/>
<xsd:element name="ask" type="xsd:string"/>
+ <xsd:element name="choice" type="typens:complexChoice"/>
</xsd:sequence>
<xsd:attribute name="last" type="xsd:string"/>
</xsd:complexType>