Package org.eclipse.xsd

Examples of org.eclipse.xsd.XSDTypeDefinition


     */
    public void walk(XSDTypeDefinition base, Visitor visitor) {
        List types = types(base);

        for (int i = 0; i < types.size(); i++) {
            XSDTypeDefinition type = (XSDTypeDefinition) types.get(i);

            //do the visit, if visitor returns false, break out
            if (!visitor.visit(type)) {
                break;
            }
View Full Code Here


     */
    public void rwalk(XSDTypeDefinition base, Visitor visitor) {
        List types = types(base);

        for (int i = types.size() - 1; i > -1; i--) {
            XSDTypeDefinition type = (XSDTypeDefinition) types.get(i);

            //do the visit, if visitor returns false, break out
            if (!visitor.visit(type)) {
                break;
            }
View Full Code Here

        List types = (List) cache.get(base);

        if (types == null) {
            types = new ArrayList();

            XSDTypeDefinition type = base;

            while (type != null) {
                types.add(type);

                //get the next type
                if (type.equals(type.getBaseType())) {
                    break;
                }

                type = type.getBaseType();
            }

            cache.put(base, types);
        }
View Full Code Here

                typeDefintion =
                    (QName) context.getComponentInstance("http://geotools.org/typeDefinition");
            }

            if (typeDefintion != null) {
                XSDTypeDefinition type = index.getTypeDefinition(typeDefintion);

                if (type == null) {
                    throw new NullPointerException();
                }

                //create a mock element declaration
                root = XSDFactory.eINSTANCE.createXSDElementDeclaration();
                root.setName(name.getLocalPart());
                root.setTargetNamespace(name.getNamespaceURI());
                root.setTypeDefinition(type);
            }
        }

        if (root == null) {
            String msg = "Could not find element declaration for:" + name;
            throw new IllegalArgumentException(msg);
        }

        encoded.add(new EncodingEntry(object, root, null));

        while (!encoded.isEmpty()) {
            EncodingEntry entry = (EncodingEntry) encoded.peek();

            if (entry.encoding != null) {
                //element has been started, get the next child
                if (!entry.children.isEmpty()) {
                    Object[] child = (Object[]) entry.children.get(0);
                    XSDElementDeclaration element = (XSDElementDeclaration) child[0];
                    Iterator itr = (Iterator) child[1];

                    if (itr.hasNext()) {
                        Object next = itr.next();
                       
                        //here we check for instanceof EncoderDelegate
                        if ( next instanceof EncoderDelegate ) {
                            //do not add entry to the stack, just delegate to encode
                            try {
                                ((EncoderDelegate) next).encode(handler);
                            }
                            catch (Exception e) {
                                throw new RuntimeException( e );
                            }
                        }
                        else {
                            //add the next object to be encoded to the stack
                            encoded.push(new EncodingEntry(next, element,entry));                           
                        }
                    } else {
                        //iterator done, close it
                        Object source = child[2];
                        closeIterator(itr,source);
                       
                        //this child is done, remove from child list
                        entry.children.remove(0);
                    }
                } else {
                    // no more children, finish the element
                    end(entry.encoding, entry.element);
                    encoded.pop();
                   
                    //clean up the entry
                    entry.object = null;
                    entry.element = null;
                    entry.encoding = null;
                    entry.children = null;
                    entry.parent = null;
                }
            } else {
                //start the encoding of the entry

                //first make sure the element is not abstract
                if (entry.element.isAbstract()) {
                    // look for a non abstract substitute - substitution groups are subject to
                    // changes over time, so we make a copy to avoid being hit with a ConcurrentModificationException
                    List sub = safeCopy(entry.element.getSubstitutionGroup());


                    if (sub.size() > 0) {
                        //match up by type
                        List matches = new ArrayList();

                        for (Iterator s = sub.iterator(); s.hasNext();) {
                            XSDElementDeclaration e = (XSDElementDeclaration) s.next();

                            if (e == null || e.equals(entry.element)) {
                                continue;
                            }

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

                            //look up hte binding
                            Binding binding = bindingLoader.loadBinding(new QName(
                                        e.getTargetNamespace(), e.getName()), context);

                            if (binding == null) {
                                //try the type
                                XSDTypeDefinition type = e.getType();

                                if (type == null || type.getName() == null) {
                                    continue;
                                }

                                binding = bindingLoader.loadBinding(new QName(
                                            type.getTargetNamespace(), type.getName()), context);
                            }

                            if (binding == null) {
                                continue;
                            }
View Full Code Here

        return null;
    }

    private XSDTypeDefinition container() {
      //get the containing type (we do this for anonymous complex types)
        XSDTypeDefinition container = null;
        if (getParentHandler().getComponent() != null) {
            container = getParentHandler().getComponent().getTypeDefinition();
        }
        return container;
    }
View Full Code Here

        XSDResourceImpl resource = (XSDResourceImpl) resourceSet.getResource(
                URI.createURI(EmfXsdLoadTest.class.getResource(filename).toString()), true);
        XSDSchema schema = resource.getSchema();
        Assert.assertNotNull(schema);
        SchemaIndex index = null;
        XSDTypeDefinition type = null;
        try {
            index = new SchemaIndexImpl(new XSDSchema[] { schema });
            type = index.getTypeDefinition(new QName(namespace, name));
        } finally {
            if (index != null) {
View Full Code Here

     * @param name
     *            complex type to be tested
     */
    private static void checkChildElementTypes(Configuration configuration, QName name) {
        SchemaIndex index = null;
        XSDTypeDefinition type = null;
        try {
            index = Schemas.findSchemas(configuration);
            type = index.getTypeDefinition(name);
        } finally {
            if (index != null) {
View Full Code Here

        if (generateTypes) {
          List types = GeneratorUtils.allTypes( schema );

            for (Iterator t = types.iterator(); t.hasNext();) {
                XSDTypeDefinition type = (XSDTypeDefinition) t.next();
                generate( type, schema );
               
                if (target(type, schema)) {
                    components.add(type);
                }
View Full Code Here

        anonymous.add( attribute.getAnonymousTypeDefinition() );
      }
    }
      //add any anonymous types foudn with type definitions
      for ( Iterator t = types.iterator(); t.hasNext(); ) {
        XSDTypeDefinition type = (XSDTypeDefinition) t.next();
        List particles = Schemas.getChildElementParticles( type, false );
        for ( Iterator p = particles.iterator(); p.hasNext(); ) {
          XSDParticle particle = (XSDParticle) p.next();
          XSDElementDeclaration element = (XSDElementDeclaration) particle.getContent();
         
          //ignore element references, caught in teh above loop
          if ( element.isElementDeclarationReference() )
            continue;
         
          if ( element.getAnonymousTypeDefinition() != null ) {
            element.getAnonymousTypeDefinition().setName( type.getName() + "_" + element.getName() );
            anonymous.add( element.getAnonymousTypeDefinition() );
          }
        }
      }
     
View Full Code Here

     */
  public static List types( XSDSchema schema, Set names ) {
      List allTypes = allTypes( schema );
      if ( names != null && !names.isEmpty() ) {
          for (Iterator t = allTypes.iterator(); t.hasNext(); ) {
              XSDTypeDefinition type = (XSDTypeDefinition) t.next();
              if ( type.getName() != null && names.contains(type.getName())) {
                  continue;
              }
             
              t.remove();
          }
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.