1 17 package org.apache.ws.jaxme.xs.junit; 18 import java.io.File ; 19 import java.io.FileInputStream ; 20 21 import junit.framework.TestCase; 22 23 import org.apache.ws.jaxme.xs.XSComplexType; 24 import org.apache.ws.jaxme.xs.XSElement; 25 import org.apache.ws.jaxme.xs.XSGroup; 26 import org.apache.ws.jaxme.xs.XSParser; 27 import org.apache.ws.jaxme.xs.XSParticle; 28 import org.apache.ws.jaxme.xs.XSSchema; 29 import org.apache.ws.jaxme.xs.XSType; 30 import org.apache.ws.jaxme.xs.xml.XsQName; 31 import org.xml.sax.InputSource ; 32 33 public class ClaesLarssonTest extends TestCase { 34 public ClaesLarssonTest(String pName) { 35 super(pName); 36 } 37 38 public void testParse() throws Exception { 39 XSParser xsp = new XSParser(); 40 xsp.setValidating(false); 41 42 String xmlFileName = "examples/xs/Claes_Larsson/schema.xsd"; 43 java.net.URL xmlSystemId = new File (xmlFileName).toURL(); 44 45 InputSource isource = new InputSource (new FileInputStream (xmlFileName)); 46 isource.setSystemId(xmlSystemId.toString()); 47 XSSchema schema = xsp.parse(isource); 48 49 XSElement[] elements = schema.getElements(); 51 assertEquals(154, elements.length); 52 53 XSElement localTransformationElement = schema.getElement(new XsQName((String ) null, "local_transformation")); 54 assertNotNull(localTransformationElement); 55 XSType localTransformationType = localTransformationElement.getType(); 56 assertTrue(!localTransformationType.isSimple()); 57 XSComplexType localTransformationComplexType = localTransformationType.getComplexType(); 58 assertTrue(!localTransformationComplexType.hasSimpleContent()); 59 XSParticle localTransformationParticle = localTransformationComplexType.getParticle(); 60 XSGroup localTransformationGroup = localTransformationParticle.getGroup(); 61 XSParticle[] particles = localTransformationGroup.getParticles(); 62 assertEquals(0, particles[0].getMinOccurs()); 63 assertEquals(1, particles[0].getMaxOccurs()); 64 } 65 } | Popular Tags |