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

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


    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

    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

    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);
    assertEquals(aa1, bAttributes[0]);
    XSAttribute ba1 = (XSAttribute) bAttributes[1];
    assertEquals(new XsQName((String) null, "ba1"), ba1.getName());
  }
View Full Code Here

        InputSource isource = new InputSource(new StringReader(schemaSource));
        isource.setSystemId("testSimpleTypeRestriction2.xsd");
        XSSchema schema = pParser.parse(isource);
        XSType[] types = schema.getTypes();
        assertEquals(2, types.length);
        assertEquals(new XsQName("http://asi.sbc.com/cpsosasos/trouble/data", "NameTypeType"),
                     types[1].getName());
        XSSimpleType nameTypeType = assertSimpleType(types[1]);
        assertUnionType(nameTypeType);
        assertEquals(new XsQName("http://asi.sbc.com/cpsosasos/trouble/data", "ServiceIDType"),
                     types[0].getName());
        XSSimpleType serviceIDType = assertSimpleType(types[0]);
        assertUnionType(serviceIDType);
        assertTrue(serviceIDType.isRestriction());
    }
View Full Code Here

        InputSource isource = new InputSource(new StringReader(schemaSource));
        isource.setSystemId("testElementReferenceGlobal.xsd");
        XSSchema schema = pParser.parse(isource);
        XSElement[] elements = schema.getElements();
        assertEquals(2, elements.length);
        assertEquals(new XsQName("http://ws.apache.org/jaxme/test/recursion", "Attribute"), elements[0].getName());
        assertTrue(elements[0].isGlobal());
        assertEquals(new XsQName("http://ws.apache.org/jaxme/test/recursion", "AttributeList"), elements[1].getName());
        assertTrue(elements[1].isGlobal());
        XSComplexType complexType = assertComplexType(elements[1].getType());
        XSParticle particle = assertComplexContent(complexType);
        XSGroup group = assertGroup(particle);
        XSParticle[] particles = group.getParticles();
View Full Code Here

      throw new IllegalStateException("Expected a simple type");
    }
    XSSimpleType simpleType = pType.getSimpleType();
    if (simpleType.isAtomic()) {
      if (pType.isGlobal()) {
        XsQName myName = pType.getName();
        if (myName.equals(XSEntity.getInstance().getName())      ||
            myName.equals(XSNotation.getInstance().getName())    ||
            myName.equals(XSGYearMonth.getInstance().getName())  ||
            myName.equals(XSGYear.getInstance().getName())       ||
            myName.equals(XSGMonthDay.getInstance().getName())   ||
            myName.equals(XSGMonth.getInstance().getName())      ||
            myName.equals(XSGDay.getInstance().getName())) {
          throw new SAXException("The type " + myName + " is not supported.");
        } else if (myName.equals(XSIDREF.getInstance().getName())) {
          return new IDREFSG(pFactory, pSchema, pType);
        } else if (myName.equals(XSID.getInstance().getName())) {
          return new IDSG(pFactory, pSchema, pType);
        } else if (myName.equals(XSByte.getInstance().getName())) {
          return new ByteSG(pFactory, pSchema, pType);
        } else if (myName.equals(XSShort.getInstance().getName())) {
          return new ShortSG(pFactory, pSchema, pType);
        } else if (myName.equals(XSInt.getInstance().getName())) {
          return new IntSG(pFactory, pSchema, pType);
        } else if (myName.equals(XSLong.getInstance().getName())) {
          return new LongSG(pFactory, pSchema, pType);
        } else if (myName.equals(XSUnsignedByte.getInstance().getName())  ||
                    myName.equals(XSUnsignedShort.getInstance().getName())) {
          return new UnsignedShortSG(pFactory, pSchema, pType);
        } else if (myName.equals(XSUnsignedInt.getInstance().getName())) {
          return new UnsignedIntSG(pFactory, pSchema, pType);
        } else if (myName.equals(XSInteger.getInstance().getName())             ||
                    myName.equals(XSNonPositiveInteger.getInstance().getName())  ||
                    myName.equals(XSNegativeInteger.getInstance().getName())     ||
                    myName.equals(XSUnsignedLong.getInstance().getName())        ||
                    myName.equals(XSPositiveInteger.getInstance().getName())     ||
                    myName.equals(XSNonNegativeInteger.getInstance().getName())) {
          return new IntegerSG(pFactory, pSchema, pType);
        } else if (myName.equals(XSDecimal.getInstance().getName())) {
          return new DecimalSG(pFactory, pSchema, pType);
        } else if (myName.equals(XSQName.getInstance().getName())) {
          return new QNameSG(pFactory, pSchema, pType);
        } else if (myName.equals(XSDouble.getInstance().getName())) {
          return new DoubleSG(pFactory, pSchema, pType);
        } else if (myName.equals(XSFloat.getInstance().getName())) {
          return new FloatSG(pFactory, pSchema, pType);
        } else if (myName.equals(XSHexBinary.getInstance().getName())) {
          return new HexBinarySG(pFactory, pSchema, pType);
        } else if (myName.equals(XSBase64Binary.getInstance().getName())) {
          return new Base64BinarySG(pFactory, pSchema, pType);
        } else if (myName.equals(XSBoolean.getInstance().getName())) {
          return new BooleanSG(pFactory, pSchema, pType);
        } else if (myName.equals(XSDate.getInstance().getName())) {
          return new DateSG(pFactory, pSchema, pType);
        } else if (myName.equals(XSDateTime.getInstance().getName())) {
          return new DateTimeSG(pFactory, pSchema, pType);
        } else if (myName.equals(XSTime.getInstance().getName())) {
          return new TimeSG(pFactory, pSchema, pType);
        } else if (myName.equals(XSDuration.getInstance().getName())) {
          return new DurationSG(pFactory, pSchema, pType);
        } else if (myName.equals(XSAnySimpleType.getInstance().getName())     ||
                    myName.equals(XSString.getInstance().getName())            ||
                    myName.equals(XSAnyURI.getInstance().getName())            ||
                    myName.equals(XSNormalizedString.getInstance().getName())  ||
                    myName.equals(XSToken.getInstance().getName())             ||
                    myName.equals(XSLanguage.getInstance().getName())          ||
                    myName.equals(XSName.getInstance().getName())              ||
                    myName.equals(XSNMToken.getInstance().getName())           ||
                    myName.equals(XSNCName.getInstance().getName())) {
          return new StringSG(pFactory, pSchema, pType);
        }
      }

      SimpleTypeSGChain result = newSimpleTypeSG(pController, pFactory, pSchema, simpleType.getRestrictedType());

      result = new SimpleTypeRestrictionSG(result, pType, simpleType);

      if (simpleType.getEnumerations().length > 0) {
        boolean generateTypesafeEnumClass = false;
        String className = null;
        String packageName = null;

        if (simpleType instanceof JAXBSimpleType) {
          JAXBSimpleType jaxbSimpleType = (JAXBSimpleType) simpleType;
          JAXBTypesafeEnumClass jaxbTypesafeEnumClass = jaxbSimpleType.getJAXBTypesafeEnumClass();
          if (jaxbTypesafeEnumClass != null) {
            generateTypesafeEnumClass = true;
            className = jaxbTypesafeEnumClass.getName();
          }
        }

        if (!generateTypesafeEnumClass) {
          XSEnumeration[] enumerations = simpleType.getEnumerations();
          for (int i = 0;  i < enumerations.length;  i++) {
            XSEnumeration enumeration = enumerations[i];
            if (enumeration instanceof JAXBEnumeration) {
              JAXBEnumeration jaxbEnumeration = (JAXBEnumeration) enumeration;
              if (jaxbEnumeration.getJAXBTypesafeEnumMember() != null) {
                generateTypesafeEnumClass = true;
                break;
              }
            }
          }
        }

        if (!generateTypesafeEnumClass  &&  pType.isGlobal()) {
          XsQName[] qNames = new XsQName[]{XSNMToken.getInstance().getName()};
          XSSchema xsSchema = xsType.getXSSchema();
          if (xsSchema instanceof JAXBSchema) {
            JAXBSchema jaxbSchema = (JAXBSchema) xsSchema;
            JAXBGlobalBindings globalBindings = jaxbSchema.getJAXBGlobalBindings();
            if (globalBindings != null) {
              qNames = globalBindings.getTypesafeEnumBase();
            }
          }

          for (XSType restrType = xsType;  !generateTypesafeEnumClass;  ) {
            restrType = restrType.getSimpleType().getRestrictedType();
            if (restrType.isGlobal()) {
              for (int i = 0;  i < qNames.length;  i++) {
                if (qNames[i].equals(restrType.getName())) {
                  generateTypesafeEnumClass = true;
                  break;
                }
              }
              if (XSAnySimpleType.getInstance().getName().equals(restrType.getName())) {
                break;
              }
            }
          }
        }

        JAXBSchemaBindings jaxbSchemaBindings;
        if (xsType instanceof JAXBType) {
            jaxbSchemaBindings = ((JAXBType) xsType).getJAXBSchemaBindings();
        } else {
            jaxbSchemaBindings = null;
        }
        packageName = AbstractContext.getPackageName(pSchema, jaxbSchemaBindings,
                                   pController.getLocator(),
                                   pController.getName());

        if (generateTypesafeEnumClass) {
          if (className == null) {
            XsQName qName = pType.isGlobal() ? pType.getName() : pController.getName();
            className = AbstractContext.getClassNameFromLocalName(pController.getLocator(),
                                                                  qName.getLocalName(),
                                                                  pSchema) + "Class";
          }
          result = new EnumerationSG(result, JavaQNameImpl.getInstance(packageName, className), pType);
        }
      }
View Full Code Here

    ObjectSG ea = elements[0];
    assertTrue(ea.getTypeSG().isComplex());
    ComplexTypeSG eact = ea.getTypeSG().getComplexTypeSG();
    AttributeSG[] eactAttr = eact.getAttributes();
    assertEquals(3, eactAttr.length);
    assertEquals(new XsQName((String) null, "d"), eactAttr[0].getName());
    assertEquals(eactAttr[0].getTypeSG().getSimpleTypeSG().getRuntimeType(), JavaQNameImpl.getInstance(Calendar.class));
    assertEquals(new XsQName((String) null, "e"), eactAttr[1].getName());
    assertEquals(eactAttr[1].getTypeSG().getSimpleTypeSG().getRuntimeType(), JavaQNameImpl.getInstance(float.class));
    assertEquals(new XsQName((String) null, "a"), eactAttr[2].getName());
    assertEquals(eactAttr[2].getTypeSG().getSimpleTypeSG().getRuntimeType(), JavaQNameImpl.getInstance(String.class));

    ObjectSG eb = elements[1];
    assertTrue(eb.getTypeSG().isComplex());
    ComplexTypeSG ebct = eb.getTypeSG().getComplexTypeSG();
    AttributeSG[] ebctAttr = ebct.getAttributes();
    assertEquals(5, ebctAttr.length);
    assertEquals(new XsQName((String) null, "g"), ebctAttr[0].getName());
    assertEquals(ebctAttr[0].getTypeSG().getSimpleTypeSG().getRuntimeType(), JavaQNameImpl.getInstance(double.class));
    assertEquals(new XsQName((String) null, "d"), ebctAttr[1].getName());
    assertEquals(ebctAttr[1].getTypeSG().getSimpleTypeSG().getRuntimeType(), JavaQNameImpl.getInstance(Calendar.class));
    assertEquals(ebctAttr[2].getTypeSG().getSimpleTypeSG().getRuntimeType(), JavaQNameImpl.getInstance(float.class));
    assertEquals(ebctAttr[3].getTypeSG().getSimpleTypeSG().getRuntimeType(), JavaQNameImpl.getInstance(String.class));
    assertEquals(ebctAttr[4].getTypeSG().getSimpleTypeSG().getRuntimeType(), JavaQNameImpl.getInstance(int.class));
  }
View Full Code Here

    ObjectSG[] elements = jschema.getElements();
    assertEquals(4, elements.length);

    ObjectSG e1 = elements[0];
    assertEquals(new XsQName((String) null, "a"), e1.getName());
    TypeSG t1 = e1.getTypeSG();
    assertTrue(!t1.isComplex());
    assertTrue(t1.getSimpleTypeSG().isAtomic());
    assertEquals(t1.getSimpleTypeSG().getRuntimeType(), JavaQNameImpl.getInstance(String.class));

    ObjectSG e2 = elements[1];
    assertEquals(new XsQName((String) null, "b"), e2.getName());
    TypeSG t2 = e2.getTypeSG();
    assertTrue(!t2.isComplex());
    SimpleTypeSG st2 = t2.getSimpleTypeSG();
    assertTrue(st2.isAtomic());
    assertEquals(JavaQNameImpl.getInstance(float.class), st2.getRuntimeType());

    ObjectSG e3 = elements[2];
    assertEquals(new XsQName((String) null, "c"), e3.getName());
    TypeSG t3 = e3.getTypeSG();
    assertTrue(t3.isComplex());
    ComplexTypeSG ct3 = t3.getComplexTypeSG();
    assertTrue(!ct3.hasSimpleContent());
    ComplexContentSG cct3 = ct3.getComplexContentSG();
    ParticleSG[] childs = cct3.getGroupSG().getParticles();
    assertEquals(2, childs.length);
    assertTrue(childs[0].isElement());
    ObjectSG child1 = childs[0].getObjectSG();
    assertEquals(new XsQName((String) null, "a"), child1.getName());
    assertTrue(childs[1].isElement());
    ObjectSG child2 = childs[1].getObjectSG();
    assertEquals(new XsQName((String) null, "d"), child2.getName());
    assertTrue(!child2.getTypeSG().isComplex());
    SimpleTypeSG st4 = child2.getTypeSG().getSimpleTypeSG();
    assertEquals(JavaQNameImpl.getInstance(double.class.getName()), st4.getRuntimeType());
    AttributeSG[] attributes = ct3.getAttributes();
    assertEquals(1, attributes.length);
    assertEquals(new XsQName((String) null, "e"), attributes[0].getName());
    assertTrue(!attributes[0].getTypeSG().isComplex());

    ObjectSG e4 = elements[3];
    assertTrue(e4.getTypeSG().isComplex());
    ComplexTypeSG ct4 = e4.getTypeSG().getComplexTypeSG();
    assertTrue(ct4.hasSimpleContent());
    SimpleContentSG sct4 = ct4.getSimpleContentSG();
    assertTrue(!sct4.getContentTypeSG().isComplex());
    assertEquals(JavaQNameImpl.getInstance(int.class), sct4.getContentTypeSG().getRuntimeType());
    assertEquals(1, ct4.getAttributes().length);
    assertEquals(new XsQName((String) null, "g"), ct4.getAttributes()[0].getName());
    assertEquals(JavaQNameImpl.getInstance(boolean.class), ct4.getAttributes()[0].getTypeSG().getRuntimeType());
  }
View Full Code Here

    SchemaSG jschema = parse(schema, "testFacets.xsd");

    ObjectSG[] elements = jschema.getElements();
    assertEquals(1, elements.length);
    ObjectSG se1 = elements[0];
    assertEquals(new XsQName((String) null, "a"), se1.getName());
    assertTrue(!se1.getTypeSG().isComplex());
    SimpleTypeSG sst1 = se1.getTypeSG().getSimpleTypeSG();
    assertEquals(JavaQNameImpl.getInstance(String.class), sst1.getRuntimeType());
    Facet facet = sst1.getFacet(Facet.ENUMERATION);
    assertNotNull(facet);
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.