Package org.jibx.schema.elements

Examples of org.jibx.schema.elements.AttributeElement


     */
    public boolean visit(AttributeElement node) {
        if (node.getUse() != AttributeElement.PROHIBITED_USE) {
           
            // check for direct definition (rather than reference)
            AttributeElement refattr = node.getReference();
            if (refattr == null) {
                if (node.getType() == null) {
                   
                    // create a group for the embedded definition
                    buildStructure(false, node);
View Full Code Here


            case SchemaBase.ATTRIBUTE_TYPE:
            {
                if (isIgnored()) {
                    delete = true;
                } else {
                    AttributeElement attr = ((AttributeElement)component);
                    if (m_overrideType != null) {
                        attr.setType(m_overrideType);
                    }
                    QName type = attr.getType();
                    if (type == null) {
                        AttributeElement ref = attr.getReference();
                        if (ref != null) {
                            delete = !checkReference(ref);
                        } else if (!attr.isInlineType()) {
                            attr.setType(SchemaTypes.ANY_SIMPLE_TYPE.getQName());
                        }
                    } else {
                        QName repl = replaceAndReference(type, vctx);
                        if (repl == null) {
                            // TODO optionally make sure the attribute is optional?
                            delete = true;
                        } else if (repl != type) {
                            attr.setType(repl);
                        }
                    }
                }
                break;
            }
           
            case SchemaBase.ATTRIBUTEGROUP_TYPE:
            {
                if (component instanceof AttributeGroupRefElement) {
                    delete = !checkReference(((AttributeGroupRefElement)component).getReference());
                }
                break;
            }
           
            case SchemaBase.ELEMENT_TYPE:
            {
                ElementElement elem = ((ElementElement)component);
                if (isIgnored()) {
                   
                    // reference or definition determines handling
                    QName ref = elem.getRef();
                    if (ref == null) {
                       
                        // definition, just delete all content
                        for (int i = 0; i < elem.getChildCount(); i++) {
                            elem.detachChild(i);
                        }
                        elem.compactChildren();
                       
                    } else {
                       
                        // reference may be to other namespace, so convert to qualified name string
                        StringBuffer buff = new StringBuffer();
                        buff.append('{');
                        if (ref.getUri() != null) {
                            buff.append(ref.getUri());
                        }
                        buff.append('}');
                        buff.append(ref.getName());
                        elem.setName(buff.toString());
                        elem.setRef(null);
                       
                    }
                    elem.setType(SchemaTypes.ANY_TYPE.getQName());
View Full Code Here

            {
               
                case SchemaBase.ATTRIBUTE_TYPE:
                {
                    // set the attribute type to the specified type
                    AttributeElement attr = (AttributeElement)parent;
                    attr.setType(derive.getBase());
                    return true;
                }
               
                case SchemaBase.COMPLEXTYPE_TYPE:
                {
View Full Code Here

                   
                } else if (comp.type() == SchemaBase.ATTRIBUTE_TYPE) {
                   
                    // value is an attribute, set the name directly
                    value.setEffectiveStyle(NestingAttributes.ATTRIBUTE_STYLE);
                    AttributeElement attr = (AttributeElement)comp;
                    if (SchemaUtils.isOptionalAttribute(attr)) {
                        // TODO: this is needed because the optional status doesn't inherit downward for embedded items, as
                        // when a simpleType is nested inside an optional attribute. should the code be changed to
                        // inherit instead?
                        value.setUsage(PropertyAttributes.OPTIONAL_USAGE);
View Full Code Here

     *
     * @param qname name
     * @param def attribute definition
     */
    public void registerAttribute(QName qname, AttributeElement def) {
        AttributeElement dupl = m_nameRegister.registerAttribute(qname, def);
        if (dupl != null) {
            addError("Duplicate name " + qname, def);
        }
    }
View Full Code Here

        for (int i = 0; i < comps.size(); i++) {
            IComponent comp = (IComponent)comps.get(i);
            if (comp instanceof ValueElement) {
               
                // simple attribute definition
                AttributeElement attr = new AttributeElement();
                attr.setName(comp.getName());
                QName qname = getSimpleTypeQName(comp);
                if (qname == null) {
                    attr.setTypeDefinition(buildSimpleType(comp));
                } else {
                    setAttributeType(qname, attr, hold);
                }
                if (!comp.isOptional()) {
                    attr.setUse(AttributeElement.REQUIRED_USE);
                }
                addItemDocumentation((ValueElement)comp, attr);
                attrs.add(attr);
               
            } else if (comp instanceof ContainerElementBase) {
View Full Code Here

TOP

Related Classes of org.jibx.schema.elements.AttributeElement

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.