Package org.eclipse.xsd

Examples of org.eclipse.xsd.XSDSimpleTypeDefinition


      {
        return eEnum;
      }
      else
      {
        XSDSimpleTypeDefinition baseTypeDefinition = xsdSimpleTypeDefinition.getBaseTypeDefinition();
        if (baseTypeDefinition != null)
        {
          EDataType eDataType = ecoreFactory.createEDataType();
          setAnnotations(eDataType, xsdSimpleTypeDefinition);

          String name = getEcoreAttribute(xsdSimpleTypeDefinition, "name");
          if (name == null)
          {
            name = validAliasName(xsdSimpleTypeDefinition, true);
          }

          eDataType.setName(name);
          extendedMetaData.setName(eDataType, xsdSimpleTypeDefinition.getAliasName());

          EPackage ePackage = getEPackage(xsdSimpleTypeDefinition);
          addToSortedList(ePackage.getEClassifiers(), eDataType);

          if (baseTypeDefinition.getVariety() != xsdSimpleTypeDefinition.getVariety())
          {
            if (xsdSimpleTypeDefinition.getVariety() == XSDVariety.LIST_LITERAL)
            {
              EDataType itemEDataType = getEDataType(xsdSimpleTypeDefinition.getItemTypeDefinition());
              extendedMetaData.setItemType(eDataType, itemEDataType);
              eDataType.setInstanceClassName("java.util.List");
            }
            else
            {
              String instanceClassName = null;
              List memberTypes = new ArrayList();
              for (Iterator i = xsdSimpleTypeDefinition.getMemberTypeDefinitions().iterator(); i.hasNext(); )
              {
                XSDSimpleTypeDefinition memberTypeDefinition = (XSDSimpleTypeDefinition)i.next();
                EDataType memberEDataType = getEDataType(memberTypeDefinition);
                memberTypes.add(memberEDataType);
                String memberInstanceClassName = memberEDataType.getInstanceClassName();
                if (memberInstanceClassName == null && memberEDataType instanceof EEnum)
                {
View Full Code Here


    {
      EClassifier referenceClassifier = getEClassifier(referenceType);
      boolean needsHolder = false;
      if (elementTypeDefinition instanceof XSDSimpleTypeDefinition)
      {
        XSDSimpleTypeDefinition xsdSimpleTypeDefinition = (XSDSimpleTypeDefinition)elementTypeDefinition;
        if (xsdSimpleTypeDefinition.getVariety() == XSDVariety.LIST_LITERAL)
        {
          needsHolder = true;
         
          EPackage holderPackage = getEPackage(xsdElementDeclaration);
          String holderName = xsdElementDeclaration.getName() + ":holder";
View Full Code Here

     * </p>
     * @param instance
     */
    protected Object preParse(InstanceComponent instance) {
        // we only preparse text, so simple types
        XSDSimpleTypeDefinition type = null;

        if (instance.getTypeDefinition() instanceof XSDSimpleTypeDefinition) {
            type = (XSDSimpleTypeDefinition) instance.getTypeDefinition();
        } else {
            XSDComplexTypeDefinition complexType = (XSDComplexTypeDefinition) instance
                .getTypeDefinition();

            if (complexType.getContentType() instanceof XSDSimpleTypeDefinition) {
                type = (XSDSimpleTypeDefinition) complexType.getContentType();
            }
        }

        String text = instance.getText();

        if (type != null) {
            //alright, lets preparse some text
            //first base on variety
            if (type.getVariety() == XSDVariety.LIST_LITERAL) {
                //list, whiteSpace is fixed to "COLLAPSE
                text = Whitespace.COLLAPSE.preparse(text);

                //lists are seperated by spaces
                String[] list = text.split(" +");

                //apply the facets
                // 1. length
                // 2. maxLength
                // 3. minLength
                // 4. enumeration
                if (type.getLengthFacet() != null) {
                    XSDLengthFacet length = type.getLengthFacet();

                    if (list.length != length.getValue()) {
                        //validation exception
                    }
                }

                if (type.getMaxLengthFacet() != null) {
                    XSDMaxLengthFacet length = type.getMaxLengthFacet();

                    if (list.length > length.getValue()) {
                        //validation exception
                    }
                }

                if (type.getMinLengthFacet() != null) {
                    XSDMinLengthFacet length = type.getMinLengthFacet();

                    if (list.length < length.getValue()) {
                        //validation exception
                    }
                }

                if (!type.getEnumerationFacets().isEmpty()) {
                    //gather up all teh possible values
                    Set values = new HashSet();

                    for (Iterator e = type.getEnumerationFacets().iterator(); e.hasNext();) {
                        XSDEnumerationFacet enumeration = (XSDEnumerationFacet) e.next();

                        for (Iterator v = enumeration.getValue().iterator(); v.hasNext();) {
                            values.add(v.next());
                        }
                    }

                    for (int i = 0; i < list.length; i++) {
                        if (!values.contains(list[i])) {
                            //validation exception
                        }
                    }
                }

                //now we must parse the items up
                final XSDSimpleTypeDefinition itemType = type.getItemTypeDefinition();
                List parsed = new ArrayList();

                //create a pseudo declaration
                final XSDElementDeclaration element = XSDFactory.eINSTANCE
                    .createXSDElementDeclaration();
View Full Code Here

        String value = instance.getText();

        while (type != null) {
            if (type instanceof XSDSimpleTypeDefinition) {
                XSDSimpleTypeDefinition simpleType = (XSDSimpleTypeDefinition) type;
                List facets = simpleType.getFacets();

                for (Iterator itr = facets.iterator(); itr.hasNext();) {
                    XSDFacet facet = (XSDFacet) itr.next();

                    if ("whiteSpace".equals(facet.getFacetName())) {
View Full Code Here

    private Length() {
    }

    public int length(XSDTypeDefinition definition) {
        try {
            XSDSimpleTypeDefinition simple = (XSDSimpleTypeDefinition) definition;
            XSDLengthFacet facet = simple.getLengthFacet();

            if (facet == null) {
                return Integer.MAX_VALUE;
            }
View Full Code Here

                    decl = XSDFactory.eINSTANCE.createXSDAttributeDeclaration();
                    decl.setName(attQName.getLocalPart());
                    decl.setTargetNamespace(attQName.getNamespaceURI());

                    //set the type to be of string
                    XSDSimpleTypeDefinition type = (XSDSimpleTypeDefinition) XSDUtil.getSchemaForSchema(XSDUtil.SCHEMA_FOR_SCHEMA_URI_2001)
                                                                                    .getSimpleTypeIdMap()
                                                                                    .get("string");

                    decl.setTypeDefinition(type);
                }
View Full Code Here

        assertEquals("1.0", xsd.getVersion());
    }

    /** Look into "builtin" schema for schema (aka xsd ?) */
    public void testXSDSimpleTypes() throws Exception {
        XSDSimpleTypeDefinition any = xsdSimple("anySimpleType");
        assertNotNull("Found", any);
    }
View Full Code Here

        assertNotNull("Found", any);
    }

    /** Look into parsed schema - should agree with XMLSchema */
    public void testSchemaSimpleTypes() throws Exception {
        XSDSimpleTypeDefinition any = xsdSimple("anySimpleType");
        assertNotNull("Found", any);
    }
View Full Code Here

            if (field.getType() != QName.class) {
                continue;
            }

            QName name = (QName) field.get(null);
            XSDSimpleTypeDefinition aXsd = xsdSimple(name.getLocalPart());

            if (aXsd == null) {
                //System.out.println( "Could not find binding for " + name.getLocalPart() );
            }
        }
View Full Code Here

                            XSDAttributeDeclaration attribute = (XSDAttributeDeclaration) itr.next();
                            if ( attribute.isAttributeDeclarationReference() ) {
                                attribute = attribute.getResolvedAttributeDeclaration();
                            }
                           
                            XSDSimpleTypeDefinition type = attribute.getTypeDefinition();
                            if (type == null) {
                                //look up in global schema
                                for (Iterator a = schema.getAttributeDeclarations().iterator(); a.hasNext();) {
                                    XSDAttributeDeclaration ad = (XSDAttributeDeclaration) a.next();
                                    if (Utilities.equals(ad.getTargetNamespace(), attribute.getTargetNamespace())
                                        && Utilities.equals(ad.getName(), attribute.getName())) {
                                        type = ad.getTypeDefinition();
                                        break;
                                    }
                                }
                            }
                            if ( type.getName() == null ) {
                              //TODO: deal with anonymous attribute types
                              continue;
                            }
                            AttributeType gtType = createType(type, depth+1);
                            if ( "uom".equals( attribute.getName() ) ) {
View Full Code Here

TOP

Related Classes of org.eclipse.xsd.XSDSimpleTypeDefinition

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.