Package org.jibx.runtime

Examples of org.jibx.runtime.QName


       
        // start by generating group/attributeGroup schema components
        MappingElementBase mapping = detail.getMapping();
        if (detail.isGroup()) {
            // TODO: extend base type for group/attributeGroup?
            QName qname = detail.getOtherName();
            SchemaHolder hold = findSchema(qname.getUri());
            if (detail.hasChild()) {
                GroupElement group = new GroupElement();
                group.setName(qname.getName());
                group.setDefinition(buildCompositor(mapping, 0, false, hold));
                addDocumentation(info, group);
                hold.getSchema().getTopLevelChildren().add(group);
            }
            if (detail.hasAttribute()) {
                AttributeGroupElement attgrp = new AttributeGroupElement();
                attgrp.setName(qname.getName());
                fillAttributes(mapping, 0, attgrp.getAttributeList(), hold);
                addDocumentation(info, attgrp);
                hold.getSchema().getTopLevelChildren().add(attgrp);
            }
        }
       
        // next generate the complex type definition
        if (detail.isType()) {
           
            // set up the basic definition structure
            QName qname = detail.getTypeName();
            SchemaHolder hold = findSchema(qname.getUri());
            ComplexTypeElement type = buildComplexType(detail, hold);
            type.setName(qname.getName());
            addDocumentation(info, type);
            hold.getSchema().getTopLevelChildren().add(type);
        }
       
        // finish by generating element definition
        if (detail.isElement()) {
            QName qname = detail.getOtherName();
            SchemaHolder hold = findSchema(qname.getUri());
            ElementElement elem = new ElementElement();
            elem.setName(qname.getName());
            setSubstitutionGroup(detail.getSubstitution(), elem, hold);
            if (detail.isType()) {
                setElementType(detail.getTypeName(), elem, hold);
            } else {
               
View Full Code Here


       
        // look up referenced type definitions
        if (m_memberTypes != null) {
            m_memberTypeDefinitions = new CommonTypeDefinition[m_memberTypes.length];
            for (int i = 0; i < m_memberTypes.length; i++) {
                QName tname = m_memberTypes[i];
                CommonTypeDefinition def = vctx.findType(tname);
                m_memberTypeDefinitions[i] = def;
                if (def == null) {
                    vctx.addFatal("Referenced type '" + tname + "' is not defined", this);
                }
View Full Code Here

                   
                    // abstract or concrete mapping for element
                    ElementElement element = (ElementElement)comp;
                    setName(element.getEffectiveQName(), mapping, holder);
                    mapping.setAbstract(element.isAbstract());
                    QName group = element.getSubstitutionGroup();
                    if (group != null) {
                        ElementElement base = m_validationContext.findElement(group);
                        DefinitionItem basedef = ((GlobalExtension)base.getExtension()).getDefinition();
                        mapping.setExtendsName(basedef.getGenerateClass().getFullName());
                    }
                   
                } else {
                   
                    // abstract mapping for type definition or group
                    mapping.setAbstract(true);
                    QName qname = definition.getQName();
                    mapping.setTypeQName(qname);
                    String uri = qname.getUri();
                    if (uri != null) {
                        m_bindingDirectory.addTypeNameReference(holder, uri, schema);
                    }
                   
                }
               
                // add the mapping to binding and set on class
                holder.addMapping(mapping);
                ((StructureClassHolder)clas).setBinding(mapping);
                DefinitionItem elementdef = (DefinitionItem)typeinst.get(definition);
                if (elementdef != null) {
                   
                    // create mapping for element name linked to type
                    ElementElement element = (ElementElement)elementdef.getSchemaComponent();
                    SchemaElement elschema = element.getSchema();
                    MappingElementBase elmapping = new MappingElement();
                    elmapping.setClassName(clas.getBindingName());
                    elmapping.setAbstract(element.isAbstract());
                   
                    // handle linking to substitution group head using extends mapping
                    QName group = element.getSubstitutionGroup();
                    if (group != null) {
                        ElementElement base = m_validationContext.findElement(group);
                        DefinitionItem basedef = ((GlobalExtension)base.getExtension()).getDefinition();
                        elmapping.setExtendsName(basedef.getGenerateClass().getFullName());
                    }
                   
                    // create single structure child invoking the type mapping
                    holder = m_bindingDirectory.getRequiredBinding(elschema);
                    setName(element.getEffectiveQName(), elmapping, holder);
                    StructureElement struct = new StructureElement();
                    QName qname = mapping.getTypeQName();
                    String uri = qname.getUri();
                    if (uri != null) {
                        m_bindingDirectory.addTypeNameReference(holder, uri, schema);
                    }
                    struct.setMapAsQName(qname);
                    elmapping.addChild(struct);
View Full Code Here

       
        // build the item structure for each definition and link to pregenerated classes
        ArrayList items = buildItemStructures();
        for (int i = 0; i < items.size(); i++) {
            DefinitionItem definition = (DefinitionItem)items.get(i);
            QName qname = definition.getQName();
            TypeData clas = null;
            switch (definition.getSchemaComponent().type()) {
                case SchemaBase.ATTRIBUTEGROUP_TYPE:
                case SchemaBase.COMPLEXTYPE_TYPE:
                case SchemaBase.GROUP_TYPE:
View Full Code Here

                // handle mapping as type if abstract with type name, or as element if concrete
                MappingElementBase mapping = (MappingElementBase)element;
                String cname = mapping.getClassName();
                TypeData data = buildClassData(cname, false);
                if (mapping.isAbstract()) {
                    QName qname = mapping.getTypeQName();
                    if (qname != null) {
                        typemap.put(qname, data);
                        if (s_logger.isDebugEnabled()) {
                            s_logger.debug("Added class " + cname + " for type " + qname);
                        }
                    }
                } else {
                    QName qname = new QName(mapping.getNamespace().getUri(), mapping.getName());
                    elemmap.put(qname, data);
                    if (s_logger.isDebugEnabled()) {
                        s_logger.debug("Added class " + cname + " for element " + qname);
                    }
                }
View Full Code Here

       
        // check for missing items
        if (m_name == null) {
            vctx.addError("Missing required 'name' attribute", this);
        } else {
            m_qname = new QName(vctx.getCurrentSchema().getEffectiveNamespace(),
                getName());
        }
        if (m_definitionList.size() == 0) {
            vctx.addError("Missing required <all>, <choice>, or <sequence> child element", this);
        } else  if (m_definitionList.size() > 1) {
View Full Code Here

        ClassCustom custom = m_global.getClassCustomization(itype);
        if (detail != null) {
            if (detail.isUseAbstract() && !detail.isExtended()) {
               
                // add <structure> with map-as for abstract mapping
                QName qname = detail.getTypeQName();
                if (iname == null) {
                    iname = custom.getElementName();
                }
                StructureElement struct = new StructureElement();
                if (qname == null) {
                    struct.setMapAsName(itype);
                } else {
                   
                    // set the type reference and namespace dependency
                    String uri = qname.getUri();
                    hold.addTypeNameReference(uri, uri);
                    struct.setMapAsQName(qname);
                   
                }
                struct.setName(iname);
View Full Code Here

        BindingMappingDetail detail = (BindingMappingDetail)m_mappingDetailsMap.get(type);
        if (detail != null) {
           
            // use existing <mapping> definition for type
            if (detail.isUseAbstract() && !detail.isExtended()) {
                QName qname = detail.getTypeQName();
                String uri = qname.getUri();
                hold.addTypeNameReference(uri, uri);
                struct.setMapAsQName(qname);
                if (memb != null) {
                    struct.setName(memb.getXmlName());
                    hold.addNamespaceUsage(hold.getNamespace());
View Full Code Here

    private void addMapping(String type, BindingMappingDetail detail) {
       
        // create the basic mapping structure(s)
        ClassCustom cust = m_global.addClassCustomization(type);
        MappingElementBase mainmapping = null;
        QName qname = null;
        MappingElementBase mapcon = null;
        IClass clas = cust.getClassInformation();
        if (detail.isUseConcrete()) {
           
            // create concrete mapping
            mapcon = createMapping(type, cust);
            qname = detail.getElementQName();
            mapcon.setName(qname.getName());
            detail.setConcreteMapping(mapcon);
           
            // make "concrete" mapping abstract if no class creation possible
            if (clas.isAbstract() || clas.isInterface()) {
                mapcon.setAbstract(true);
            }
           
            // fill details directly to this mapping unless abstract also created
            mainmapping = mapcon;
           
        }
        MappingElement mapabs = null;
        if (detail.isUseAbstract()) {
           
            // create abstract mapping
            mapabs = createMapping(type, cust);
            mapabs.setAbstract(true);
            qname = detail.getTypeQName();
            mapabs.setTypeQName(qname);
            detail.setAbstractMapping(mapabs);
           
            // use abstract mapping for details (concrete will reference this one)
            mainmapping = mapabs;
           
        }
        if (mainmapping != null) {
           
            // find the binding containing this mapping
            String uri = qname.getUri();
            BindingHolder hold = m_directory.getBinding(uri);
            if (mainmapping.isAbstract()) {
                hold.addTypeNameReference(uri, uri);
            }
           
            // check for superclass mapping to be extended (do this first for compatibility with schema type extension)
            StructureElement struct = null;
            String ptype = detail.getExtendsType();
            Map exmembmap = Collections.EMPTY_MAP;
            Map inmembmap = new HashMap();
            if (ptype == null) {
               
                // not extending a base mapping, check if need to include superclass
                IClass parent = clas.getSuperClass();
                if (cust.isUseSuper() && parent != null) {
                    ptype = parent.getName();
                    if (checkInclude(ptype)) {
                        struct = new StructureElement();
                        struct.setDeclaredType(ptype);
                        ClassCustom scust = m_global.getClassCustomization(ptype);
                        exmembmap = new HashMap();
                        fillStructure(scust, null, exmembmap, struct, hold);
                    }
                }
               
            } else {
               
                // create reference to parent mapping
                struct = new StructureElement();
                BindingMappingDetail pdetail = (BindingMappingDetail)m_mappingDetailsMap.get(ptype);
                if (!pdetail.isGenerated()) {
                    addMapping(ptype, pdetail);
                }
                exmembmap = pdetail.getAccessMethodMap();
                if (pdetail.isUseAbstract()) {
                   
                    // reference abstract mapped superclass
                    QName tname = pdetail.getTypeQName();
                    if (tname == null) {
                        throw new IllegalStateException("Internal error: unimplemented case of superclass " + ptype
                            + " to be extended by subclass " + type + ", without an abstract <mapping> ");
                    } else {
                        uri = tname.getUri();
                        hold.addTypeNameReference(uri, uri);
                        struct.setMapAsQName(tname);
                    }
                   
                } else {
                   
                    // reference concrete mapped superclass
                    struct.setMapAsName(ptype);
                   
                }
               
                // set extension for child concrete mapping
                if (mapcon != null) {
                    mapcon.setExtendsName(ptype);
                }
               
            }
           
            // add extension reference structure to mapping
            if (struct != null) {
                mainmapping.addChild(struct);
            }
           
            // add all details of class member handling to binding
            inmembmap.putAll(exmembmap);
            addMemberBindings(cust, exmembmap, inmembmap, mainmapping, hold);
            hold.addMapping(mainmapping);
            if (mapabs != null && mapcon != null) {
               
                // define content as structure reference to abstract mapping
                struct = new StructureElement();
                QName tname = detail.getTypeQName();
                uri = tname.getUri();
                hold.addTypeNameReference(uri, uri);
                struct.setMapAsQName(tname);
                mapcon.addChild(struct);
                hold.addMapping(mapcon);
               
View Full Code Here

                BindingMappingDetail sdetail = addMappingDetails(isabs, null, stype);
                sdetail.setExtended(true);
            }
           
            // force type name to use same namespace as element name, if supplied
            QName tname;
            if (ename == null) {
                tname = cust.getTypeQName();
            } else {
                tname = new QName(ename.getUri(), cust.getTypeName());
            }
           
            // make sure the binding holder has been created for this namespace
            String uri = tname.getUri();
            if (m_directory.getBinding(uri) == null) {
                m_directory.addBinding(uri, uri, null, true);
            }
           
            // check or get element name to be used
View Full Code Here

TOP

Related Classes of org.jibx.runtime.QName

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.