Author: jochen Date: Tue Oct 10 01:35:33 2006 New Revision: 454664 URL: http://svn.apache.org/viewvc?view=rev&rev=454664 Log: Fixed handling of recursive extensions, as reported by Brian Uri.
Added: webservices/jaxme/branches/MAVEN/projects/jm/src/test/resources/jira/jaxme-83.xsd webservices/jaxme/branches/MAVEN/projects/jm/src/test/resources/jira/jaxme-84.xsd webservices/jaxme/branches/b0_5/src/test/jaxb/jira/jaxme-83.xsd Modified: webservices/jaxme/branches/MAVEN/projects/jm/maven.xml webservices/jaxme/branches/MAVEN/projects/jm/src/test/java/org/apache/ws/jaxme/junit/BindingsTest.java webservices/jaxme/branches/MAVEN/projects/jm/src/test/resources/bindings/bindings.jxb webservices/jaxme/branches/MAVEN/projects/jm/src/test/resources/bindings/bindings.xsd webservices/jaxme/branches/b0_5/src/xs/org/apache/ws/jaxme/xs/XSComplexType.java webservices/jaxme/branches/b0_5/src/xs/org/apache/ws/jaxme/xs/impl/XSTypeImpl.java webservices/jaxme/branches/b0_5/src/xs/org/apache/ws/jaxme/xs/junit/ParserTest.java webservices/jaxme/branches/b0_5/src/xs/org/apache/ws/jaxme/xs/junit/ParserTestBase.java webservices/jaxme/branches/b0_5/status.xml Modified: webservices/jaxme/branches/MAVEN/projects/jm/maven.xml URL: http://svn.apache.org/viewvc/webservices/jaxme/branches/MAVEN/projects/jm/maven.xml?view=diff&rev=454664&r1=454663&r2=454664 ============================================================================== --- webservices/jaxme/branches/MAVEN/projects/jm/maven.xml (original) +++ webservices/jaxme/branches/MAVEN/projects/jm/maven.xml Tue Oct 10 01:35:33 2006 @@ -135,6 +135,11 @@ <ant:produces dir="${maven.test.dest}" includes="org/apache/ws/jaxme/test/misc/enumeration/*"/> <ant:produces dir="${maven.test.dest}" includes="org/apache/ws/jaxme/test/misc/wildcards/*"/> </ant:xjc> + <ant:xjc target="${maven.test.dest}"> + <ant:schema dir="${maven.test.dest}/bindings" includes="*.xsd"/> + <ant:binding dir="${maven.test.dest}/bindings" includes="*.jxb"/> + <ant:produces dir="${maven.test.dest}" includes="org/apache/ws/jaxme/test/bindings/**/*"/> + </ant:xjc> <ant:path id="generated.test.src" location="${maven.test.dest}"/> Modified: webservices/jaxme/branches/MAVEN/projects/jm/src/test/java/org/apache/ws/jaxme/junit/BindingsTest.java URL: http://svn.apache.org/viewvc/webservices/jaxme/branches/MAVEN/projects/jm/src/test/java/org/apache/ws/jaxme/junit/BindingsTest.java?view=diff&rev=454664&r1=454663&r2=454664 ============================================================================== --- webservices/jaxme/branches/MAVEN/projects/jm/src/test/java/org/apache/ws/jaxme/junit/BindingsTest.java (original) +++ webservices/jaxme/branches/MAVEN/projects/jm/src/test/java/org/apache/ws/jaxme/junit/BindingsTest.java Tue Oct 10 01:35:33 2006 @@ -39,13 +39,13 @@ */ public void testBindingGenerator() throws Exception { Generator g = new GeneratorImpl(); - g.setTargetDirectory(new File("build/tests/binding/src")); - g.setResourceTargetDirectory(new File("build/tests/binding/src")); - g.addBindings(new InputSource(new File("src/test/jaxb/bindings/bindings.jxb").toURI().toURL().toExternalForm())); + g.setTargetDirectory(new File("target/tests/binding/src")); + g.setResourceTargetDirectory(new File("target/tests/binding/src")); + g.addBindings(new InputSource(new File("src/test/resources/bindings/bindings.jxb").toURI().toURL().toExternalForm())); SchemaReader sr = new JAXBSchemaReader(); sr.setGenerator(g); g.setSchemaReader(sr); - g.generate(new File("src/test/jaxb/bindings/bindings.xsd")); + g.generate(new File("src/test/resources/bindings/bindings.xsd")); } /** Modified: webservices/jaxme/branches/MAVEN/projects/jm/src/test/resources/bindings/bindings.jxb URL: http://svn.apache.org/viewvc/webservices/jaxme/branches/MAVEN/projects/jm/src/test/resources/bindings/bindings.jxb?view=diff&rev=454664&r1=454663&r2=454664 ============================================================================== --- webservices/jaxme/branches/MAVEN/projects/jm/src/test/resources/bindings/bindings.jxb (original) +++ webservices/jaxme/branches/MAVEN/projects/jm/src/test/resources/bindings/bindings.jxb Tue Oct 10 01:35:33 2006 @@ -25,6 +25,13 @@ <jxb:bindings node="xs:[EMAIL PROTECTED]'YesNoType']"> <jxb:typesafeEnumClass/> </jxb:bindings> + <jxb:bindings node="xs:[EMAIL PROTECTED]'foo']/xs:complexType/xs:[EMAIL PROTECTED]'bool']"> + <jxb:property> + <jxb:baseType> + <jxb:javaType name='java.lang.Boolean'/> + </jxb:baseType> + </jxb:property> + </jxb:bindings> </jxb:bindings> <jxb:bindings schemaLocation="imported.xsi" node="/xs:schema"> Modified: webservices/jaxme/branches/MAVEN/projects/jm/src/test/resources/bindings/bindings.xsd URL: http://svn.apache.org/viewvc/webservices/jaxme/branches/MAVEN/projects/jm/src/test/resources/bindings/bindings.xsd?view=diff&rev=454664&r1=454663&r2=454664 ============================================================================== --- webservices/jaxme/branches/MAVEN/projects/jm/src/test/resources/bindings/bindings.xsd (original) +++ webservices/jaxme/branches/MAVEN/projects/jm/src/test/resources/bindings/bindings.xsd Tue Oct 10 01:35:33 2006 @@ -30,6 +30,7 @@ </xs:sequence> <xs:attribute name="bar" type="bnd:YesNoType"/> <xs:attribute name="blabb" type="imp:YesNoType"/> + <xs:attribute name="bool" type="xs:boolean"/> </xs:complexType> </xs:element> Added: webservices/jaxme/branches/MAVEN/projects/jm/src/test/resources/jira/jaxme-83.xsd URL: http://svn.apache.org/viewvc/webservices/jaxme/branches/MAVEN/projects/jm/src/test/resources/jira/jaxme-83.xsd?view=auto&rev=454664 ============================================================================== --- webservices/jaxme/branches/MAVEN/projects/jm/src/test/resources/jira/jaxme-83.xsd (added) +++ webservices/jaxme/branches/MAVEN/projects/jm/src/test/resources/jira/jaxme-83.xsd Tue Oct 10 01:35:33 2006 @@ -0,0 +1,19 @@ +<xs:schema + xmlns:xs="http://www.w3.org/2001/XMLSchema" + xmlns="http://ws.apache.org/jaxme/test/jira/elementref" + targetNamespace="http://ws.apache.org/jaxme/test/jira/elementref" + elementFormDefault="qualified"> + <xs:element name="Dcr"> + <xs:complexType> + <xs:attribute name="id"/> + </xs:complexType> + </xs:element> + + <xs:element name="DcrLoadResult"> + <xs:complexType> + <xs:sequence> + <xs:element ref="Dcr"/> + </xs:sequence> + </xs:complexType> + </xs:element> +</xs:schema> Added: webservices/jaxme/branches/MAVEN/projects/jm/src/test/resources/jira/jaxme-84.xsd URL: http://svn.apache.org/viewvc/webservices/jaxme/branches/MAVEN/projects/jm/src/test/resources/jira/jaxme-84.xsd?view=auto&rev=454664 ============================================================================== --- webservices/jaxme/branches/MAVEN/projects/jm/src/test/resources/jira/jaxme-84.xsd (added) +++ webservices/jaxme/branches/MAVEN/projects/jm/src/test/resources/jira/jaxme-84.xsd Tue Oct 10 01:35:33 2006 @@ -0,0 +1,32 @@ +<xs:schema + xmlns:xs="http://www.w3.org/2001/XMLSchema" + targetNamespace="http://namespaces.softwareag.com/de/s/xDWS/soap-api" + xmlns:xdws="http://namespaces.softwareag.com/de/s/xDWS/soap-api" + elementFormDefault="qualified" + attributeFormDefault="unqualified"> + <xs:complexType name="xdwsResultInfo"> + <xs:attribute name="rc" type="xs:int" use="required"/> + <xs:attribute name="message" type="xs:string" use="optional"/> + <xs:attribute name="details" type="xs:string" use="optional"/> + </xs:complexType> + <xs:element name="xdwsResponse"> + <xs:complexType> + <xs:sequence> + <xs:element name="response" minOccurs="0" maxOccurs="unbounded"> + <xs:complexType> + <xs:complexContent> + <xs:extension base="xdws:xdwsResultInfo"> + <xs:choice minOccurs="0"> + <xs:element name="a" type="xs:string"/> + <xs:element name="b" type="xs:string"/> + </xs:choice> + </xs:extension> + </xs:complexContent> + </xs:complexType> + </xs:element> + <xs:element name="result" type="xdws:xdwsResultInfo"/> + </xs:sequence> + <xs:attribute name="version" type="xs:int" use="required" /> + </xs:complexType> + </xs:element> +</xs:schema> Added: webservices/jaxme/branches/b0_5/src/test/jaxb/jira/jaxme-83.xsd URL: http://svn.apache.org/viewvc/webservices/jaxme/branches/b0_5/src/test/jaxb/jira/jaxme-83.xsd?view=auto&rev=454664 ============================================================================== --- webservices/jaxme/branches/b0_5/src/test/jaxb/jira/jaxme-83.xsd (added) +++ webservices/jaxme/branches/b0_5/src/test/jaxb/jira/jaxme-83.xsd Tue Oct 10 01:35:33 2006 @@ -0,0 +1,19 @@ +<xs:schema + xmlns:xs="http://www.w3.org/2001/XMLSchema" + xmlns="http://ws.apache.org/jaxme/test/jira/elementref" + targetNamespace="http://ws.apache.org/jaxme/test/jira/elementref" + elementFormDefault="qualified"> + <xs:element name="Dcr"> + <xs:complexType> + <xs:attribute name="id"/> + </xs:complexType> + </xs:element> + + <xs:element name="DcrLoadResult"> + <xs:complexType> + <xs:sequence> + <xs:element ref="Dcr"/> + </xs:sequence> + </xs:complexType> + </xs:element> +</xs:schema> Modified: webservices/jaxme/branches/b0_5/src/xs/org/apache/ws/jaxme/xs/XSComplexType.java URL: http://svn.apache.org/viewvc/webservices/jaxme/branches/b0_5/src/xs/org/apache/ws/jaxme/xs/XSComplexType.java?view=diff&rev=454664&r1=454663&r2=454664 ============================================================================== --- webservices/jaxme/branches/b0_5/src/xs/org/apache/ws/jaxme/xs/XSComplexType.java (original) +++ webservices/jaxme/branches/b0_5/src/xs/org/apache/ws/jaxme/xs/XSComplexType.java Tue Oct 10 01:35:33 2006 @@ -17,6 +17,7 @@ package org.apache.ws.jaxme.xs; import org.apache.ws.jaxme.xs.xml.*; +import org.xml.sax.SAXException; /** <p>Details of a complex type.</p> @@ -50,7 +51,7 @@ * @see #isElementOnly() * @see #isMixed() */ - public XsComplexContentType getComplexContentType(); + public XsComplexContentType getComplexContentType() throws SAXException; /** <p>If the element hasn't simple content: Returns whether the * elements content is empty. Shortcut for @@ -59,7 +60,7 @@ * complex content * @see XsComplexContentType#EMPTY */ - public boolean isEmpty(); + public boolean isEmpty() throws SAXException; /** <p>If the element hasn't simple content: Returns whether the * elements content is elementOnly. Shortcut for @@ -68,7 +69,7 @@ * complex content * @see XsComplexContentType#ELEMENT_ONLY */ - public boolean isElementOnly(); + public boolean isElementOnly() throws SAXException; /** <p>If the element hasn't simple content: Returns whether the * elements content is mixed. Shortcut for @@ -77,26 +78,26 @@ * complex content * @see XsComplexContentType#MIXED */ - public boolean isMixed(); + public boolean isMixed() throws SAXException; /** <p>If the element hasn't simple content: Returns the complex * elements particle.</p> * @throws IllegalStateException The element has simple content */ - public XSParticle getParticle(); + public XSParticle getParticle() throws SAXException; /** <p>Returns the complex types attributes.</p> */ - public XSAttributable[] getAttributes(); + public XSAttributable[] getAttributes() throws SAXException; /** <p>Returns whether the element is a extension of another element.</p> */ - public boolean isExtension(); + public boolean isExtension() throws SAXException; /** <p>If the element is an extension: Returns the extended type.</p> * @throws IllegalStateException The element is no extension. */ - public XSType getExtendedType(); + public XSType getExtendedType() throws SAXException; /** <p>Returns whether the element is a restriction of another element.</p> */ Modified: webservices/jaxme/branches/b0_5/src/xs/org/apache/ws/jaxme/xs/impl/XSTypeImpl.java URL: http://svn.apache.org/viewvc/webservices/jaxme/branches/b0_5/src/xs/org/apache/ws/jaxme/xs/impl/XSTypeImpl.java?view=diff&rev=454664&r1=454663&r2=454664 ============================================================================== --- webservices/jaxme/branches/b0_5/src/xs/org/apache/ws/jaxme/xs/impl/XSTypeImpl.java (original) +++ webservices/jaxme/branches/b0_5/src/xs/org/apache/ws/jaxme/xs/impl/XSTypeImpl.java Tue Oct 10 01:35:33 2006 @@ -44,7 +44,7 @@ public abstract class XSComplexTypeImpl implements XSComplexType { protected final XSType owner; private final XsTComplexType myComplexType; - protected XSType extendedType, restrictedType; + protected XSType restrictedType; public XSComplexTypeImpl(XSType pOwner, XsTComplexType pType) { owner = pOwner; @@ -62,20 +62,17 @@ throw new IllegalStateException("This complex type doesn't have simple content."); } public boolean hasComplexContent() { return false; } - public boolean isEmpty() { return XsComplexContentType.EMPTY.equals(getComplexContentType()); } - public boolean isElementOnly() { return XsComplexContentType.ELEMENT_ONLY.equals(getComplexContentType()); } - public boolean isMixed() { return XsComplexContentType.MIXED.equals(getComplexContentType()); } + public boolean isEmpty() throws SAXException { return XsComplexContentType.EMPTY.equals(getComplexContentType()); } + public boolean isElementOnly() throws SAXException { return XsComplexContentType.ELEMENT_ONLY.equals(getComplexContentType()); } + public boolean isMixed() throws SAXException { return XsComplexContentType.MIXED.equals(getComplexContentType()); } public void validate() throws SAXException { } - public boolean isExtension() { return extendedType != null; } - public XSType getExtendedType() { - if (extendedType == null) { + public boolean isExtension() throws SAXException { return false; } + public XSType getExtendedType() throws SAXException { throw new IllegalStateException("This type is no extension."); - } - return extendedType; } public boolean isRestriction() { return restrictedType != null; } @@ -91,12 +88,24 @@ private final XsESimpleContent simpleContent; private final XSSimpleContentType simpleContentType; private final XSAttributable[] attributes; + private final XSType extendedType; public boolean isElementOnly() { return false; } public boolean isEmpty() { return false; } public boolean isMixed() { return false; } - public XSSimpleContentImpl(XSType pOwner, XsTComplexType pType, XsESimpleContent pSimpleContent) + public XSType getExtendedType() throws SAXException { + if (extendedType == null) { + super.getExtendedType(); + } + return extendedType; + } + + public boolean isExtension() throws SAXException { + return extendedType != null; + } + + public XSSimpleContentImpl(XSType pOwner, XsTComplexType pType, XsESimpleContent pSimpleContent) throws SAXException { super(pOwner, pType); simpleContent = pSimpleContent; @@ -169,230 +178,259 @@ } } - public class XSComplexContentImpl extends XSComplexTypeImpl { - private final XsEComplexContent complexContent; - private final XSParticle complexContentParticle; - private final XsComplexContentType complexContentType; - private final XSAttributable[] attributes; - - protected XsEComplexContent getComplexContent() { - return complexContent; - } - - private int getMinOccursByParticle(XsTTypeDefParticle pParticle) throws SAXException { - if (pParticle instanceof XsEChoice) { - return ((XsEChoice) pParticle).getMinOccurs(); - } else if (pParticle instanceof XsESequence) { - return ((XsESequence) pParticle).getMinOccurs(); - } else if (pParticle instanceof XsTAll) { - return ((XsTAll) pParticle).getMinOccurs(); - } else if (pParticle instanceof XsTGroupRef) { - return ((XsTGroupRef) pParticle).getMinOccurs(); - } else { - throw new IllegalStateException("Unknown TypeDefParticle type: " + pParticle.getClass().getName()); + public class XSComplexContentImpl extends XSComplexTypeImpl { + private final XsEComplexContent complexContent; + private final XSType owner; + private boolean complexContentInitialized; + private XSParticle complexContentParticle2; + private XsComplexContentType complexContentType2; + private XSAttributable[] attributes2; + private XSType extendedType; + + protected XsEComplexContent getComplexContent() { + return complexContent; + } + + private int getMinOccursByParticle(XsTTypeDefParticle pParticle) throws SAXException { + if (pParticle instanceof XsEChoice) { + return ((XsEChoice) pParticle).getMinOccurs(); + } else if (pParticle instanceof XsESequence) { + return ((XsESequence) pParticle).getMinOccurs(); + } else if (pParticle instanceof XsTAll) { + return ((XsTAll) pParticle).getMinOccurs(); + } else if (pParticle instanceof XsTGroupRef) { + return ((XsTGroupRef) pParticle).getMinOccurs(); + } else { + throw new IllegalStateException("Unknown TypeDefParticle type: " + pParticle.getClass().getName()); + } } - } - private int getMaxOccursByParticle(XsTTypeDefParticle pParticle) throws SAXException { - if (pParticle instanceof XsEChoice) { - return ((XsEChoice) pParticle).getMaxOccurs(); - } else if (pParticle instanceof XsESequence) { - return ((XsESequence) pParticle).getMaxOccurs(); - } else if (pParticle instanceof XsTAll) { - return ((XsTAll) pParticle).getMaxOccurs(); - } else if (pParticle instanceof XsTGroupRef) { - return ((XsTGroupRef) pParticle).getMaxOccurs(); - } else { - throw new IllegalStateException("Unknown TypeDefParticle type: " + pParticle.getClass().getName()); + private int getMaxOccursByParticle(XsTTypeDefParticle pParticle) throws SAXException { + if (pParticle instanceof XsEChoice) { + return ((XsEChoice) pParticle).getMaxOccurs(); + } else if (pParticle instanceof XsESequence) { + return ((XsESequence) pParticle).getMaxOccurs(); + } else if (pParticle instanceof XsTAll) { + return ((XsTAll) pParticle).getMaxOccurs(); + } else if (pParticle instanceof XsTGroupRef) { + return ((XsTGroupRef) pParticle).getMaxOccurs(); + } else { + throw new IllegalStateException("Unknown TypeDefParticle type: " + pParticle.getClass().getName()); + } } - } - protected XSGroup getGroupByParticle(XsTTypeDefParticle pParticle) throws SAXException { - XSGroup result; - XSType myOwner = getOwner(); - XSObjectFactory factory = myOwner.getXSSchema().getXSObjectFactory(); - if (pParticle == null) { - return null; - } else if (pParticle instanceof XsEChoice) { - XsEChoice choice = (XsEChoice) pParticle; - result = factory.newXSGroup(myOwner, choice); - } else if (pParticle instanceof XsESequence) { - XsESequence sequence = (XsESequence) pParticle; - result = factory.newXSGroup(myOwner, sequence); - } else if (pParticle instanceof XsTAll) { - XsTAll all = (XsTAll) pParticle; - result = factory.newXSGroup(myOwner, all); - } else if (pParticle instanceof XsTGroupRef) { - XsTGroupRef groupRef = (XsTGroupRef) pParticle; - result = factory.newXSGroup(myOwner, groupRef); - } else { - throw new IllegalStateException("Unknown TypeDefParticle type: " + pParticle.getClass().getName()); - } - result.validate(); - return result; - } + protected XSGroup getGroupByParticle(XsTTypeDefParticle pParticle) throws SAXException { + XSGroup result; + XSType myOwner = getOwner(); + XSObjectFactory factory = myOwner.getXSSchema().getXSObjectFactory(); + if (pParticle == null) { + return null; + } else if (pParticle instanceof XsEChoice) { + XsEChoice choice = (XsEChoice) pParticle; + result = factory.newXSGroup(myOwner, choice); + } else if (pParticle instanceof XsESequence) { + XsESequence sequence = (XsESequence) pParticle; + result = factory.newXSGroup(myOwner, sequence); + } else if (pParticle instanceof XsTAll) { + XsTAll all = (XsTAll) pParticle; + result = factory.newXSGroup(myOwner, all); + } else if (pParticle instanceof XsTGroupRef) { + XsTGroupRef groupRef = (XsTGroupRef) pParticle; + result = factory.newXSGroup(myOwner, groupRef); + } else { + throw new IllegalStateException("Unknown TypeDefParticle type: " + pParticle.getClass().getName()); + } + result.validate(); + return result; + } - protected XsComplexContentType getContentTypeByParticle(XsTTypeDefParticle pParticle, XSGroup pGroup) - throws SAXException { - if (pParticle == null) { - return XsComplexContentType.EMPTY; - } else if (pParticle instanceof XsEChoice) { - if (pGroup.getParticles().length == 0) { - XsEChoice choice = (XsEChoice) pParticle; - if (choice.getMinOccurs() == 0) { - return XsComplexContentType.EMPTY; - } else { - throw new LocSAXException("Invalid choice: Neither child elements, nor 'minOccurs'=0", choice.getLocator()); - } - } else { + protected XsComplexContentType getContentTypeByParticle(XsTTypeDefParticle pParticle, XSGroup pGroup) + throws SAXException { + if (pParticle == null) { + return XsComplexContentType.EMPTY; + } else if (pParticle instanceof XsEChoice) { + if (pGroup.getParticles().length == 0) { + XsEChoice choice = (XsEChoice) pParticle; + if (choice.getMinOccurs() == 0) { + return XsComplexContentType.EMPTY; + } else { + throw new LocSAXException("Invalid choice: Neither child elements, nor 'minOccurs'=0", choice.getLocator()); + } + } else { + } + } else if (pParticle instanceof XsESequence) { + if (pGroup.getParticles().length == 0) { + return XsComplexContentType.EMPTY; + } + } else if (pParticle instanceof XsTAll) { + if (pGroup.getParticles().length == 0) { + return XsComplexContentType.EMPTY; + } + } else if (pParticle instanceof XsTGroupRef) { + } else { + throw new IllegalStateException("Unknown TypeDefParticle type: " + pParticle.getClass().getName()); + } + boolean isMixed; + if (complexContent.isMixed() == null) { + isMixed = ((XsTComplexType) getXsObject()).isMixed(); + } else { + isMixed = complexContent.isMixed().booleanValue(); + } + return isMixed ? XsComplexContentType.MIXED : XsComplexContentType.ELEMENT_ONLY; } - } else if (pParticle instanceof XsESequence) { - if (pGroup.getParticles().length == 0) { - return XsComplexContentType.EMPTY; - } - } else if (pParticle instanceof XsTAll) { - if (pGroup.getParticles().length == 0) { - return XsComplexContentType.EMPTY; + + private class ExtensionGroup implements XSGroup { + private final XSObject parent; + private final XSParticle[] particles; + private ExtensionGroup(XSObject pParent, XSParticle[] pParticles) { + parent = pParent; + particles = pParticles; + } + public boolean isTopLevelObject() { return false; } + public boolean isGlobal() { return false; } + public XsQName getName() { return null; } + public XSSchema getXSSchema() { return XSTypeImpl.this.getXSSchema(); } + public Locator getLocator() { return getComplexContent().getLocator(); } + public void validate() throws SAXException {} + public XSModelGroup.Compositor getCompositor() { return XSModelGroup.SEQUENCE; } + public boolean isSequence() { return true; } + public boolean isChoice() { return false; } + public boolean isAll() { return false; } + public XSParticle[] getParticles() { return particles; } + public XSAnnotation[] getAnnotations() { return new XSAnnotation[0]; } + public void setGlobal(boolean pGlobal) { + if (pGlobal) { + throw new IllegalStateException("An extensions model group cannot be made global."); + } + } + public XSObject getParentObject() { return parent; } + public Attributes getOpenAttributes() { return null; } } - } else if (pParticle instanceof XsTGroupRef) { - } else { - throw new IllegalStateException("Unknown TypeDefParticle type: " + pParticle.getClass().getName()); - } - boolean isMixed; - if (complexContent.isMixed() == null) { - isMixed = ((XsTComplexType) getXsObject()).isMixed(); - } else { - isMixed = complexContent.isMixed().booleanValue(); - } - return isMixed ? XsComplexContentType.MIXED : XsComplexContentType.ELEMENT_ONLY; - } - private class ExtensionGroup implements XSGroup { - private final XSObject parent; - private final XSParticle[] particles; - private ExtensionGroup(XSObject pParent, XSParticle[] pParticles) { - parent = pParent; - particles = pParticles; - } - public boolean isTopLevelObject() { return false; } - public boolean isGlobal() { return false; } - public XsQName getName() { return null; } - public XSSchema getXSSchema() { return XSTypeImpl.this.getXSSchema(); } - public Locator getLocator() { return getComplexContent().getLocator(); } - public XSObjectFactory getXSObjectFactory() { return getXSObjectFactory(); } - public void validate() throws SAXException {} - public XSModelGroup.Compositor getCompositor() { return XSModelGroup.SEQUENCE; } - public boolean isSequence() { return true; } - public boolean isChoice() { return false; } - public boolean isAll() { return false; } - public XSParticle[] getParticles() { return particles; } - public XSAnnotation[] getAnnotations() { return new XSAnnotation[0]; } - public void setGlobal(boolean pGlobal) { - if (pGlobal) { - throw new IllegalStateException("An extensions model group cannot be made global."); + public XSComplexContentImpl(XSType pOwner, XsTComplexType pType, XsEComplexContent pComplexContent) + throws SAXException { + super(pOwner, pType); + complexContent = pComplexContent; + owner = pOwner; } - } - public XSObject getParentObject() { return parent; } - public Attributes getOpenAttributes() { return null; } - } - public XSComplexContentImpl(XSType pOwner, XsTComplexType pType, XsEComplexContent pComplexContent) - throws SAXException { - super(pOwner, pType); - complexContent = pComplexContent; - XsTExtensionType extension = complexContent.getExtension(); - if (extension == null) { - XsTComplexRestrictionType restriction = complexContent.getRestriction(); - if (restriction == null) { - // TODO: Restriction of the ur-type - throw new LocSAXException("Neither of extension or restriction, aka restriction of the ur-type: Not implemented", - complexContent.getLocator()); - } - XsQName base = restriction.getBase(); - if (base == null) { - throw new LocSAXException("Invalid 'restriction': Missing 'base' attribute", getLocator()); - } - XSType type = getXSSchema().getType(base); - if (type == null) { - throw new LocSAXException("Invalid 'restriction': Unknown base type " + base, getLocator()); - } - if (type.isSimple()) { - throw new LocSAXException("Invalid 'restriction': The base type " + getName() + " is simple.", getLocator()); - } - XsTTypeDefParticle particle = restriction.getTypeDefParticle(); - - XSGroup group = getGroupByParticle(particle); - if (group == null) { - // TODO: Restriction of the ur-type - complexContentParticle = null; - } else { - complexContentParticle = new XSParticleImpl(group); + public XSType getExtendedType() throws SAXException { + initContent(); + if (extendedType == null) { + super.getExtendedType(); + } + return extendedType; } - complexContentType = getContentTypeByParticle(particle, group); - attributes = XSAttributeGroupImpl.getAttributes(XSTypeImpl.this, restriction); - restrictedType = type; - } else { - XsQName base = extension.getBase(); - if (base == null) { - throw new LocSAXException("Invalid 'extension': Missing 'base' attribute", getLocator()); - } - XSType type = getXSSchema().getType(base); - if (type == null) { - throw new LocSAXException("Invalid 'extension': Unknown base type " + base, getLocator()); - } - if (type.isSimple()) { - throw new LocSAXException("Invalid 'extension': The base type " + base + " is simple.", getLocator()); - } - XSComplexType extendedComplexType = type.getComplexType(); - if (extendedComplexType.hasSimpleContent()) { - throw new LocSAXException("Invalid 'extension': The base type " + base + " has simple content.", - getLocator()); - } - XsTTypeDefParticle particle = extension.getTypeDefParticle(); - XSGroup group = getGroupByParticle(particle); - XsComplexContentType groupType = getContentTypeByParticle(particle, group); - - if (XsComplexContentType.EMPTY.equals(groupType)) { - if (type == XSAnyType.getInstance()) { - complexContentType = null; - complexContentParticle = null; - } else { - complexContentType = extendedComplexType.getComplexContentType(); - complexContentParticle = extendedComplexType.getParticle(); - } - } else if (extendedComplexType.isEmpty()) { - complexContentType = groupType; - XSParticleImpl particleImpl = new XSParticleImpl(group); - particleImpl.setMinOccurs(getMinOccursByParticle(particle)); - particleImpl.setMaxOccurs(getMaxOccursByParticle(particle)); - complexContentParticle = particleImpl; - } else { - XSGroup sequenceGroup = new ExtensionGroup(pOwner, new XSParticle[]{extendedComplexType.getParticle(), new XSParticleImpl(group)}); - complexContentParticle = new XSParticleImpl(sequenceGroup); - complexContentType = groupType; + + public boolean isExtension() throws SAXException { + initContent(); + return extendedType != null; } - XSAttributable[] inheritedAttributes = extendedComplexType.getAttributes(); - XSAttributable[] myAttributes = XSAttributeGroupImpl.getAttributes(XSTypeImpl.this, extension); - attributes = new XSAttributable[inheritedAttributes.length + myAttributes.length]; - System.arraycopy(inheritedAttributes, 0, attributes, 0, inheritedAttributes.length); - System.arraycopy(myAttributes, 0, attributes, inheritedAttributes.length, myAttributes.length); - extendedType = type; - } - } + public boolean hasComplexContent() { return true; } - public boolean hasComplexContent() { return true; } + private void initContent() throws SAXException { + if (complexContentInitialized) { + return; + } + XsTExtensionType extension = complexContent.getExtension(); + if (extension == null) { + XsTComplexRestrictionType restriction = complexContent.getRestriction(); + if (restriction == null) { + // TODO: Restriction of the ur-type + throw new LocSAXException("Neither of extension or restriction, aka restriction of the ur-type: Not implemented", + complexContent.getLocator()); + } + XsQName base = restriction.getBase(); + if (base == null) { + throw new LocSAXException("Invalid 'restriction': Missing 'base' attribute", getLocator()); + } + XSType type = getXSSchema().getType(base); + if (type == null) { + throw new LocSAXException("Invalid 'restriction': Unknown base type " + base, getLocator()); + } + if (type.isSimple()) { + throw new LocSAXException("Invalid 'restriction': The base type " + getName() + " is simple.", getLocator()); + } + XsTTypeDefParticle particle = restriction.getTypeDefParticle(); + + XSGroup group = getGroupByParticle(particle); + if (group == null) { + // TODO: Restriction of the ur-type + complexContentParticle2 = null; + } else { + complexContentParticle2 = new XSParticleImpl(group); + } + complexContentType2 = getContentTypeByParticle(particle, group); + attributes2 = XSAttributeGroupImpl.getAttributes(XSTypeImpl.this, restriction); + restrictedType = type; + } else { + XsQName base = extension.getBase(); + if (base == null) { + throw new LocSAXException("Invalid 'extension': Missing 'base' attribute", getLocator()); + } + XSType type = getXSSchema().getType(base); + if (type == null) { + throw new LocSAXException("Invalid 'extension': Unknown base type " + base, getLocator()); + } + if (type.isSimple()) { + throw new LocSAXException("Invalid 'extension': The base type " + base + " is simple.", getLocator()); + } + XSComplexType extendedComplexType = type.getComplexType(); + if (extendedComplexType.hasSimpleContent()) { + throw new LocSAXException("Invalid 'extension': The base type " + base + " has simple content.", + getLocator()); + } + XsTTypeDefParticle particle = extension.getTypeDefParticle(); + + XSGroup group = getGroupByParticle(particle); + XsComplexContentType groupType = getContentTypeByParticle(particle, group); + if (XsComplexContentType.EMPTY.equals(groupType)) { + if (type == XSAnyType.getInstance()) { + complexContentType2 = null; + complexContentParticle2 = null; + } else { + complexContentType2 = extendedComplexType.getComplexContentType(); + complexContentParticle2 = extendedComplexType.getParticle(); + } + } else if (extendedComplexType.isEmpty()) { + complexContentType2 = groupType; + XSParticleImpl particleImpl = new XSParticleImpl(group); + particleImpl.setMinOccurs(getMinOccursByParticle(particle)); + particleImpl.setMaxOccurs(getMaxOccursByParticle(particle)); + complexContentParticle2 = particleImpl; + } else { + XSGroup sequenceGroup = new ExtensionGroup(owner, new XSParticle[]{extendedComplexType.getParticle(), new XSParticleImpl(group)}); + complexContentParticle2 = new XSParticleImpl(sequenceGroup); + complexContentType2 = groupType; + } + + XSAttributable[] inheritedAttributes = extendedComplexType.getAttributes(); + XSAttributable[] myAttributes = XSAttributeGroupImpl.getAttributes(XSTypeImpl.this, extension); + attributes2 = new XSAttributable[inheritedAttributes.length + myAttributes.length]; + System.arraycopy(inheritedAttributes, 0, attributes2, 0, inheritedAttributes.length); + System.arraycopy(myAttributes, 0, attributes2, inheritedAttributes.length, myAttributes.length); + extendedType = type; + } - public XsComplexContentType getComplexContentType() { - return complexContentType; - } + complexContentInitialized = true; + } - public XSParticle getParticle() { - return complexContentParticle; - } + public XsComplexContentType getComplexContentType() throws SAXException { + initContent(); + return complexContentType2; + } - public XSAttributable[] getAttributes() { return attributes; } - } + public XSParticle getParticle() throws SAXException { + initContent(); + return complexContentParticle2; + } + + public XSAttributable[] getAttributes() throws SAXException { + initContent(); + return attributes2; + } + } public abstract class XSBasicComplexTypeImpl extends XSComplexTypeImpl { @@ -646,121 +684,125 @@ } public void validate() throws SAXException { - if (isValidated()) { - return; - } else { - isValidated = true; - } + if (isValidated()) { + return; + } else { + isValidated = true; + } - if (xsAnnotation == null) { - annotations = new XSAnnotation[0]; - } else { - XSAnnotation result = getXSSchema().getXSObjectFactory().newXSAnnotation(this, xsAnnotation); - result.validate(); - annotations = new XSAnnotation[]{result}; - } + if (xsAnnotation == null) { + annotations = new XSAnnotation[0]; + } else { + XSAnnotation result = getXSSchema().getXSObjectFactory().newXSAnnotation(this, xsAnnotation); + result.validate(); + annotations = new XSAnnotation[]{result}; + } + + if (isSimple()) { + XSSimpleType mySimpleType; + Object baseObject = getXsObject(); + if (baseObject instanceof XsTSimpleType) { + XsTSimpleType myXsTSimpleType = (XsTSimpleType) baseObject; + XsEList list = myXsTSimpleType.getList(); + if (list == null) { + XsEUnion union = myXsTSimpleType.getUnion(); + if (union == null) { + XsERestriction restriction = myXsTSimpleType.getRestriction(); + if (restriction == null) { + throw new LocSAXException("Either of the 'list', 'union', or 'restriction' child elements must be set.", + myXsTSimpleType.getLocator()); + } + XsQName myName = restriction.getBase(); + XSType restrictedType; + if (myName == null) { + XsTLocalSimpleType baseType = restriction.getSimpleType(); + if (baseType == null) { + throw new LocSAXException("Neither the 'base' attribute nor an inner 'simpleType' element are present", + restriction.getLocator()); + } else { + restrictedType = getXSSchema().getXSObjectFactory().newXSType(this, baseType); + } + } else { + restrictedType = getXSSchema().getType(myName); + if (restrictedType == null) { + throw new LocSAXException("Unknown base type: " + myName, + restriction.getLocator()); + } + } + restrictedType.validate(); + if (!restrictedType.isSimple()) { + throw new LocSAXException("The restricted type " + myName + " is complex.", + restriction.getLocator()); + } + XSSimpleType baseType = restrictedType.getSimpleType(); + if (baseType.isAtomic()) { + mySimpleType = getXSSchema().getXSObjectFactory().newXSAtomicType(this, restrictedType, restriction); + } else if (baseType.isList()) { + mySimpleType = getXSSchema().getXSObjectFactory().newXSListType(this, restrictedType, restriction); + } else if (baseType.isUnion()) { + mySimpleType = getXSSchema().getXSObjectFactory().newXSUnionType(this, restrictedType, restriction); + } else { + throw new LocSAXException("Unknown restriction type: " + baseType, restriction.getLocator()); + } + } else { + mySimpleType = getXSSchema().getXSObjectFactory().newXSUnionType(this, union); + } + } else { + mySimpleType = getXSSchema().getXSObjectFactory().newXSListType(this, list); + } + } + else { + mySimpleType = getSimpleType(); + } - if (isSimple()) { - XSSimpleType mySimpleType; - Object baseObject = getXsObject(); - if (baseObject instanceof XsTSimpleType) { - XsTSimpleType myXsTSimpleType = (XsTSimpleType) baseObject; - XsEList list = myXsTSimpleType.getList(); - if (list == null) { - XsEUnion union = myXsTSimpleType.getUnion(); - if (union == null) { - XsERestriction restriction = myXsTSimpleType.getRestriction(); - if (restriction == null) { - throw new LocSAXException("Either of the 'list', 'union', or 'restriction' child elements must be set.", - myXsTSimpleType.getLocator()); - } - XsQName myName = restriction.getBase(); - XSType restrictedType; - if (myName == null) { - XsTLocalSimpleType baseType = restriction.getSimpleType(); - if (baseType == null) { - throw new LocSAXException("Neither the 'base' attribute nor an inner 'simpleType' element are present", - restriction.getLocator()); - } else { - restrictedType = getXSSchema().getXSObjectFactory().newXSType(this, baseType); - } - } else { - restrictedType = getXSSchema().getType(myName); - if (restrictedType == null) { - throw new LocSAXException("Unknown base type: " + myName, - restriction.getLocator()); - } - } - restrictedType.validate(); - if (!restrictedType.isSimple()) { - throw new LocSAXException("The restricted type " + myName + " is complex.", - restriction.getLocator()); - } - XSSimpleType baseType = restrictedType.getSimpleType(); - if (baseType.isAtomic()) { - mySimpleType = getXSSchema().getXSObjectFactory().newXSAtomicType(this, restrictedType, restriction); - } else if (baseType.isList()) { - mySimpleType = getXSSchema().getXSObjectFactory().newXSListType(this, restrictedType, restriction); - } else if (baseType.isUnion()) { - mySimpleType = getXSSchema().getXSObjectFactory().newXSUnionType(this, restrictedType, restriction); - } else { - throw new LocSAXException("Unknown restriction type: " + baseType, restriction.getLocator()); - } - } else { - mySimpleType = getXSSchema().getXSObjectFactory().newXSUnionType(this, union); - } - } else { - mySimpleType = getXSSchema().getXSObjectFactory().newXSListType(this, list); - } - } - else { - mySimpleType = getSimpleType(); + this.simpleType = mySimpleType; + } else { + validateComplexType(); } - - this.simpleType = mySimpleType; - } else { - XSComplexTypeImpl myComplexType; - XsTComplexType myXsTComplexType = (XsTComplexType) getXsObject(); - XsESimpleContent simpleContent = myXsTComplexType.getSimpleContent(); - if (simpleContent == null) { - XsEComplexContent complexContent = myXsTComplexType.getComplexContent(); - if (complexContent == null) { - XsTTypeDefParticle particle = myXsTComplexType.getTypeDefParticle(); - if (particle == null) { - myComplexType = new XSSequenceComplexTypeImpl(this, myXsTComplexType); - } else if (particle instanceof XsESequence) { - myComplexType = new XSSequenceComplexTypeImpl(this, myXsTComplexType, (XsESequence) particle); - } else if (particle instanceof XsEChoice) { - myComplexType = new XSChoiceComplexTypeImpl(this, myXsTComplexType, (XsEChoice) particle); - } else if (particle instanceof XsTAll) { - myComplexType = new XSAllComplexTypeImpl(this, myXsTComplexType, (XsTAll) particle); - } else if (particle instanceof XsTGroupRef) { - XsTGroupRef groupRef = (XsTGroupRef) particle; - XsQName myName = groupRef.getRef(); - if (myName == null) { - throw new LocSAXException("Missing 'ref' attribute", groupRef.getLocator()); - } - XSGroup group = getXSSchema().getGroup(myName); - if (group == null) { - throw new LocSAXException("Unknown group: " + myName, getLocator()); - } - group.validate(); - myComplexType = new XSGroupComplexTypeImpl(this, myXsTComplexType, group, groupRef); - } else { - throw new IllegalStateException("Invalid particle: " + particle.getClass().getName()); - } + } + + private void validateComplexType() throws SAXException, LocSAXException { + XSComplexTypeImpl myComplexType; + XsTComplexType myXsTComplexType = (XsTComplexType) getXsObject(); + XsESimpleContent simpleContent = myXsTComplexType.getSimpleContent(); + if (simpleContent == null) { + XsEComplexContent complexContent = myXsTComplexType.getComplexContent(); + if (complexContent == null) { + XsTTypeDefParticle particle = myXsTComplexType.getTypeDefParticle(); + if (particle == null) { + myComplexType = new XSSequenceComplexTypeImpl(this, myXsTComplexType); + } else if (particle instanceof XsESequence) { + myComplexType = new XSSequenceComplexTypeImpl(this, myXsTComplexType, (XsESequence) particle); + } else if (particle instanceof XsEChoice) { + myComplexType = new XSChoiceComplexTypeImpl(this, myXsTComplexType, (XsEChoice) particle); + } else if (particle instanceof XsTAll) { + myComplexType = new XSAllComplexTypeImpl(this, myXsTComplexType, (XsTAll) particle); + } else if (particle instanceof XsTGroupRef) { + XsTGroupRef groupRef = (XsTGroupRef) particle; + XsQName myName = groupRef.getRef(); + if (myName == null) { + throw new LocSAXException("Missing 'ref' attribute", groupRef.getLocator()); + } + XSGroup group = getXSSchema().getGroup(myName); + if (group == null) { + throw new LocSAXException("Unknown group: " + myName, getLocator()); + } + group.validate(); + myComplexType = new XSGroupComplexTypeImpl(this, myXsTComplexType, group, groupRef); + } else { + throw new IllegalStateException("Invalid particle: " + particle.getClass().getName()); + } + } else { + XSComplexContentImpl complexContentImpl = new XSComplexContentImpl(this, myXsTComplexType, complexContent); + myComplexType = complexContentImpl; + } } else { - XSComplexContentImpl complexContentImpl = new XSComplexContentImpl(this, myXsTComplexType, complexContent); - myComplexType = complexContentImpl; + XSSimpleContentImpl simpleContentImpl = new XSSimpleContentImpl(this, myXsTComplexType, simpleContent); + myComplexType = simpleContentImpl; } - } else { - XSSimpleContentImpl simpleContentImpl = new XSSimpleContentImpl(this, myXsTComplexType, simpleContent); - myComplexType = simpleContentImpl; - } - this.complexType = myComplexType; - myComplexType.validate(); + this.complexType = myComplexType; + myComplexType.validate(); } - } public XSSimpleType getSimpleType() throws SAXException { validate(); Modified: webservices/jaxme/branches/b0_5/src/xs/org/apache/ws/jaxme/xs/junit/ParserTest.java URL: http://svn.apache.org/viewvc/webservices/jaxme/branches/b0_5/src/xs/org/apache/ws/jaxme/xs/junit/ParserTest.java?view=diff&rev=454664&r1=454663&r2=454664 ============================================================================== --- webservices/jaxme/branches/b0_5/src/xs/org/apache/ws/jaxme/xs/junit/ParserTest.java (original) +++ webservices/jaxme/branches/b0_5/src/xs/org/apache/ws/jaxme/xs/junit/ParserTest.java Tue Oct 10 01:35:33 2006 @@ -1551,4 +1551,41 @@ testGroupMultiplicity(newXSParser()); testGroupMultiplicity(newJAXBParser()); } + + private void testComplexTypeConsideredSimple(XSParser pParser) throws Exception { + final String schemaSource + = "<xs:schema xmlns='www.fgm.com/services/fgm/1.1'\n" + + " xmlns:xs='http://www.w3.org/2001/XMLSchema'\n" + + " targetNamespace='www.fgm.com/services/fgm/1.1'\n" + + " elementFormDefault='qualified'>\n" + + " <xs:complexType name='BaseObject'/>\n" + + " <xs:complexType name='BrokenObject'>\n" + + " <xs:complexContent>\n" + + " <xs:extension base='BaseObject'>\n" + + " <xs:sequence>\n" + + " <xs:choice minOccurs='0' maxOccurs='unbounded'>\n" + + " <xs:element name='Choice' type='ExtendedBrokenObject'\n" + + " minOccurs='0' maxOccurs='unbounded'/>\n" + + " </xs:choice>\n" + + " </xs:sequence>\n" + + " </xs:extension>\n" + + " </xs:complexContent>\n" + + " </xs:complexType>\n" + + " <xs:complexType name='ExtendedBrokenObject'>\n" + + " <xs:complexContent>\n" + + " <xs:extension base='BrokenObject'/>\n" + + " </xs:complexContent>\n" + + " </xs:complexType>\n" + + "</xs:schema>\n"; + InputSource isource = new InputSource(new StringReader(schemaSource)); + isource.setSystemId("testComplexTypeConsideredSimple.xsd"); + pParser.parse(isource); + } + + /** Test for http://marc.theaimsgroup.com/?l=jaxme-dev&m=115945460223201&w=2 + */ + public void testComplexTypeConsideredSimple() throws Exception { + testComplexTypeConsideredSimple(newXSParser()); + testComplexTypeConsideredSimple(newJAXBParser()); + } } Modified: webservices/jaxme/branches/b0_5/src/xs/org/apache/ws/jaxme/xs/junit/ParserTestBase.java URL: http://svn.apache.org/viewvc/webservices/jaxme/branches/b0_5/src/xs/org/apache/ws/jaxme/xs/junit/ParserTestBase.java?view=diff&rev=454664&r1=454663&r2=454664 ============================================================================== --- webservices/jaxme/branches/b0_5/src/xs/org/apache/ws/jaxme/xs/junit/ParserTestBase.java (original) +++ webservices/jaxme/branches/b0_5/src/xs/org/apache/ws/jaxme/xs/junit/ParserTestBase.java Tue Oct 10 01:35:33 2006 @@ -158,7 +158,7 @@ return result; } - protected XSParticle assertComplexContent(XSComplexType pType) { + protected XSParticle assertComplexContent(XSComplexType pType) throws SAXException { assertTrue(!pType.hasSimpleContent()); XSParticle result = pType.getParticle(); assertNotNull(result); @@ -230,7 +230,7 @@ return result; } - protected XSSimpleContentType assertSimpleContent(XSComplexType pType) { + protected XSSimpleContentType assertSimpleContent(XSComplexType pType) throws SAXException { assertTrue(pType.hasSimpleContent()); XSSimpleContentType result = pType.getSimpleContent(); assertNotNull(result); Modified: webservices/jaxme/branches/b0_5/status.xml URL: http://svn.apache.org/viewvc/webservices/jaxme/branches/b0_5/status.xml?view=diff&rev=454664&r1=454663&r2=454664 ============================================================================== --- webservices/jaxme/branches/b0_5/status.xml (original) +++ webservices/jaxme/branches/b0_5/status.xml Tue Oct 10 01:35:33 2006 @@ -87,6 +87,10 @@ content), then the content particles minOccurs and maxOccurs values haven't been inherited. (JAXME-84) </action> + <action dev="JW" type="fix" context="xs"> + If an recursive type was an extension of another recursive type, + then the initialization could fail. + </action> </release> <release version="0.5.1" date="06-Jan-2006"> <action dev="JW" type="enhancement" context="js"> --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]