Package org.eclipse.xsd

Examples of org.eclipse.xsd.XSDAttributeDeclaration


                //add any more attributes
                List attributes = index.getAttributes(entry.element);

                for (Iterator itr = attributes.iterator(); itr.hasNext();) {
                    XSDAttributeDeclaration attribute = (XSDAttributeDeclaration) itr.next();

                    //do not encode the attribute if it has already been
                    // encoded by the parent
                    String ns = attribute.getTargetNamespace();
                    String local = attribute.getName();

                    if ((entry.encoding.getAttributeNS(ns, local) != null)
                            && !"".equals(entry.encoding.getAttributeNS(ns, local))) {
                        continue;
                    }
View Full Code Here


        if (component instanceof XSDElementDeclaration) {
            XSDElementDeclaration element = (XSDElementDeclaration) component;

            return encoder.encode(object, element, doc, container );
        } else if (component instanceof XSDAttributeDeclaration) {
            XSDAttributeDeclaration attribute = (XSDAttributeDeclaration) component;

            return encoder.encode(object, attribute, doc, container);
        }

        return null;
View Full Code Here

    public static final XSDAttributeDeclaration getAttributeDeclaration(
        XSDElementDeclaration element, QName qName) {
        List atts = getAttributeDeclarations(element);

        for (Iterator itr = atts.iterator(); itr.hasNext();) {
            XSDAttributeDeclaration att = (XSDAttributeDeclaration) itr.next();

            if (nameMatches(att, qName)) {
                return att;
            }
        }
View Full Code Here

            String uri = attributes.getURI(i);
            String name = attributes.getLocalName(i);

            QName attQName = new QName(uri, name);

            XSDAttributeDeclaration decl = Schemas.getAttributeDeclaration(content, attQName);

            if (decl == null) {
                //check wether unknown attributes should be parsed
                if (!parser.isStrict()) {
                    if (parser.getLogger().isLoggable(Level.FINE)) {
                        parser.getLogger().fine("Parsing unknown attribute: " + attQName);
                    }

                    //create a mock attribute and continue
                    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);
                }
            }

            //TODO: validate, if there is no declaration for an attribute, then
            //TODO: make sure no required attributes are missing
            // validation should fail, this is being side stepped for now until
            // a good way of handling the namespace attributes on the root
            // element, for now we just ignore attributes we dont find in the
            // schema
            if (decl != null) {
                AttributeInstance att = new AttributeImpl(decl);
                att.setNamespace(decl.getTargetNamespace());
                att.setName(decl.getName());
                att.setText(attributes.getValue(i));

                atts.add(att);
            } else {
                parser.getLogger().warning("Could not find attribute declaration: " + attQName);
View Full Code Here

        if (generateAttributes) {
            List attributes = schema.getAttributeDeclarations();

            for (Iterator a = attributes.iterator(); a.hasNext();) {
                XSDAttributeDeclaration attribute = (XSDAttributeDeclaration) a
                    .next();
                generate(attribute, schema);

                if (target(attribute, schema)) {
                    components.add(attribute);
View Full Code Here

        element.getAnonymousTypeDefinition().setName( "_" + element.getName() );
        anonymous.add( element.getAnonymousTypeDefinition() );
      }
    }
    for ( Iterator a = schema.getAttributeDeclarations().iterator(); a.hasNext(); ) {
      XSDAttributeDeclaration attribute = (XSDAttributeDeclaration) a.next();
      if ( attribute.getAnonymousTypeDefinition() != null ) {
        attribute.getAnonymousTypeDefinition().setName( "_" + attribute.getName() );
        anonymous.add( attribute.getAnonymousTypeDefinition() );
      }
    }
      //add any anonymous types foudn with type definitions
      for ( Iterator t = types.iterator(); t.hasNext(); ) {
        XSDTypeDefinition type = (XSDTypeDefinition) t.next();
View Full Code Here

            properties.add(ad);
      }
     
      List atts = Schemas.getAttributeDeclarations(xsdType,false);
      for (Iterator itr = atts.iterator(); itr.hasNext();) {
                            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 ) {
View Full Code Here

                schema.add(descriptor);
            }
           
            if (includeAttributes) {
                for (XSDAttributeUse attgcontent : complexTypeDef.getAttributeUses()) {
                    XSDAttributeDeclaration att = attgcontent.getContent();
                    descriptor = createAttributeDescriptor (getXmlAttributeType(), null, new NameImpl(null, "@" + att.getName()), 0,1, false,null);
                    schema.add(descriptor);
                }
            }

            // set substitution group for descriptors here
View Full Code Here

        XSDElementDeclaration decl = (XSDElementDeclaration) descriptor.getUserData().get(
                XSDElementDeclaration.class);

        Iterator it = Schemas.getAttributeDeclarations(decl).iterator();
        while (it.hasNext()) {
            XSDAttributeDeclaration attDecl = ((XSDAttributeDeclaration) it.next());
            if (attDecl.getURI().equals(
                    (name.getNamespaceURI() == null ? "" : name.getNamespaceURI()) + "#"
                            + name.getLocalPart())) {
                return name;
            }
        }
View Full Code Here

        return node;
    }

    AttributeInstance createAtribute(String namespace, String name, QName type, String text) {
        XSDAttributeDeclaration declaration = XSDFactory.eINSTANCE.createXSDAttributeDeclaration();
        declaration.setName(name);
        declaration.setTargetNamespace(namespace);
        declaration.setTypeDefinition((XSDSimpleTypeDefinition) findTypeDefinition(schema, type));

        AttributeInstance attribute = new AttributeImpl(declaration);
        attribute.setName(name);
        attribute.setNamespace(namespace);
        attribute.setText(text);
View Full Code Here

TOP

Related Classes of org.eclipse.xsd.XSDAttributeDeclaration

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.