You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jaxme-dev@ws.apache.org by jo...@apache.org on 2004/09/29 10:41:02 UTC
cvs commit: ws-jaxme/src/jaxme/org/apache/ws/jaxme/generator/sg/impl JAXBTypeSG.java
jochen 2004/09/29 01:41:02
Modified: src/test/jaxb enumeration.xsd
. status.xml
src/jaxme/org/apache/ws/jaxme/generator/sg/impl
JAXBTypeSG.java
Log:
An attribute with an enumeration required setting the "package" property. See JAXME-37 in Jira.
Revision Changes Path
1.3 +29 -0 ws-jaxme/src/test/jaxb/enumeration.xsd
Index: enumeration.xsd
===================================================================
RCS file: /home/cvs/ws-jaxme/src/test/jaxb/enumeration.xsd,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- enumeration.xsd 23 Jul 2004 07:17:57 -0000 1.2
+++ enumeration.xsd 29 Sep 2004 08:41:02 -0000 1.3
@@ -232,4 +232,33 @@
</xs:sequence>
</xs:complexType>
</xs:element>
+
+ <xs:element name="LocalEnumAttribute">
+ <xs:complexType>
+ <xs:attribute name="stringAttr">
+ <xs:simpleType>
+ <xs:restriction base="xs:string">
+ <xs:enumeration value="a"/>
+ <xs:enumeration value="b"/>
+ </xs:restriction>
+ </xs:simpleType>
+ </xs:attribute>
+ <xs:attribute name="intAttr">
+ <xs:simpleType>
+ <xs:restriction base="xs:int">
+ <xs:enumeration value="0"/>
+ <xs:enumeration value="1"/>
+ </xs:restriction>
+ </xs:simpleType>
+ </xs:attribute>
+ <xs:attribute name="doubleAttr">
+ <xs:simpleType>
+ <xs:restriction base="xs:double">
+ <xs:enumeration value="0.0"/>
+ <xs:enumeration value="1.0"/>
+ </xs:restriction>
+ </xs:simpleType>
+ </xs:attribute>
+ </xs:complexType>
+ </xs:element>
</xs:schema>
1.34 +4 -0 ws-jaxme/status.xml
Index: status.xml
===================================================================
RCS file: /home/cvs/ws-jaxme/status.xml,v
retrieving revision 1.33
retrieving revision 1.34
diff -u -r1.33 -r1.34
--- status.xml 23 Sep 2004 22:58:45 -0000 1.33
+++ status.xml 29 Sep 2004 08:41:02 -0000 1.34
@@ -64,6 +64,10 @@
is now exposed as content type "mixed", and not "empty".
(Mik Lernout, mik at futurestreet.org)
</action>
+ <action dev="JW" type="fix" context="generator">
+ An attribute with an enumeration required setting the
+ "package" property. See JAXME-37 in Jira.
+ </action>
</release>
<release version="0.3.1" date="2004-Sep-03">
<action dev="JW" type="fix" context="generator">
1.9 +37 -14 ws-jaxme/src/jaxme/org/apache/ws/jaxme/generator/sg/impl/JAXBTypeSG.java
Index: JAXBTypeSG.java
===================================================================
RCS file: /home/cvs/ws-jaxme/src/jaxme/org/apache/ws/jaxme/generator/sg/impl/JAXBTypeSG.java,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- JAXBTypeSG.java 20 Aug 2004 23:43:24 -0000 1.8
+++ JAXBTypeSG.java 29 Sep 2004 08:41:02 -0000 1.9
@@ -60,9 +60,7 @@
import org.apache.ws.jaxme.js.JavaSource;
import org.apache.ws.jaxme.logging.Logger;
import org.apache.ws.jaxme.logging.LoggerAccess;
-import org.apache.ws.jaxme.xs.XSElement;
import org.apache.ws.jaxme.xs.XSEnumeration;
-import org.apache.ws.jaxme.xs.XSParticle;
import org.apache.ws.jaxme.xs.XSSchema;
import org.apache.ws.jaxme.xs.XSSimpleType;
import org.apache.ws.jaxme.xs.XSType;
@@ -119,6 +117,7 @@
import org.apache.ws.jaxme.xs.xml.XsSchemaHeader;
import org.xml.sax.Locator;
import org.xml.sax.SAXException;
+import org.xml.sax.SAXParseException;
/**
* @author <a href="mailto:joe@ispsoft.de">Jochen Wiedmann</a>
@@ -149,6 +148,23 @@
isGlobalClass = true;
}
+ private TypeSG getReferencedType(SGFactory pFactory, Context pClassContext,
+ XSType pReferencingType, XSType pReferencedType)
+ throws SAXException {
+ XsQName name = pReferencedType.getName();
+ TypeSG result;
+ if (pReferencedType.isGlobal()) {
+ result = pFactory.getTypeSG(pReferencedType);
+ if (result == null) {
+ throw new SAXParseException("Unknown global type " + name,
+ pReferencingType.getLocator());
+ }
+ } else {
+ throw new IllegalStateException("A referenced type must be global.");
+ }
+ return result;
+ }
+
/** <p>Creates a new, local instance of JAXBTypeSG. Classes are generated
* into the given context.</p>
*/
@@ -160,20 +176,17 @@
if (pType.isSimple()) {
if (pType.getSimpleType().isRestriction()) {
XSType restrictedXsType = pType.getSimpleType().getRestrictedType();
- if (restrictedXsType.equals(pType)) {
- throw new IllegalStateException("Invalid restriction (equals this): " + pType);
- }
- restrictedType = pFactory.getTypeSG(restrictedXsType, pClassContext, restrictedXsType.getName());
+ restrictedType = getReferencedType(pFactory, pClassContext, pType, restrictedXsType);
extendedType = null;
} else {
restrictedType = extendedType = null;
}
} else {
if (pType.getComplexType().isRestriction()) {
- restrictedType = pFactory.getTypeSG(pType.getComplexType().getRestrictedType(), pClassContext, pName);
+ restrictedType = getReferencedType(pFactory, pClassContext, pType, pType.getComplexType().getRestrictedType());
extendedType = null;
} else if (pType.getComplexType().isExtension()) {
- extendedType = pFactory.getTypeSG(pType.getComplexType().getExtendedType(), pClassContext, pName);
+ extendedType = getReferencedType(pFactory, pClassContext, pType, pType.getComplexType().getExtendedType());
restrictedType = null;
} else {
restrictedType = extendedType = null;
@@ -448,14 +461,13 @@
}
}
- SimpleTypeSGChain result = newSimpleTypeSG(pController, pFactory, pSchema, simpleType.getRestrictedType());
+ SimpleTypeSGChain result = newSimpleTypeSG(pController, pFactory, pSchema, simpleType.getRestrictedType());
result = new SimpleTypeRestrictionSG(result, pType, simpleType);
if (simpleType.getEnumerations().length > 0) {
boolean generateTypesafeEnumClass = false;
String className = null;
- String packageName = null;
if (simpleType instanceof JAXBSimpleType) {
JAXBSimpleType jaxbSimpleType = (JAXBSimpleType) simpleType;
@@ -513,9 +525,6 @@
} else {
jaxbSchemaBindings = null;
}
- packageName = AbstractContext.getPackageName(pSchema, jaxbSchemaBindings,
- pController.getLocator(),
- pController.getName());
if (generateTypesafeEnumClass) {
if (className == null) {
@@ -524,7 +533,21 @@
qName.getLocalName(),
pSchema) + "Class";
}
- result = new EnumerationSG(result, JavaQNameImpl.getInstance(packageName, className), pType);
+ JavaQName qName;
+ if (classContext == null) {
+ String packageName = AbstractContext.getPackageName(pSchema,
+ jaxbSchemaBindings,
+ pController.getLocator(),
+ pController.getName());
+ qName = JavaQNameImpl.getInstance(packageName, className);
+ } else {
+ JavaQName elementClassName = classContext.getXMLInterfaceName();
+ if (elementClassName == null) {
+ elementClassName = classContext.getXMLImplementationName();
+ }
+ qName = JavaQNameImpl.getInstance(elementClassName.getPackageName(), className);
+ }
+ result = new EnumerationSG(result, qName, pType);
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: jaxme-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: jaxme-dev-help@ws.apache.org