Examples of XSType


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

  protected XSSimpleContentType assertSimpleContent(XSComplexType pType) {
    assertTrue(pType.hasSimpleContent());
    XSSimpleContentType result = pType.getSimpleContent();
    assertNotNull(result);
    XSType resultType = result.getType();
    assertNotNull(resultType);
    assertTrue(resultType.isSimple());
    boolean haveException = false;
    try {
      pType.getComplexContentType();
    } catch (IllegalStateException e) {
      haveException = true;
View Full Code Here

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

      XSAnnotation result = getXSSchema().getXSObjectFactory().newXSAnnotation(this, xsAnnotation);
      result.validate();
      annotations = new XSAnnotation[]{result};
    }

    XSType myType;
    if (isReference()) {
      XSElement element = getXSSchema().getElement(getName());
      if (element == null) {
        throw new LocSAXException("Invalid element reference: " + getName() + " is not defined.",
                                     getLocator());
      }
      element.validate();
      myType = element.getType();
    } else {
      XsTElement element = getXsTElement();
      if (isInnerSimpleType()) {
        myType = getXSSchema().getXSObjectFactory().newXSType(this, element.getSimpleType());
      } else if (isInnerComplexType()) {
        myType = getXSSchema().getXSObjectFactory().newXSType(this, element.getComplexType());
      } else {
        XsQName typeName = element.getType();
        if (typeName == null) {
          throw new LocSAXException("Invalid element: Either of its 'type' or 'ref' attributes or its 'simpleType' or 'complexType' children must be set.",
                                       getLocator());
        }
        myType = getXSSchema().getType(typeName);
        if (myType == null) {
          throw new LocSAXException("Invalid element: The type " + typeName + " is not defined.",
                                       getLocator());
        }
      }
    }
    this.type = myType;
    myType.validate();
  }
View Full Code Here

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

    XSSchema schema = pParser.parse(isource);

    XSType[] types = schema.getTypes();
    assertEquals(3, types.length);

    XSType t1 = types[0];
    assertEquals(new XsQName((String) null, "a"), t1.getName());
    XSSimpleType st1 = assertSimpleType(t1);
    assertAtomicType(st1);
    XSType t1_1 = assertRestriction(st1);
    assertEquals(XSString.getInstance(), t1_1);

    XSType t2 = types[1];
    assertEquals(new XsQName((String) null, "b"), t2.getName());
    XSSimpleType st2 = assertSimpleType(t2);
    XSListType lt = assertListType(st2);
    XSType it = lt.getItemType();
    assertNotNull(it);
    assertEquals(XSInt.getInstance(), it);
    XSSimpleType it2 = assertSimpleType(it);
    assertAtomicType(it2);

    XSType t3 = types[2];
    assertEquals(new XsQName((String) null, "c"), t3.getName());
    XSSimpleType st3 = assertSimpleType(t3);
    XSUnionType ut3 = assertUnionType(st3);
    XSType[] memberTypes = ut3.getMemberTypes();
    assertEquals(2, memberTypes.length);
    XSType mt3_1 = memberTypes[0];
    assertEquals(mt3_1, t1);
    XSType mt3_2 = memberTypes[1];
    assertEquals(mt3_2, t2);
  }
View Full Code Here

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

    assertEquals(3, attr.length);

    XSAttribute attr1 = (XSAttribute) attr[0];
    assertTrue(attr1.isGlobal());
    assertEquals(new XsQName((String) null, "a"), attr1.getName());
    XSType t1 = attr1.getType();
    assertEquals(XSString.getInstance(), t1);
    XSSimpleType st1 = assertSimpleType(attr1.getType());
    assertAtomicType(st1);

    XSAttribute attr2 = (XSAttribute) attr[1];
    assertTrue(attr2.isGlobal());
    assertEquals(new XsQName((String) null, "b"), attr2.getName());
    XSType t2 = attr2.getType();
    assertTrue(!XSInt.getInstance().equals(t2));
    XSType t2_1 = assertRestriction(assertSimpleType(t2));
    assertEquals(XSInt.getInstance(), t2_1);
    XSSimpleType st2 = assertSimpleType(t2);
    assertAtomicType(st2);

    XSAttribute attr3 = (XSAttribute) attr[2];
    assertTrue(attr3.isGlobal());
    assertEquals(new XsQName((String) null, "c"), attr3.getName());
    XSType t3 = attr3.getType();
    assertEquals(XSInt.getInstance(), t3);
    XSSimpleType st3 = assertSimpleType(t3);
    assertAtomicType(st3);
  }
View Full Code Here

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

    XSObject[] elements = schema.getElements();
    assertEquals(4, elements.length);

    XSElement e1 = (XSElement) elements[0];
    assertEquals(new XsQName((String) null, "a"), e1.getName());
    XSType t1 = e1.getType();
    assertEquals(XSString.getInstance(), t1);

    XSElement e2 = (XSElement) elements[1];
    assertEquals(new XsQName((String) null, "b"), e2.getName());
    XSType t2 = e2.getType();
    assertEquals(XSFloat.getInstance(), assertRestriction(assertSimpleType(t2)));

    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];
    assertEquals(0, p3_2.getMinOccurs());
    XSElement e3_2 = assertElement(p3_2);
    assertEquals(new XsQName((String) null, "d"), e3_2.getName());
    assertEquals(XSDouble.getInstance(), e3_2.getType());
    XSAttributable[] a3 = ct3.getAttributes();
    assertEquals(1, a3.length);
    XSAttribute a3_1 = (XSAttribute) a3[0];
    assertEquals(new XsQName((String) null, "e"), a3_1.getName());
    assertEquals(XSInt.getInstance(), a3_1.getType());

    XSElement e4 = (XSElement) elements[3];
    assertEquals(new XsQName((String) null, "f"), e4.getName());
    XSComplexType ct4 = assertComplexType(e4.getType());
    XSType t4 = assertSimpleContent(ct4).getType();
    assertSimpleType(t4);
    assertEquals(XSInt.getInstance(), t4);
    XSAttributable[] a4 = ct4.getAttributes();
    assertEquals(1, a4.length);
    XSAttribute a4_1 = (XSAttribute) a4[0];
View Full Code Here

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

    XSType[] schemaTypes = schema.getTypes();
    assertNotNull(schemaTypes);
    assertEquals(4, schemaTypes.length);

    // Items
    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
View Full Code Here

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

    XSParser xsParser = newXSParser();
    XSSchema schema = xsParser.parse(isource);

    XSType[] types = schema.getTypes();
    assertEquals(2, types.length);
    XSType a = types[0];
    assertEquals(new XsQName((String) null, "a"), a.getName());
    XSComplexType aComplexType = assertComplexType(a);
    XSAttributable[] aAttributes = aComplexType.getAttributes();
    assertEquals(1, aAttributes.length);
    XSAttribute aa1 = (XSAttribute) aAttributes[0];

    XSType b = types[1];
    assertEquals(new XsQName((String) null, "b"), b.getName());
    XSComplexType bComplexType = assertComplexType(b);
    assertTrue(bComplexType.isExtension());
    assertEquals(bComplexType.getExtendedType(), a);
    XSAttributable[] bAttributes = bComplexType.getAttributes();
    assertEquals(2, bAttributes.length);
View Full Code Here

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

    XsQName myName = pRestriction.getBase();
    if (myName == null) {
      throw new LocSAXException("Invalid 'restriction': Missing 'base' attribute.",
                                   pRestriction.getLocator());
    }
    XSType type = getXSSchema().getType(myName);
    if (type == null) {
      throw new LocSAXException("Invalid 'restriction': Unknown 'base' type " + myName,
                                   pRestriction.getLocator());
    }
    type.validate();
    if (type.isSimple()) {
      throw new LocSAXException("The 'base' type " + myName + " of 'simpleContent/restriction' is simple." +
                                   " It ought to be a complex type with simple content: ",
                                   pRestriction.getLocator());
    }
    XSComplexType myComplexType = type.getComplexType();
    if (!myComplexType.hasSimpleContent()) {
      throw new LocSAXException("The 'base' type " + myName + " of 'simpleContent/restriction' is complex," +
                                   " but doesn't have simple content: ", pRestriction.getLocator());
    }
    if (myComplexType.isExtension()) {
      XSType extendedType = myComplexType.getSimpleContent().getType();
      extendedType.validate();
      simpleType = extendedType.getSimpleType();
    } else {
      XsTLocalSimpleType localSimpleType = pRestriction.getSimpleType();
      XSObjectFactory factory = pParent.getXSSchema().getXSObjectFactory();
      XSType restrictedType;
      if (localSimpleType != null) {
        restrictedType = factory.newXSType(this, localSimpleType);
      } else {
        restrictedType = myComplexType.getSimpleContent().getType();
      }
      restrictedType.validate();
      XSSimpleType restrictedSimpleType = restrictedType.getSimpleType();
      if (restrictedSimpleType.isAtomic()) {
        simpleType = factory.newXSAtomicType(this, restrictedType, pRestriction);
      } else if (restrictedSimpleType.isList()) {
        simpleType = factory.newXSListType(this, restrictedType, pRestriction);
      } else if (restrictedSimpleType.isUnion()) {
View Full Code Here

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

          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()) {
View Full Code Here

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

                                     restriction.getLocator());
        }
        restrictedType.validate();
        extendedType = null;
        XSObjectFactory factory = pOwner.getXSSchema().getXSObjectFactory();
        XSType contentType = factory.newXSType(pOwner, restriction);
        simpleContentType = factory.newXSSimpleContentType(pOwner, contentType, restriction);
        attributes = XSAttributeGroupImpl.getAttributes(XSTypeImpl.this, restriction);
      } else {
        XsQName extendedTypesName = extension.getBase();
        if (extendedTypesName == null) {
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.