Package org.apache.ws.jaxme.xs.xml

Examples of org.apache.ws.jaxme.xs.xml.XsQName


    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];
View Full Code Here


    XSAttributable[] attr = schema.getAttributes();
    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

    XSAttributeGroup[] groups = schema.getAttributeGroups();
    assertNotNull(groups);
    assertEquals(2, groups.length);

    XSAttributeGroup ag1 = groups[0];
    assertEquals(new XsQName((String) null, "c"), ag1.getName());
    XSAttributable[] attr1 = ag1.getAttributes();
    assertEquals(3, attr1.length);
    XSAttribute attr1_1 = (XSAttribute) attr1[0];
    assertEquals(new XsQName((String) null, "d"), attr1_1.getName());
    assertEquals(XSDateTime.getInstance(), attr1_1.getType());
    XSAttribute attr1_2 = (XSAttribute) attr1[1];
    assertEquals(new XsQName((String) null, "e"), attr1_2.getName());
    assertEquals(XSFloat.getInstance(), attr1_2.getType());
    XSAttribute attr1_3 = (XSAttribute) attr1[2];
    assertEquals(new XsQName((String) null, "a"), attr1_3.getName());
    assertEquals(XSString.getInstance(), attr1_3.getType());

    XSAttributeGroup ag2 = groups[1];
    assertEquals(new XsQName((String) null, "f"), ag2.getName());
    XSAttributable[] attr2 = ag2.getAttributes();
    assertEquals(5, attr2.length);
    XSAttribute attr2_1 = (XSAttribute) attr2[0];
    assertEquals(new XsQName((String) null, "g"), attr2_1.getName());
    assertEquals(XSDouble.getInstance(), attr2_1.getType());
    XSAttribute attr2_2 = (XSAttribute) attr2[1];
    assertEquals(new XsQName((String) null, "d"), attr2_2.getName());
    assertEquals(XSDateTime.getInstance(), attr2_2.getType());
    XSAttribute attr2_3 = (XSAttribute) attr2[2];
    assertEquals(new XsQName((String) null, "e"), attr2_3.getName());
    assertEquals(XSFloat.getInstance(), attr2_3.getType());
    XSAttribute attr2_4 = (XSAttribute) attr2[3];
    assertEquals(new XsQName((String) null, "a"), attr2_4.getName());
    assertEquals(XSString.getInstance(), attr2_4.getType());
    XSAttribute attr2_5 = (XSAttribute) attr2[4];
    assertEquals(new XsQName((String) null, "b"), attr2_5.getName());
    assertEquals(XSInt.getInstance(), attr2_5.getType());
  }
View Full Code Here

    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];
    assertEquals(new XsQName((String) null, "g"), a4_1.getName());
    assertEquals(XSBoolean.getInstance(), a4_1.getType());
  }
View Full Code Here

    XSSchema schema = pParser.parse(isource);

    XSElement[] elements = schema.getElements();
    assertEquals(1, elements.length);
    XSElement e1 = elements[0];
    assertEquals(new XsQName((String) null, "a"), e1.getName());
    XSSimpleType st1 = assertSimpleType(e1.getType());
    assertEquals(XSString.getInstance(), assertRestriction(st1));
    XSEnumeration[] enumerations = st1.getEnumerations();
    assertNotNull(enumerations);
    assertEquals(3, enumerations.length);
View Full Code Here

    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
    //  <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());
      XSElement element = assertElement(child);
      assertEquals(new XsQName((String) null, nameShouldBe[i]), element.getName());
      assertEquals(i == 4 ? XSDecimal.getInstance() : XSString.getInstance(), element.getType());
    }

    // purchaseOrder
    // <xsd:element name='purchaseOrder' type='PurchaseOrderType'/>
    XSElement[] schemaElements = schema.getElements();
    assertEquals(2, schemaElements.length);
    XSElement purchaseOrder = schemaElements[0];
    assertEquals(new XsQName((String) null, "purchaseOrder"), purchaseOrder.getName());
    assertEquals(purchaseOrderType, purchaseOrder.getType());
    assertEquals(new XsQName((String) null, "comment"), schemaElements[1].getName());
  }
View Full Code Here

    isource.setSystemId("testRestrictionMaxExclusive.xsd");
    parser.parse(isource);
  }

  private void verifyLocalNamespaces(String pSchema, boolean pQualified) throws Exception {
    XsQName fooQualified = new XsQName("http://test.com/namespaces", "foo");
    XsQName fooUnQualified = new XsQName((String) null, "foo");
    XsQName barQualified = new XsQName("http://test.com/namespaces", "bar");
    XsQName barUnQualified = new XsQName((String) null, "bar");
   
    XSParser parser = newJAXBParser();
    InputSource isource = new InputSource(new StringReader(pSchema));
    XSSchema schema = parser.parse(isource);
    XSElement[] schemaElements = schema.getElements();
View Full Code Here

    InputSource isource = new InputSource(new StringReader(schemaSource1));
    isource.setSystemId("testTargetNamespace1.xsd");
    XSSchema schema = parser.parse(isource);
    XSElement[] schemaElements = schema.getElements();
    assertEquals(1, schemaElements.length);
    assertEquals(new XsQName("http://test.com/namespaces", "foo"), schemaElements[0].getName());
    assertNull(schemaElements[0].getName().getPrefix());

    final String schemaSource2 =
      "<xs:schema xmlns:xs='http://www.w3.org/2001/XMLSchema' xmlns:test='http://test.com/namespaces'" +
      " targetNamespace='http://test.com/namespaces'>\n" +
      "  <xs:element name='foo' type='xs:string'/>\n" +
      "</xs:schema>\n";

    parser = newJAXBParser();
    isource = new InputSource(new StringReader(schemaSource2));
    isource.setSystemId("testTargetNamespace1.xsd");
    schema = parser.parse(isource);
    schemaElements = schema.getElements();
    assertEquals(1, schemaElements.length);
    assertEquals(new XsQName("http://test.com/namespaces", "foo"), schemaElements[0].getName());
    assertEquals("test", schemaElements[0].getName().getPrefix());

    final String namespaceSchemaHeader =
      "<xs:schema xmlns:xs='http://www.w3.org/2001/XMLSchema' xmlns:test='http://test.com/namespaces'" +
      "    targetNamespace='http://test.com/namespaces'";
View Full Code Here

    String[] parts = new String[3];
    for (StringTokenizer st = new StringTokenizer(pTypesafeEnumBase, " ,");
         st.hasMoreTokens()) {
      String token = st.nextToken();
      getNamespaceSupport().processName(token, parts, false);
      XsQName qName = new XsQName(parts[0], parts[1], XsQName.prefixOf(token));
      for (int i = 0;  i < forbiddenEnumQNames.length;  i++) {
        if (forbiddenEnumQNames[i].equals(qName)) {
          throw new LocSAXException("The type " + qName +
                                     " must not be specified in the typesafeEnumBase (JAXB 6.5.1)",
                                     getLocator());
View Full Code Here

    InputSource isource = new InputSource(new StringReader(schemaSource1));
    isource.setSystemId("testTargetNamespace1.xsd");
    XSSchema schema = parser.parse(isource);
    XSElement[] elements = schema.getElements();
    assertEquals(3, elements.length);
    XsQName headName = new XsQName("http://test.com/namespaces", "head");
    XsQName subst1Name = new XsQName("http://test.com/namespaces", "subst1");
    XsQName subst2Name = new XsQName("http://test.com/namespaces", "subst2");
    assertEquals(headName, elements[0].getName());
    assertNotNull(elements[0].getSubstitutionGroup());
    assertNull(elements[0].getSubstitutionGroupName());
    assertEquals(subst1Name, elements[1].getName());
    assertNull(elements[1].getSubstitutionGroup());
View Full Code Here

TOP

Related Classes of org.apache.ws.jaxme.xs.xml.XsQName

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.