You are viewing a plain text version of this content. The canonical link for it is here.
Posted to axis-cvs@ws.apache.org by am...@apache.org on 2007/02/07 09:31:00 UTC
svn commit: r504459 - in /webservices/axis2/trunk/java/modules/adb-codegen:
src/org/apache/axis2/schema/ src/org/apache/axis2/schema/template/
test-resources/testsuite/
Author: amilas
Date: Wed Feb 7 00:30:59 2007
New Revision: 504459
URL: http://svn.apache.org/viewvc?view=rev&rev=504459
Log:
Add union support for multi simple type restriction
Modified:
webservices/axis2/trunk/java/modules/adb-codegen/src/org/apache/axis2/schema/SchemaCompiler.java
webservices/axis2/trunk/java/modules/adb-codegen/src/org/apache/axis2/schema/template/ADBBeanTemplate.xsl
webservices/axis2/trunk/java/modules/adb-codegen/test-resources/testsuite/restrictions.xsd
webservices/axis2/trunk/java/modules/adb-codegen/test-resources/testsuite/union.xsd
Modified: webservices/axis2/trunk/java/modules/adb-codegen/src/org/apache/axis2/schema/SchemaCompiler.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/adb-codegen/src/org/apache/axis2/schema/SchemaCompiler.java?view=diff&rev=504459&r1=504458&r2=504459
==============================================================================
--- webservices/axis2/trunk/java/modules/adb-codegen/src/org/apache/axis2/schema/SchemaCompiler.java (original)
+++ webservices/axis2/trunk/java/modules/adb-codegen/src/org/apache/axis2/schema/SchemaCompiler.java Wed Feb 7 00:30:59 2007
@@ -59,7 +59,6 @@
import java.util.Map;
import java.util.Properties;
-
/*
* Copyright 2004,2005 The Apache Software Foundation.
*
@@ -1209,8 +1208,20 @@
metaInfHolder.setAsParent(baseMetaInfoHolder);
} else if (type instanceof XmlSchemaSimpleType) {
- //Do the actual parent setting
- //TODO handle the varios parent types here
+
+ // we have to copy the uion data if the parent simple type restriction
+ // is an union
+ // this union attribute is copied from the child to parent to genrate the parent
+ // code as union
+ if (baseMetaInfoHolder.isUnion()) {
+ metaInfHolder.setUnion(true);
+ Map memberTypes = baseMetaInfoHolder.getMemberTypes();
+ Object qname;
+ for (Iterator iter = memberTypes.keySet().iterator(); iter.hasNext();) {
+ qname = iter.next();
+ metaInfHolder.addMemberType((QName) qname, (String) memberTypes.get(qname));
+ }
+ }
metaInfHolder.setAsParent(baseMetaInfoHolder);
}
@@ -1376,17 +1387,17 @@
String className = findClassName(resBaseType, false);
//this means the schema type actually returns a different QName
- if (baseSchemaTypeMap.containsKey(resBaseType)){
- if (changedTypeMap.containsKey(resBaseType)) {
- metaInfHolder.registerMapping(qName,
- (QName) changedTypeMap.get(resBaseType),
- className, SchemaConstants.ELEMENT_TYPE);
+ if (baseSchemaTypeMap.containsKey(resBaseType)) {
+ if (changedTypeMap.containsKey(resBaseType)) {
+ metaInfHolder.registerMapping(qName,
+ (QName) changedTypeMap.get(resBaseType),
+ className, SchemaConstants.ELEMENT_TYPE);
} else {
metaInfHolder.registerMapping(qName,
resBaseType,
className, SchemaConstants.ELEMENT_TYPE);
}
- } else if (processedTypemap.containsKey(resBaseType)){
+ } else if (processedTypemap.containsKey(resBaseType)) {
//this is not a standared type
// so the parent class must extend it
metaInfHolder.setSimple(true);
Modified: webservices/axis2/trunk/java/modules/adb-codegen/src/org/apache/axis2/schema/template/ADBBeanTemplate.xsl
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/adb-codegen/src/org/apache/axis2/schema/template/ADBBeanTemplate.xsl?view=diff&rev=504459&r1=504458&r2=504459
==============================================================================
--- webservices/axis2/trunk/java/modules/adb-codegen/src/org/apache/axis2/schema/template/ADBBeanTemplate.xsl (original)
+++ webservices/axis2/trunk/java/modules/adb-codegen/src/org/apache/axis2/schema/template/ADBBeanTemplate.xsl Wed Feb 7 00:30:59 2007
@@ -64,7 +64,7 @@
</xsl:if>
public <xsl:if test="not(@unwrapped) or (@skip-write)">static</xsl:if> class <xsl:value-of select="$name"/> <xsl:if test="$extension"> extends <xsl:value-of select="$extension"/></xsl:if> <xsl:if test="$restriction"> extends <xsl:value-of select="$restriction"/></xsl:if>
- <xsl:if test="$union"> extends org.apache.axis2.databinding.types.Union </xsl:if>
+ <xsl:if test="$union and not($restriction) and not($extension)"> extends org.apache.axis2.databinding.types.Union </xsl:if>
implements org.apache.axis2.databinding.ADBBean{
<xsl:choose>
<xsl:when test="@type">/* This type was generated from the piece of schema that had
@@ -534,7 +534,8 @@
</xsl:for-each>
- <xsl:if test="$union and $simple">
+ <!-- we don't need to generate the setObject method in parent classes -->
+ <xsl:if test="$union and $simple and not($restriction) and not($extension)">
<!-- generate class for a union type -->
public void setObject(java.lang.Object object){
Modified: webservices/axis2/trunk/java/modules/adb-codegen/test-resources/testsuite/restrictions.xsd
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/adb-codegen/test-resources/testsuite/restrictions.xsd?view=diff&rev=504459&r1=504458&r2=504459
==============================================================================
--- webservices/axis2/trunk/java/modules/adb-codegen/test-resources/testsuite/restrictions.xsd (original)
+++ webservices/axis2/trunk/java/modules/adb-codegen/test-resources/testsuite/restrictions.xsd Wed Feb 7 00:30:59 2007
@@ -6,18 +6,14 @@
<xsd:simpleType name="NewNormalizedStringType">
<xsd:restriction base="xsd:normalizedString"/>
</xsd:simpleType>
-
<xsd:simpleType name="NormalizedStringType">
<xsd:restriction base="tns:NewNormalizedStringType"/>
</xsd:simpleType>
-
<xsd:complexType name="BusinessObjectDocumentType">
<xsd:attribute name="releaseID" type="tns:NormalizedStringType" use="required"></xsd:attribute>
<xsd:attribute name="versionID" type="tns:NormalizedStringType" use="optional"></xsd:attribute>
</xsd:complexType>
<xsd:element name="SimpleRestriction" type="tns:BusinessObjectDocumentType"/>
-
- <!-- complext type restriction -->
<xsd:complexType name="BaseRestrictionType">
<xsd:sequence>
<xsd:element name="baseTypeElement1" minOccurs="0" type="xsd:string"/>
@@ -34,4 +30,28 @@
</xsd:restriction>
</xsd:complexContent>
</xsd:complexType>
+
+ <xsd:simpleType name="RSuperChildType">
+ <xsd:restriction base="xsd:string"/>
+ </xsd:simpleType>
+ <xsd:simpleType name="ESuperChildType">
+ <xsd:restriction base="xsd:string">
+ <xsd:enumeration value="test1"/>
+ <xsd:enumeration value="test2"/>
+ <xsd:enumeration value="test3"/>
+ </xsd:restriction>
+ </xsd:simpleType>
+
+ <xsd:simpleType name="USuperChildType">
+ <xsd:union memberTypes="xsd:string xsd:int xsd:boolean"/>
+ </xsd:simpleType>
+
+ <xsd:simpleType name="UChildType">
+ <xsd:restriction base = "tns:USuperChildType"/>
+ </xsd:simpleType>
+
+ <xsd:simpleType name="UParentType">
+ <xsd:restriction base="tns:UChildType"/>
+ </xsd:simpleType>
+
</xsd:schema>
Modified: webservices/axis2/trunk/java/modules/adb-codegen/test-resources/testsuite/union.xsd
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/adb-codegen/test-resources/testsuite/union.xsd?view=diff&rev=504459&r1=504458&r2=504459
==============================================================================
--- webservices/axis2/trunk/java/modules/adb-codegen/test-resources/testsuite/union.xsd (original)
+++ webservices/axis2/trunk/java/modules/adb-codegen/test-resources/testsuite/union.xsd Wed Feb 7 00:30:59 2007
@@ -35,4 +35,5 @@
</s:sequence>
</s:complexType>
</s:element>
+
</s:schema>
---------------------------------------------------------------------
To unsubscribe, e-mail: axis-cvs-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-cvs-help@ws.apache.org