You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by di...@apache.org on 2003/10/27 02:52:50 UTC
cvs commit: ws-axis/java/src/org/apache/axis/wsdl/symbolTable SchemaUtils.java SymbolTable.java Utils.java
dims 2003/10/26 17:52:50
Modified: java/src/org/apache/axis Constants.java
java/src/org/apache/axis/wsdl/toJava JavaStubWriter.java
java/src/org/apache/axis/wsdl/gen Parser.java
java/src/org/apache/axis/wsdl/symbolTable SchemaUtils.java
SymbolTable.java Utils.java
Log:
Fix for Bug 23145 - WSDL2Java appears to ignore attributegroups in serialization
from kbrichan@comcast.net (Brook Richan)
Revision Changes Path
1.125 +4 -0 ws-axis/java/src/org/apache/axis/Constants.java
Index: Constants.java
===================================================================
RCS file: /home/cvs/ws-axis/java/src/org/apache/axis/Constants.java,v
retrieving revision 1.124
retrieving revision 1.125
diff -u -r1.124 -r1.125
--- Constants.java 16 Oct 2003 13:53:37 -0000 1.124
+++ Constants.java 27 Oct 2003 01:52:49 -0000 1.125
@@ -613,6 +613,10 @@
public static final QName SOAP_INTEGER = new QName(URI_DEFAULT_SOAP_ENC, "integer");
public static final QName SOAP_DECIMAL = new QName(URI_DEFAULT_SOAP_ENC, "decimal");
public static final QName SOAP_ARRAY = new QName(URI_DEFAULT_SOAP_ENC, "Array");
+ public static final QName SOAP_COMMON_ATTRS11 = new QName(URI_SOAP11_ENC, "commonAttributes");
+ public static final QName SOAP_COMMON_ATTRS12 = new QName(URI_SOAP12_ENC, "commonAttributes");
+ public static final QName SOAP_ARRAY_ATTRS11 = new QName(URI_SOAP11_ENC, "arrayAttributes");
+ public static final QName SOAP_ARRAY_ATTRS12 = new QName(URI_SOAP12_ENC, "arrayAttributes");
public static final QName SOAP_ARRAY12 = new QName(URI_SOAP12_ENC, "Array");
public static final QName SOAP_MAP = new QName(NS_URI_XMLSOAP, "Map");
1.119 +4 -2 ws-axis/java/src/org/apache/axis/wsdl/toJava/JavaStubWriter.java
Index: JavaStubWriter.java
===================================================================
RCS file: /home/cvs/ws-axis/java/src/org/apache/axis/wsdl/toJava/JavaStubWriter.java,v
retrieving revision 1.118
retrieving revision 1.119
diff -u -r1.118 -r1.119
--- JavaStubWriter.java 24 Oct 2003 21:06:30 -0000 1.118
+++ JavaStubWriter.java 27 Oct 2003 01:52:49 -0000 1.119
@@ -199,7 +199,7 @@
TypeEntry type = (TypeEntry) it.next();
// Note this same check is repeated in JavaDeployWriter.
- // 1) Don't register types that are base (primitive) types.
+ // 1) Don't register types that are base (primitive) types or attributeGroups.
// If the baseType != null && getRefType() != null this
// is a simpleType that must be registered.
// 2) Don't register the special types for collections
@@ -210,7 +210,9 @@
type instanceof CollectionTE ||
type instanceof Element ||
!type.isReferenced() ||
- type.isOnlyLiteralReferenced()) {
+ type.isOnlyLiteralReferenced() ||
+ (type.getNode() != null &&
+ type.getNode().getLocalName().equals("attributeGroup"))) {
continue;
}
1.17 +2 -1 ws-axis/java/src/org/apache/axis/wsdl/gen/Parser.java
Index: Parser.java
===================================================================
RCS file: /home/cvs/ws-axis/java/src/org/apache/axis/wsdl/gen/Parser.java,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -r1.16 -r1.17
--- Parser.java 22 Apr 2003 19:36:12 -0000 1.16
+++ Parser.java 27 Oct 2003 01:52:50 -0000 1.17
@@ -348,7 +348,7 @@
// Write out the type if and only if:
// - we found its definition (getNode())
// - it is referenced
- // - it is not a base type
+ // - it is not a base type or an attributeGroup
// - it is a Type (not an Element) or a CollectionElement
// (Note that types that are arrays are passed to getGenerator
// because they may require a Holder)
@@ -357,6 +357,7 @@
boolean isType = (type instanceof Type ||
type instanceof CollectionElement);
if (type.getNode() != null &&
+ ! type.getNode().getLocalName().equals("attributeGroup") &&
type.isReferenced() &&
isType &&
type.getBaseType() == null) {
1.27 +145 -44 ws-axis/java/src/org/apache/axis/wsdl/symbolTable/SchemaUtils.java
Index: SchemaUtils.java
===================================================================
RCS file: /home/cvs/ws-axis/java/src/org/apache/axis/wsdl/symbolTable/SchemaUtils.java,v
retrieving revision 1.26
retrieving revision 1.27
diff -u -r1.26 -r1.27
--- SchemaUtils.java 11 Aug 2003 21:25:28 -0000 1.26
+++ SchemaUtils.java 27 Oct 2003 01:52:50 -0000 1.27
@@ -969,8 +969,142 @@
}
/**
+ * adds an attribute node's type and name to the vector
+ * helper used by getContainedAttributeTypes
+ */
+ private static void addAttributeToVector(Vector v, Node child, SymbolTable symbolTable)
+ {
+ // Get the name and type qnames.
+ // The type qname is used to locate the TypeEntry, which is then
+ // used to retrieve the proper java name of the type.
+ QName attributeName = Utils.getNodeNameQName(child);
+ BooleanHolder forElement = new BooleanHolder();
+ QName attributeType = Utils.getTypeQName(child, forElement, false);
+
+ // An attribute is either qualified or unqualified.
+ // If the ref= attribute is used, the name of the ref'd element is used
+ // (which must be a root element). If the ref= attribute is not
+ // used, the name of the attribute is unqualified.
+ if (!forElement.value) {
+ // check the Form (or attributeFormDefault) attribute of
+ // this node to determine if it should be namespace
+ // quailfied or not.
+ String form = Utils.getAttribute(child, "form");
+ if (form != null && form.equals("unqualified")) {
+ // Unqualified nodeName
+ attributeName = Utils.findQName("", attributeName.getLocalPart());
+ } else if (form == null) {
+ // check attributeFormDefault on schema element
+ String def = Utils.getScopedAttribute(child,
+ "attributeFormDefault");
+ if (def == null || def.equals("unqualified")) {
+ // Unqualified nodeName
+ attributeName = Utils.findQName("", attributeName.getLocalPart());
+ }
+ }
+ } else {
+ attributeName = attributeType;
+ }
+
+ // Get the corresponding TypeEntry from the symbol table
+ TypeEntry type = symbolTable.getTypeEntry(attributeType,
+ forElement.value);
+
+ // add type and name to vector, skip it if we couldn't parse it
+ // XXX - this may need to be revisited.
+ if (type != null && attributeName != null) {
+ v.add(type);
+ v.add(attributeName);
+ }
+ }
+
+ /**
+ * adds an attribute to the vector
+ * helper used by addAttributeGroupToVector
+ */
+ private static void addAttributeToVector(Vector v, SymbolTable symbolTable,
+ QName type, QName name)
+ {
+ TypeEntry typeEnt = symbolTable.getTypeEntry(type, false);
+ if (typeEnt != null) // better not be null
+ {
+ v.add(typeEnt);
+ v.add(name);
+ }
+ }
+
+ /**
+ * adds each attribute group's attribute node to the vector
+ * helper used by getContainedAttributeTypes
+ */
+ private static void addAttributeGroupToVector(Vector v, Node attrGrpnode, SymbolTable symbolTable)
+ {
+ // get the type of the attributeGroup
+ QName attributeGroupType = Utils.getTypeQName(attrGrpnode, new BooleanHolder(), false);
+ TypeEntry type = symbolTable.getTypeEntry(attributeGroupType, false);
+ if (type != null)
+ {
+ if (type.getNode() != null)
+ {
+ // for each attribute or attributeGroup defined in the attributeGroup...
+ NodeList children = type.getNode().getChildNodes();
+ for (int j = 0; j < children.getLength(); j++) {
+ Node kid = children.item(j);
+ if (isXSDNode(kid, "attribute")) {
+ addAttributeToVector(v, kid, symbolTable);
+ }
+ else if (isXSDNode(kid, "attributeGroup")) {
+ addAttributeGroupToVector(v, kid, symbolTable);
+ }
+ }
+ }
+ else if (type.isBaseType())
+ {
+ // soap/encoding is treated as a "known" schema
+ // so let's act like we know it
+ if (type.getQName().equals(Constants.SOAP_COMMON_ATTRS11))
+ {
+ // 1.1 commonAttributes contains two attributes
+ addAttributeToVector(v, symbolTable,
+ Constants.XSD_ID, new QName(Constants.URI_SOAP11_ENC, "id"));
+ addAttributeToVector(v, symbolTable,
+ Constants.XSD_ANYURI, new QName(Constants.URI_SOAP11_ENC, "href"));
+ }
+ else if (type.getQName().equals(Constants.SOAP_COMMON_ATTRS12))
+ {
+ // 1.2 commonAttributes contains one attribute
+ addAttributeToVector(v, symbolTable,
+ Constants.XSD_ID, new QName(Constants.URI_SOAP12_ENC, "id"));
+ }
+ else if (type.getQName().equals(Constants.SOAP_ARRAY_ATTRS11))
+ {
+ // 1.1 arrayAttributes contains two attributes
+ addAttributeToVector(v, symbolTable,
+ Constants.XSD_STRING, new QName(Constants.URI_SOAP12_ENC, "arrayType"));
+ addAttributeToVector(v, symbolTable,
+ Constants.XSD_STRING, new QName(Constants.URI_SOAP12_ENC, "offset"));
+ }
+ else if (type.getQName().equals(Constants.SOAP_ARRAY_ATTRS12))
+ {
+ // 1.2 arrayAttributes contains two attributes
+ // the type of "arraySize" is really "2003soapenc:arraySize"
+ // which is rather of a hairy beast that is not yet supported
+ // in Axis, so let's just use string; nobody should care for
+ // now because arraySize wasn't used at all up until this
+ // bug 23145 was fixed, which had nothing to do, per se, with
+ // adding support for arraySize
+ addAttributeToVector(v, symbolTable,
+ Constants.XSD_STRING, new QName(Constants.URI_SOAP12_ENC, "arraySize"));
+ addAttributeToVector(v, symbolTable,
+ Constants.XSD_QNAME, new QName(Constants.URI_SOAP12_ENC, "itemType"));
+ }
+ }
+ }
+ }
+
+ /**
* Return the attribute names and types if any in the node
- * The even indices are the element types (TypeEntry) and
+ * The even indices are the attribute types (TypeEntry) and
* the odd indices are the corresponding names (Strings).
*
* Example:
@@ -981,6 +1115,7 @@
* </sequence>
* <attribute name="Name" type="string" />
* <attribute name="Male" type="boolean" />
+ * <attributeGroup ref="s0:MyAttrSet" />
* </complexType>
*
*/
@@ -1034,56 +1169,22 @@
children = node.getChildNodes();
for (int i = 0; i < children.getLength(); i++) {
Node child = children.item(i);
- if (! isXSDNode(child, "attribute")) {
+ if (! isXSDNode(child, "attribute") && ! isXSDNode(child, "attributeGroup")) {
continue;
}
-
- // we have an attribute node
+
+ // we have an attribute or attributeGroup node
if (v == null)
v = new Vector();
- // Get the name and type qnames.
- // The type qname is used to locate the TypeEntry, which is then
- // used to retrieve the proper java name of the type.
- QName attributeName = Utils.getNodeNameQName(child);
- BooleanHolder forElement = new BooleanHolder();
- QName attributeType = Utils.getTypeQName(child, forElement, false);
-
- // An attribute is either qualified or unqualified.
- // If the ref= attribute is used, the name of the ref'd element is used
- // (which must be a root element). If the ref= attribute is not
- // used, the name of the attribute is unqualified.
- if (!forElement.value) {
- // check the Form (or attributeFormDefault) attribute of
- // this node to determine if it should be namespace
- // quailfied or not.
- String form = Utils.getAttribute(child, "form");
- if (form != null && form.equals("unqualified")) {
- // Unqualified nodeName
- attributeName = Utils.findQName("", attributeName.getLocalPart());
- } else if (form == null) {
- // check attributeFormDefault on schema element
- String def = Utils.getScopedAttribute(child,
- "attributeFormDefault");
- if (def == null || def.equals("unqualified")) {
- // Unqualified nodeName
- attributeName = Utils.findQName("", attributeName.getLocalPart());
- }
- }
- } else {
- attributeName = attributeType;
+ if (isXSDNode(child, "attributeGroup")) {
+ addAttributeGroupToVector(v, child, symbolTable);
}
-
- // Get the corresponding TypeEntry from the symbol table
- TypeEntry type = symbolTable.getTypeEntry(attributeType,
- forElement.value);
-
- // add type and name to vector, skip it if we couldn't parse it
- // XXX - this may need to be revisited.
- if (type != null && attributeName != null) {
- v.add(type);
- v.add(attributeName);
+ else {
+ // we have an attribute
+ addAttributeToVector(v, child, symbolTable);
}
+
}
}
return v;
1.77 +59 -1 ws-axis/java/src/org/apache/axis/wsdl/symbolTable/SymbolTable.java
Index: SymbolTable.java
===================================================================
RCS file: /home/cvs/ws-axis/java/src/org/apache/axis/wsdl/symbolTable/SymbolTable.java,v
retrieving revision 1.76
retrieving revision 1.77
diff -u -r1.76 -r1.77
--- SymbolTable.java 9 Jul 2003 18:36:59 -0000 1.76
+++ SymbolTable.java 27 Oct 2003 01:52:50 -0000 1.77
@@ -691,7 +691,7 @@
/**
* Utility method which walks the Document and creates Type objects for
- * each complexType, simpleType, or element referenced or defined.
+ * each complexType, simpleType, attributeGroup or element referenced or defined.
*
* What goes into the symbol table? In general, only the top-level types
* (ie., those just below
@@ -747,6 +747,14 @@
// and element=.
createTypeFromDef(node, true, level > SCHEMA_LEVEL);
}
+ else if (isXSD && localPart.equals("attributeGroup")) {
+ // bug 23145: support attributeGroup (Brook Richan)
+ // Create a type entry for the referenced type
+ createTypeFromRef(node);
+
+ // Create a type representing an attributeGroup.
+ createTypeFromDef(node, false, level > SCHEMA_LEVEL);
+ }
else if (isXSD && localPart.equals("attribute")) {
// Create a type entry for the referenced type
BooleanHolder forElement = new BooleanHolder();
@@ -1006,6 +1014,56 @@
String baseName = btm.getBaseName(qName);
if (baseName != null)
symbolTablePut(new BaseType(qName));
+
+ // bugzilla 23145: handle attribute groups
+ // soap/encoding is treated as a "known" schema
+ // so now let's act like we know it
+ else if (qName.equals(Constants.SOAP_COMMON_ATTRS11))
+ {
+ symbolTablePut(new BaseType(qName));
+ // the 1.1 commonAttributes type contains two attributes
+ // make sure those attributes' types are in the symbol table
+ // attribute name = "id" type = "xsd:ID"
+ if (getTypeEntry(Constants.XSD_ID, false) == null)
+ symbolTablePut(new BaseType(Constants.XSD_ID));
+ // attribute name = "href" type = "xsd:anyURI"
+ if (getTypeEntry(Constants.XSD_ANYURI, false) == null)
+ symbolTablePut(new BaseType(Constants.XSD_ANYURI));
+ }
+ else if (qName.equals(Constants.SOAP_COMMON_ATTRS12))
+ {
+ symbolTablePut(new BaseType(qName));
+ // the 1.2 commonAttributes type contains one attribute
+ // make sure the attribute's type is in the symbol table
+ // attribute name = "id" type = "xsd:ID"
+ if (getTypeEntry(Constants.XSD_ID, false) == null)
+ symbolTablePut(new BaseType(Constants.XSD_ID));
+ }
+ else if (qName.equals(Constants.SOAP_ARRAY_ATTRS11))
+ {
+ symbolTablePut(new BaseType(qName));
+ // the 1.1 arrayAttributes type contains two attributes
+ // make sure the attributes' types are in the symbol table
+ // attribute name = "arrayType" type = "xsd:string"
+ if (getTypeEntry(Constants.XSD_STRING, false) == null)
+ symbolTablePut(new BaseType(Constants.XSD_STRING));
+ // attribute name = "offset" type = "soapenc:arrayCoordinate"
+ // which is really an xsd:string
+ }
+ else if (qName.equals(Constants.SOAP_ARRAY_ATTRS12))
+ {
+ symbolTablePut(new BaseType(qName));
+ // the 1.2 arrayAttributes type contains two attributes
+ // make sure the attributes' types are in the symbol table
+ // attribute name = "arraySize" type = "2003soapenc:arraySize"
+ // which is really a hairy beast that is not
+ // supported, yet; so let's just use string
+ if (getTypeEntry(Constants.XSD_STRING, false) == null)
+ symbolTablePut(new BaseType(Constants.XSD_STRING));
+ // attribute name = "itemType" type = "xsd:QName"
+ if (getTypeEntry(Constants.XSD_QNAME, false) == null)
+ symbolTablePut(new BaseType(Constants.XSD_QNAME));
+ }
else if (forElement.value == false)
symbolTablePut(new UndefinedType(qName));
else
1.29 +6 -2 ws-axis/java/src/org/apache/axis/wsdl/symbolTable/Utils.java
Index: Utils.java
===================================================================
RCS file: /home/cvs/ws-axis/java/src/org/apache/axis/wsdl/symbolTable/Utils.java,v
retrieving revision 1.28
retrieving revision 1.29
diff -u -r1.28 -r1.29
--- Utils.java 18 Jun 2003 23:01:52 -0000 1.28
+++ Utils.java 27 Oct 2003 01:52:50 -0000 1.29
@@ -288,7 +288,7 @@
* An XML element or attribute node has several ways of
* identifying the type of the element or attribute:
* - use the type attribute to reference a complexType/simpleType
- * - use the ref attribute to reference another element
+ * - use the ref attribute to reference another element or attributeGroup
* - use of an anonymous type (i.e. a nested type underneath itself)
* - a wsdl:part can use the element attribute.
* - an extension can use the base attribute.
@@ -319,7 +319,11 @@
// If not successful, try using the ref attribute.
if (qName == null) {
- forElement.value = true;
+ QName nodeKind = getNodeQName(node);
+ // bug 23145: support attributeGroup (Brook Richan)
+ // a ref can be for an element or attributeGroup
+ if (nodeKind != null && !nodeKind.getLocalPart().equals("attributeGroup"))
+ forElement.value = true;
qName = getTypeQNameFromAttr(node, "ref");
}