jochen 2005/07/13 12:58:16 Modified: src/jaxme/org/apache/ws/jaxme/generator/sg/impl JAXBComplexContentTypeSG.java src/jaxme/org/apache/ws/jaxme/generator/sg/impl/ccsg BeanGeneratingVisitor.java src/jaxme/org/apache/ws/jaxme/junit ParserTest.java Log: Detection of groups with multiplicity > 1 was still unworking in the HEAD. Fixed, and added a unit test. Revision Changes Path 1.11 +1 -1 ws-jaxme/src/jaxme/org/apache/ws/jaxme/generator/sg/impl/JAXBComplexContentTypeSG.java Index: JAXBComplexContentTypeSG.java =================================================================== RCS file: /home/cvs/ws-jaxme/src/jaxme/org/apache/ws/jaxme/generator/sg/impl/JAXBComplexContentTypeSG.java,v retrieving revision 1.10 retrieving revision 1.11 diff -u -r1.10 -r1.11 --- JAXBComplexContentTypeSG.java 8 Jul 2005 20:43:31 -0000 1.10 +++ JAXBComplexContentTypeSG.java 13 Jul 2005 19:58:16 -0000 1.11 @@ -153,7 +153,7 @@ private void findParticles(GroupSG[] pStack, ParticleSG pParticle) throws SAXException { if (pParticle.isGroup()) { - if (pParticle.getMaxOccurs() > 1) { + if (pParticle.isMultiple()) { groupParticlesWithMultiplicityGreaterOne.add(new Particle(pStack, pParticle)); } else if (isMixed) { mixedContentParticles.add(new Particle(pStack, pParticle)); 1.4 +1 -0 ws-jaxme/src/jaxme/org/apache/ws/jaxme/generator/sg/impl/ccsg/BeanGeneratingVisitor.java Index: BeanGeneratingVisitor.java =================================================================== RCS file: /home/cvs/ws-jaxme/src/jaxme/org/apache/ws/jaxme/generator/sg/impl/ccsg/BeanGeneratingVisitor.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- BeanGeneratingVisitor.java 6 Jul 2005 21:34:13 -0000 1.3 +++ BeanGeneratingVisitor.java 13 Jul 2005 19:58:16 -0000 1.4 @@ -96,6 +96,7 @@ } public void startComplexContent(ComplexTypeSG pType) throws SAXException { + pType.getComplexContentSG().getElementParticles(); // Triggers the content verification ct = pType; generateAttributes(pType); if (pType.getComplexContentSG().isMixed()) { 1.10 +82 -45 ws-jaxme/src/jaxme/org/apache/ws/jaxme/junit/ParserTest.java Index: ParserTest.java =================================================================== RCS file: /home/cvs/ws-jaxme/src/jaxme/org/apache/ws/jaxme/junit/ParserTest.java,v retrieving revision 1.9 retrieving revision 1.10 diff -u -r1.9 -r1.10 --- ParserTest.java 8 Jul 2005 20:43:58 -0000 1.9 +++ ParserTest.java 13 Jul 2005 19:58:16 -0000 1.10 @@ -53,6 +53,7 @@ import org.apache.ws.jaxme.xs.types.XSID; import org.apache.ws.jaxme.xs.xml.XsQName; import org.xml.sax.InputSource; +import org.xml.sax.SAXException; /** <p>Implements some basic tests for the Schema generator.</p> @@ -1030,48 +1031,84 @@ assertEquals(new Long(1), nmtsl.getMinLength()); } - /** Test for <a href="http://issues.apache.org/jira/browse/JAXME-45">JAXME-45</a> - */ - public void testJira46() throws Exception { - final String uri = "http://www.cnipa.it/schemas/2003/eGovIT/Busta1_0/"; - final String schemaSpec = - "<xs:schema targetNamespace='" + uri + "'\n" + - " xmlns:eGov_IT='" + uri + "'\n" + - " xmlns:xs='http://www.w3.org/2001/XMLSchema'>\n" + - " <xs:element name='Riferimento'>\n" + - " <xs:complexType>\n" + - " <xs:sequence/>\n" + - " <xs:attribute ref='eGov_IT:id' use='required'/>\n" + - " </xs:complexType>\n" + - " </xs:element>\n" + - " <xs:attribute name='id' type='xs:ID'/>\n" + - "</xs:schema>\n"; - - InputSource isource = new InputSource(new StringReader(schemaSpec)); - isource.setSystemId("jira46.xsd"); - JAXBSchemaReader r = getSchemaReader(); - XSParser parser = r.getSGFactory().newXSParser(); - parser.setValidating(false); - XSSchema schema = parser.parse(isource); - XSAttribute[] attrs = schema.getAttributes(); - assertEquals(1, attrs.length); - XSAttribute idAttr = attrs[0]; - assertTrue(idAttr instanceof JAXBAttribute); - assertEquals(new XsQName(uri, "id"), idAttr.getName()); - assertEquals(XSID.getInstance(), idAttr.getType()); - assertTrue(idAttr.isOptional()); - XSElement[] elements = schema.getElements(); - assertEquals(1, elements.length); - XSElement rifElem = elements[0]; - assertFalse(rifElem.getType().isSimple()); - XSComplexType ct = rifElem.getType().getComplexType(); - XSAttributable[] rifAttrs = ct.getAttributes(); - assertEquals(1, rifAttrs.length); - XSAttribute idRef = (XSAttribute) rifAttrs[0]; - assertTrue(idRef instanceof JAXBAttribute); - assertFalse(idRef.equals(idAttr)); - assertEquals(new XsQName(uri, "id"), idAttr.getName()); - assertEquals(XSID.getInstance(), idAttr.getType()); - assertFalse(idRef.isOptional()); - } + /** Test for <a href="http://issues.apache.org/jira/browse/JAXME-46">JAXME-46</a> + */ + public void testJira46() throws Exception { + final String uri = "http://www.cnipa.it/schemas/2003/eGovIT/Busta1_0/"; + final String schemaSpec = + "<xs:schema targetNamespace='" + uri + "'\n" + + " xmlns:eGov_IT='" + uri + "'\n" + + " xmlns:xs='http://www.w3.org/2001/XMLSchema'>\n" + + " <xs:element name='Riferimento'>\n" + + " <xs:complexType>\n" + + " <xs:sequence/>\n" + + " <xs:attribute ref='eGov_IT:id' use='required'/>\n" + + " </xs:complexType>\n" + + " </xs:element>\n" + + " <xs:attribute name='id' type='xs:ID'/>\n" + + "</xs:schema>\n"; + + InputSource isource = new InputSource(new StringReader(schemaSpec)); + isource.setSystemId("jira46.xsd"); + JAXBSchemaReader r = getSchemaReader(); + XSParser parser = r.getSGFactory().newXSParser(); + parser.setValidating(false); + XSSchema schema = parser.parse(isource); + XSAttribute[] attrs = schema.getAttributes(); + assertEquals(1, attrs.length); + XSAttribute idAttr = attrs[0]; + assertTrue(idAttr instanceof JAXBAttribute); + assertEquals(new XsQName(uri, "id"), idAttr.getName()); + assertEquals(XSID.getInstance(), idAttr.getType()); + assertTrue(idAttr.isOptional()); + XSElement[] elements = schema.getElements(); + assertEquals(1, elements.length); + XSElement rifElem = elements[0]; + assertFalse(rifElem.getType().isSimple()); + XSComplexType ct = rifElem.getType().getComplexType(); + XSAttributable[] rifAttrs = ct.getAttributes(); + assertEquals(1, rifAttrs.length); + XSAttribute idRef = (XSAttribute) rifAttrs[0]; + assertTrue(idRef instanceof JAXBAttribute); + assertFalse(idRef.equals(idAttr)); + assertEquals(new XsQName(uri, "id"), idAttr.getName()); + assertEquals(XSID.getInstance(), idAttr.getType()); + assertFalse(idRef.isOptional()); + } + + /** Test, whether a choice group with multiplicity > 1 is + * rejected. + */ + public void testMultipleGroupRejected() throws Exception { + final String schemaSpec = + "<xs:schema\n" + + " xmlns:xs='http://www.w3.org/2001/XMLSchema'\n" + + " elementFormDefault='qualified'\n" + + " xmlns:jaxb='http://java.sun.com/xml/ns/jaxb'\n" + + " jaxb:version='1.0'>\n" + + " <xs:annotation><xs:appinfo>\n" + + " <jaxb:schemaBindings xmlns:jaxb='" + JAXBParser.JAXB_SCHEMA_URI + "'>\n" + + " <jaxb:package name='parsertest.testmultiplegroupsrejected'/>\n" + + " </jaxb:schemaBindings>\n" + + " </xs:appinfo></xs:annotation>\n" + + " <xs:element name='DIAGJOBS'>\n" + + " <xs:complexType>\n" + + " <xs:choice maxOccurs='unbounded'>\n" + + " <xs:element name='DIAGJOB' type='xs:string'/>\n" + + " <xs:sequence>\n" + + " <xs:element name='DJREF' type='xs:long'/>\n" + + " <xs:element name='DESCRIPTIONS' type='xs:string' minOccurs='0'/>\n" + + " </xs:sequence>\n" + + " </xs:choice>\n" + + " </xs:complexType>\n" + + " </xs:element>\n" + + "</xs:schema>\n"; + SchemaSG schema = parse(schemaSpec, "testMultipleGroupRejected.xsd"); + try { + schema.generate(); + fail("Expected an exception"); + } catch (SAXException e) { + assertTrue(e.getMessage().indexOf("Model groups with maxOccurs > 1 are not yet supported.") != -1); + } + } }
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]