Package org.eclipse.xsd

Examples of org.eclipse.xsd.XSDTypeDefinition


        for (AttributeType type : types) {
            Name name = type.getName();

    stringBuffer.append(TEXT_7);
   
            XSDTypeDefinition xsdType = sg.getXSDType(type);
            StringWriter writer = new StringWriter();

            SAXTransformerFactory txFactory =
                    (SAXTransformerFactory) SAXTransformerFactory.newInstance();
            TransformerHandler xmls;
            try {
                xmls = txFactory.newTransformerHandler();
            } catch (TransformerConfigurationException e) {
                throw new RuntimeException(e);
            }
            xmls.getTransformer().setOutputProperty(OutputKeys.METHOD, "XML");
            xmls.getTransformer().setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "true");
            xmls.getTransformer().setOutputProperty(OutputKeys.INDENT, "true");

            try {
                xmls.getTransformer().transform(new DOMSource(xsdType.getElement()), new StreamResult(writer));
            }
            catch (Exception e) {
                e.printStackTrace();
                return null;
            }
View Full Code Here


        //find the type in the xsd schema
        List typeDefs = schema.getTypeDefinitions();

        for (Iterator itr = typeDefs.iterator(); itr.hasNext();) {
            XSDTypeDefinition xsdType = (XSDTypeDefinition) itr.next();
            String tns = xsdType.getTargetNamespace();
            String tn = xsdType.getName();

            if (namespace.equals(tns) && name.equals(tn)) {
                types.put(xsdType, gtType);

                return;
View Full Code Here

     * @return the XSD type associated with <code>type</code>.
     */
    public XSDTypeDefinition getXSDType(AttributeType type) {
        for (Iterator itr = types.entrySet().iterator(); itr.hasNext();) {
            Map.Entry entry = (Entry) itr.next();
            XSDTypeDefinition xsdType = (XSDTypeDefinition) entry.getKey();
            AttributeType gtType = (AttributeType) entry.getValue();

            if (gtType.equals(type)) {
                return xsdType;
            }
View Full Code Here

        //process simple types
        if (simpleTypes) {
            logger.fine("Generating simple types");
            for (Iterator itr = typeDefs.iterator(); itr.hasNext();) {
                XSDTypeDefinition xsdType = (XSDTypeDefinition) itr.next();

                if (xsdType.getName() == null) {
                    continue;
                }

                if (!xsdType.getTargetNamespace()
                                .equals(schema.getTargetNamespace())) {
                    continue;
                }

                if (xsdType instanceof XSDSimpleTypeDefinition) {
                    logger.fine(xsdType.getName());
                    createType((XSDSimpleTypeDefinition) xsdType, 0);
                }
            }
        }

        //process complex types
        if (complexTypes) {
            logger.fine("Generating complex types");
            for (Iterator itr = typeDefs.iterator(); itr.hasNext();) {
                XSDTypeDefinition xsdType = (XSDTypeDefinition) itr.next();

                if (xsdType.getName() == null) {
                    continue;
                }

                if (!xsdType.getTargetNamespace()
                                .equals(schema.getTargetNamespace())) {
                    continue;
                }

                if (xsdType instanceof XSDComplexTypeDefinition) {
                    logger.fine(xsdType.getName());
                    try {
                    createType((XSDComplexTypeDefinition) xsdType, 0);
                    }
                    catch (Exception e) {
                        logger.warning("XERRORX generating " + xsdType);
View Full Code Here

            return (AttributeType) findType(xsdType);
        }

        //first build super type
        AttributeType superType = null;
        XSDTypeDefinition baseType = xsdType.getBaseType();

        if ((baseType != null) && !baseType.equals(xsdType)) {
            if (baseType.getName() != null) {
                //ignore unamed types
                //superType = createType((XSDSimpleTypeDefinition)baseType);
                superType = createType(baseType, depth+1);
                assert superType != null;
            }
View Full Code Here

      return findType(xsdType);
    }
   
    //first build super type
    AttributeType/*ComplexType*/ superType = null;
    XSDTypeDefinition baseType = xsdType.getBaseType();
    if (baseType != null && !baseType.equals(xsdType)) {
      if (baseType.getName() != null) {
        //ignore unamed types
        superType = createType(/*(XSDComplexTypeDefinition)*/baseType, depth+1);
        assert superType != null;
      }
    }
   
    // now build child types
    ArrayList properties = new ArrayList();
    if (followComplexTypes) {
      List children = Schemas.getChildElementParticles(xsdType, false);
      for (Iterator itr = children.iterator(); itr.hasNext();) {
          XSDParticle particle = (XSDParticle) itr.next();
        XSDElementDeclaration element = (XSDElementDeclaration) particle.getContent();
        if (element.isElementDeclarationReference()) {
            element = element.getResolvedElementDeclaration();
        }
       
        XSDTypeDefinition childType = element.getTypeDefinition();
        if (childType == null) {
            childType = findGlobalElementXSDType(element);
        }
       
        AttributeType gtType = null;
View Full Code Here

    }
   
    protected final AttributeType xsAnyType() {
        XSDSchema schema = XSDUtil.getSchemaForSchema(XSDConstants.SCHEMA_FOR_SCHEMA_URI_2001);
        for ( Iterator i = schema.getTypeDefinitions().iterator(); i.hasNext(); ) {
            XSDTypeDefinition t = (XSDTypeDefinition) i.next();
            if ( XS.ANYTYPE.getLocalPart().equals( t.getName() ) ) {
                return findType(t);
            }
        }
        throw new IllegalStateException("XS schema not present");
    }
View Full Code Here

        System.err.println("Creating simple type " + name(xsdType));
        AttributeType gtType = new AbstractLazyAttributeTypeImpl(name(xsdType), Object.class,
                false, false, null, null) {
            @Override
            public AttributeType buildSuper() {
                XSDTypeDefinition baseType = xsdType.getBaseType();
                if (baseType != null && baseType.getName() != null && !baseType.equals(xsdType)) {
                    return createType(baseType, Integer.MAX_VALUE);
                } else {
                    return null;
                }
            }
View Full Code Here

        ComplexType gtType = new AbstractLazyComplexTypeImpl(name(xsdType), false,
                xsdType.isAbstract(), null, null) {

            @Override
            public AttributeType buildSuper() {
                XSDTypeDefinition baseType = xsdType.getBaseType();
                if (baseType != null && baseType.getName() != null && !baseType.equals(xsdType)) {
                    return createType(baseType, DUMMY_DEPTH);
                } else {
                    return null;
                }
            }

            @SuppressWarnings("unchecked")
            @Override
            public Collection<PropertyDescriptor> buildDescriptors() {
                if (!followComplexTypes) {
                    // might need to generate shallow schema classes while bootstrapping
                    return null;
                } else {
                    List<PropertyDescriptor> properties = new ArrayList<PropertyDescriptor>();
                    for (XSDParticle particle : (List<XSDParticle>) Schemas
                            .getChildElementParticles(xsdType, false)) {
                        XSDElementDeclaration element = (XSDElementDeclaration) particle
                                .getContent();
                        if (element.isElementDeclarationReference()) {
                            element = element.getResolvedElementDeclaration();
                        }
                        XSDTypeDefinition childType = element.getTypeDefinition();
                        if (childType == null) {
                            childType = findGlobalElementXSDType(element);
                        }
                        AttributeType gtType = null;
                        if (childType != null) {
View Full Code Here

                        }
                        name = entry.getKey();
                    }
                }

                XSDTypeDefinition attributeDefinition = xsd.resolveTypeDefinition(name
                        .getNamespaceURI(), name.getLocalPart());
                attribute.setTypeDefinition(attributeDefinition);

                XSDParticle particle = factory.createXSDParticle();
                particle.setMinOccurs(attributeDescriptor.getMinOccurs());
View Full Code Here

TOP

Related Classes of org.eclipse.xsd.XSDTypeDefinition

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.