Package org.apache.ws.jaxme.xs

Examples of org.apache.ws.jaxme.xs.XSGroup


    private final XsEChoice choice;

    public XSChoiceComplexTypeImpl(XSType pOwner, XsTComplexType pType, XsEChoice pChoice) throws SAXException {
      super(pOwner, pType);
      choice = pChoice;
      XSGroup group = pOwner.getXSSchema().getXSObjectFactory().newXSGroup(pOwner, choice);
      group.validate();
      XSParticleImpl particle = new XSParticleImpl(group);
      if (group.getParticles().length == 0) {
        throw new LocSAXException("The complex type must not have an empty element group, as it is a choice.",
                                     choice.getLocator());
      } else {
        setParticle(pType.isMixed() ? XsComplexContentType.MIXED : XsComplexContentType.ELEMENT_ONLY, particle);
      }
View Full Code Here


    private final XsTAll all;

    public XSAllComplexTypeImpl(XSType pOwner, XsTComplexType pType, XsTAll pAll) throws SAXException {
      super(pOwner, pType);
      all = pAll;
      XSGroup group = pOwner.getXSSchema().getXSObjectFactory().newXSGroup(pOwner, all);
      group.validate();
      XSParticleImpl particle = new XSParticleImpl(group);
      if (group.getParticles().length == 0) {
        setParticle(XsComplexContentType.EMPTY, particle);
      } else {
        setParticle(pType.isMixed() ? XsComplexContentType.MIXED : XsComplexContentType.ELEMENT_ONLY, particle);
      }
    }
View Full Code Here

      JAXBClass jaxbClass = a.getJAXBClass();
      assertNotNull(jaxbClass);
      assertEquals("b", jaxbClass.getName());
      assertEquals("com.b.c", jaxbClass.getImplClass());
      XSParticle p1 = assertComplexContent(assertComplexType(a));
      XSGroup group = assertGroup(p1);
      XSParticle[] particles = group.getParticles();
      assertEquals(2, particles.length);
      JAXBElement f = (JAXBElement) assertElement(particles[1]);
      jaxbClass = f.getJAXBClass();
      assertNotNull(jaxbClass);
      assertEquals("x", jaxbClass.getName());
      assertNull(jaxbClass.getImplClass());


      JAXBElement g = (JAXBElement) schema.getElement(new XsQName((String) null, "g"));
      assertNotNull(g);
      assertNull(g.getJAXBClass());

      JAXBGroup m = (JAXBGroup) schema.getGroup(new XsQName((String) null, "m"));
      jaxbClass = m.getJAXBClass();
      assertNotNull(jaxbClass);
      assertEquals("k", jaxbClass.getName());
      assertEquals("com.b.i", jaxbClass.getImplClass());
    }

    {
      final String schemaSource =
        "<?xml version='1.0'?>\n" +
        "<xs:schema xmlns:xs='http://www.w3.org/2001/XMLSchema'" +
        "           xmlns:jaxb='" + JAXBParser.JAXB_SCHEMA_URI + "'>\n" +
        "  <xs:complexType name='d'>\n" +
        "    <xs:sequence>\n" +
        "      <xs:element name='e'>\n" +
        "        <xs:complexType name='a'>\n" +
        "          <xs:annotation>\n" +
        "            <xs:appinfo>\n" +
        "              <jaxb:class name='b'/>\n" +
        "            </xs:appinfo>\n" +
        "          </xs:annotation>\n" +
        "          <xs:sequence>\n" +
        "            <xs:element name='x' type='xs:int'/>\n" +
        "          </xs:sequence>\n" +
        "          <xs:attribute name='y' type='xs:string'/>\n" +
        "        </xs:complexType>\n" +
        "      </xs:element>\n" +
        "      <xs:element name='f' type='xs:string'>\n" +
        "        <xs:annotation>\n" +
        "          <xs:appinfo>\n" +
        "            <jaxb:class name='x'/>\n" +
        "          </xs:appinfo>\n" +
        "        </xs:annotation>\n" +
        "      </xs:element>\n" +
        "      <xs:element name='g' type='xs:string'/>\n" +
        "    </xs:sequence>\n" +
        "  </xs:complexType>\n" +
        "</xs:schema>";
 
      JAXBParser parser = newJAXBParser();
      InputSource isource = new InputSource(new StringReader(schemaSource));
      isource.setSystemId("testJAXBClass2.xsd");
      JAXBSchema schema = (JAXBSchema) parser.parse(isource);
      JAXBType d = (JAXBType) schema.getType(new XsQName((String) null, "d"));
      assertNotNull(d);
      XSGroup dGroup = assertGroup(assertComplexContent(assertComplexType(d)));
      assertSequence(dGroup);
      XSParticle[] particles = dGroup.getParticles();
      assertEquals(3, particles.length);
      JAXBElement e = (JAXBElement) assertElement(particles[0]);
      JAXBType a = (JAXBType) e.getType();
      JAXBClass jaxbClass = a.getJAXBClass();
      assertNotNull(jaxbClass);
View Full Code Here

    checkJAXBTypesafeEnumClass1BType(b);

    XSElement[] elements = schema.getElements();
    assertEquals(1, elements.length);
    XSElement allTypesElement = elements[0];
    XSGroup allTypesGroup = assertGroup(assertComplexContent(assertComplexType(allTypesElement.getType())));
    assertSequence(allTypesGroup);
    XSParticle[] allTypesChilds = allTypesGroup.getParticles();
    assertEquals(2, allTypesChilds.length);
    checkJAXBTypesafeEnumClass1AType(assertElement(allTypesChilds[0]).getType());
    checkJAXBTypesafeEnumClass1BType(assertElement(allTypesChilds[1]).getType());   
  }
View Full Code Here

    XSElement[] elements = schema.getElements();
    assertEquals(1, elements.length);

    XSElement allTypesElement = elements[0];
    XSParticle allTypesElementParticle = assertComplexContent(assertComplexType(allTypesElement.getType()));
    XSGroup group = allTypesElementParticle.getGroup();
    assertSequence(group);
    XSParticle[] allTypesElementsChilds = group.getParticles();
    assertEquals(1, allTypesElementsChilds.length);
    XSElement allSimpleTypesElement = assertElement(allTypesElementsChilds[0]);
    XSParticle allSimpleTypesElementParticle = assertComplexContent(assertComplexType(allSimpleTypesElement.getType()));
    XSGroup allSimpleTypesElementGroup = allSimpleTypesElementParticle.getGroup();
    assertSequence(allSimpleTypesElementGroup);
    XSParticle[] allSimpleTypesElementChilds = allSimpleTypesElementGroup.getParticles();
    assertEquals(9, allSimpleTypesElementChilds.length);

    XSElement stringTypeElement = assertElement(allSimpleTypesElementChilds[0]);
    checkJAXBTypesafeEnumClass2StringType(stringTypeElement.getType());
  }
View Full Code Here

    XSElement e3 = (XSElement) elements[2];
    assertEquals(new XsQName((String) null, "c"), e3.getName());
    XSComplexType ct3 = assertComplexType(e3.getType());
    XSParticle p3 = assertComplexContent(ct3);
    XSGroup g3 = assertGroup(p3);
    XSParticle[] particles3 = g3.getParticles();
    assertEquals(2, particles3.length);
    XSElement e3_1 = assertElement(particles3[0]);
    assertEquals(new XsQName((String) null, "a"), e3_1.getName());
    assertEquals(e1.getType(), e3_1.getType());
    XSParticle p3_2 = particles3[1];
View Full Code Here

    XSType items = schemaTypes[2];
    assertEquals(new XsQName((String) null, "Items"), items.getName());
    assertTrue(items.isGlobal());
    XSComplexType itemsComplexType = assertComplexType(items);
    XSParticle itemsParticle = assertComplexContent(itemsComplexType);
    XSGroup itemsGroup = assertGroup(itemsParticle);
    assertSequence(itemsGroup);
    // Items.item
    XSParticle[] itemsChildren = itemsGroup.getParticles();
    assertEquals(1, itemsChildren.length);
    XSParticle item = itemsChildren[0];
    XSElement itemElement = assertElement(item);
    assertEquals(new XsQName((String) null, "item"), itemElement.getName());
    assertTrue(!itemElement.isGlobal());
    XSComplexType itemComplexType = assertComplexType(itemElement.getType());
    assertEquals(0, item.getMinOccurs());
    assertEquals(-1, item.getMaxOccurs());
    XSParticle itemParticle = assertComplexContent(itemComplexType);
    XSGroup itemGroup = assertGroup(itemParticle);
    assertSequence(itemGroup);
    // Items.item.partNum
    // <xsd:attribute name='partNum' type='SKU' use='required'/>
    XSAttributable[] itemAttributes = itemComplexType.getAttributes();
    assertEquals(1, itemAttributes.length);
    XSAttribute partNum = (XSAttribute) itemAttributes[0];
    assertEquals(new XsQName((String) null, "partNum"), partNum.getName());
    assertTrue(!partNum.isOptional());
    XSType partNumType = partNum.getType();
    assertEquals(new XsQName((String) null, "SKU"), partNumType.getName());
    assertTrue(partNumType.isGlobal());

    XSParticle[] itemGroupParticles = itemGroup.getParticles();
    assertEquals(5, itemGroupParticles.length);

    // Items.item.productName
    // <xsd:element name='productName' type='xsd:string'/>
    XSParticle productName = itemGroupParticles[0];
    assertEquals(1, productName.getMinOccurs());
    assertEquals(1, productName.getMaxOccurs());
    XSElement productNameElement = assertElement(productName);
    assertEquals(new XsQName((String) null, "productName"), productNameElement.getName());
    assertSimpleType(productNameElement.getType());
    assertEquals(XSString.getInstance(), productNameElement.getType());

    // Items.item.quantity
    XSParticle quantity = itemGroupParticles[1];
    assertEquals(1, quantity.getMinOccurs());
    assertEquals(1, quantity.getMaxOccurs());
    XSElement quantityElement = assertElement(quantity);
    assertEquals(new XsQName((String) null, "quantity"), quantityElement.getName());
    XSSimpleType quantitySimpleType = assertSimpleType(quantityElement.getType());
    assertEquals(XSPositiveInteger.getInstance(), assertRestriction(quantitySimpleType));

    // Items.item.USPrice
    // <xsd:element name='USPrice'  type='xsd:decimal'/>
    XSParticle usPrice = itemGroupParticles[2];
    assertEquals(1, usPrice.getMinOccurs());
    assertEquals(1, usPrice.getMaxOccurs());
    XSElement usPriceElement = assertElement(usPrice);
    assertEquals(new XsQName((String) null, "USPrice"), usPriceElement.getName());
    assertEquals(XSDecimal.getInstance(), usPriceElement.getType());

    // Items.item.comment
    // <xsd:element ref='comment'   minOccurs='0'/>
    XSParticle comment = itemGroupParticles[3];
    assertEquals(comment.getMinOccurs(), 0);
    assertEquals(comment.getMaxOccurs(), 1);
    XSElement commentElement = assertElement(comment);
    assertEquals(new XsQName((String) null, "comment"), commentElement.getName());
    assertEquals(XSString.getInstance(), commentElement.getType());

    // Items.item.shipDate
    // <xsd:element name='shipDate' type='xsd:date' minOccurs='0'/>
    XSParticle shipDate = itemGroupParticles[4];
    assertEquals(shipDate.getMinOccurs(), 0);
    assertEquals(shipDate.getMaxOccurs(), 1);
    XSElement shipDateElement = assertElement(shipDate);
    assertEquals(XSDate.getInstance(), shipDateElement.getType());

    // PurchaseOrderType
    XSType purchaseOrderType = schemaTypes[0];
    assertTrue(purchaseOrderType.isGlobal());
    assertEquals(new XsQName((String) null, "PurchaseOrderType"), purchaseOrderType.getName());
    XSComplexType purchaseOrderTypeComplexType = assertComplexType(purchaseOrderType);
    XSParticle purchaseOrderTypeParticle = assertComplexContent(purchaseOrderTypeComplexType);
    XSGroup purchaseOrderTypeGroup = assertGroup(purchaseOrderTypeParticle);
    assertSequence(purchaseOrderTypeGroup);

    XSAttributable[] potAttributes = purchaseOrderTypeComplexType.getAttributes();
    assertEquals(1, potAttributes.length);
    // PurchaseOrderType.orderDate
    // <xsd:attribute name='orderDate' type='xsd:date'/>
    XSAttribute orderDate = (XSAttribute) potAttributes[0];
    assertEquals(new XsQName((String) null, "orderDate"), orderDate.getName());
    assertEquals(XSDate.getInstance(), orderDate.getType());

    XSParticle[] potChildren = purchaseOrderTypeGroup.getParticles();
    assertEquals(4, potChildren.length);
    // PurchaseOrderType.shipTo
    // <xsd:element name='shipTo' type='USAddress'/>
    XSParticle shipTo = potChildren[0];
    assertEquals(1, shipTo.getMinOccurs());
    assertEquals(1, shipTo.getMaxOccurs());
    XSElement shipToElement = assertElement(shipTo);
    assertEquals(new XsQName((String) null, "shipTo"), shipToElement.getName());
    XSType shipToType = shipToElement.getType();
    assertTrue(shipToType.isGlobal());
    assertEquals(new XsQName((String) null, "USAddress"), shipToType.getName());
    // PurchaseOrderType.billTo
    // <xsd:element name='billTo' type='USAddress'/>
    XSParticle billTo = potChildren[1];
    assertEquals(1, billTo.getMinOccurs());
    assertEquals(1, billTo.getMaxOccurs());
    XSElement billToElement = assertElement(billTo);
    assertEquals(new XsQName((String) null, "billTo"), billToElement.getName());
    XSType billToType = billToElement.getType();
    assertEquals(shipToType, billToType);
    // PurchaseOrderType.comment
    // <xsd:element ref='comment' minOccurs='0'/>
    XSParticle potComment = potChildren[2];
    assertEquals(0, potComment.getMinOccurs());
    assertEquals(1, potComment.getMaxOccurs());
    XSElement potCommentElement = assertElement(potComment);
    assertEquals(new XsQName((String) null, "comment"), potCommentElement.getName());
    assertEquals(potCommentElement.getType(), commentElement.getType());
    // PurchaseOrderType.items
    // <xsd:element name='items'  type='Items'/>
    XSParticle potItems = potChildren[3];
    assertEquals(1, potItems.getMinOccurs());
    assertEquals(1, potItems.getMaxOccurs());
    XSElement potItemsElement = assertElement(potItems);
    assertEquals(new XsQName((String) null, "items"), potItemsElement.getName());
    assertEquals(items, potItemsElement.getType());

    // SKU
    XSType sku = schemaTypes[3];
    assertTrue(sku.isGlobal());
    assertEquals(new XsQName((String) null, "SKU"), sku.getName());
    XSSimpleType skuSimpleType = assertSimpleType(sku);
    assertEquals(XSString.getInstance(), assertRestriction(skuSimpleType));
    assertEquals(sku, partNumType);
    // TODO: test restriction pattern

    // USAddress
    // <xsd:complexType name='USAddress'>
    // <xsd:sequence>
    XSType usAddress = schemaTypes[1];
    assertTrue(usAddress.isGlobal());
    assertEquals(new XsQName((String) null, "USAddress"), usAddress.getName());
    assertTrue(usAddress.isGlobal());
    XSComplexType usAddressComplexType = assertComplexType(usAddress);
    XSParticle usAddressParticle = assertComplexContent(usAddressComplexType);
    XSGroup usAddressGroup = assertGroup(usAddressParticle);
    assertSequence(usAddressGroup);
    // USAddress.country
    //  <xsd:attribute name='country' type='xsd:string' fixed='US'/>
    // ToDo: test attribute fixed='US'
    XSAttributable[] usAddressAttributes = usAddressComplexType.getAttributes();
    assertEquals(1, usAddressAttributes.length);
    XSAttribute country = (XSAttribute) usAddressAttributes[0];
    assertEquals(new XsQName((String) null, "country"), country.getName());
    assertEquals(XSNMToken.getInstance(), country.getType());
    // USAddress children
    String [] nameShouldBe = {"name", "street", "city", "state", "zip"};
    XSParticle[] usAddressChildren = usAddressGroup.getParticles();
    assertEquals(5, usAddressChildren.length);
    for (int i = 0; i < usAddressChildren.length; i++) {
      XSParticle child = usAddressChildren[i];
      assertEquals(1, child.getMinOccurs());
      assertEquals(1, child.getMaxOccurs());
View Full Code Here

  public GroupSG getGroup(SchemaSG pController, XsQName pName) throws SAXException {
    GroupSG groupSG = (GroupSG) groupsByName.get(pName);
    if (groupSG != null) {
      return groupSG;
    }
    XSGroup group = getXSSchema().getGroup(pName);
    if (group == null) {
      return null;
    }
    groupSG = pController.getFactory().getGroupSG(group);
    groupsByName.put(pName, groupSG);
View Full Code Here

    assertEquals(1, types.length);
    XSComplexType complexType = assertComplexType(types[0]);
    XSAttributable[] typeAttributes = complexType.getAttributes();
    assertEquals(1, typeAttributes.length);
    assertEquals(pQualified ? barQualified : barUnQualified, ((XSAttribute) typeAttributes[0]).getName());
    XSGroup group = assertGroup(assertComplexContent(complexType));
    XSParticle[] particles = group.getParticles();
    assertEquals(1, particles.length);
    XSElement typeElement = assertElement(particles[0]);
    assertEquals(pQualified ? fooQualified : fooUnQualified, typeElement.getName());
  }
View Full Code Here

    assertNull(elements[2].getSubstitutionGroup());
    assertEquals(headName, elements[2].getSubstitutionGroupName());

    XSType[] types = schema.getTypes();
    assertEquals(1, types.length);
    XSGroup group = assertGroup(assertComplexContent(assertComplexType(types[0])));
    XSParticle[] particles = group.getParticles();
    assertEquals(1, particles.length);
    XSGroup substitutedGroup = assertGroup(particles[0]);
    assertEquals(XSModelGroup.CHOICE, substitutedGroup.getCompositor());
    XSParticle[] substParticles = substitutedGroup.getParticles();
    assertEquals(3, substParticles.length);
    assertEquals(headName, assertElement(substParticles[0]).getName());
    assertEquals(subst1Name, assertElement(substParticles[1]).getName());
    assertEquals(subst2Name, assertElement(substParticles[2]).getName());
  }
View Full Code Here

TOP

Related Classes of org.apache.ws.jaxme.xs.XSGroup

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.