Package org.jibx.runtime

Examples of org.jibx.runtime.QName


        // set the name(s) to be used if mapped
        String cname = convertName(getSimpleName());
        if (m_elementName == null) {
            m_elementName = cname;
        }
        m_elementQName = new QName(getNamespace(), m_elementName);
        if (m_typeName == null) {
            m_typeName = cname;
        }
        m_typeQName = new QName(getNamespace(), m_typeName);
       
        // initialize maps with existing member customizations
        HashMap namemap = new HashMap();
        for (Iterator iter = getChildren().iterator(); iter.hasNext();) {
            ValueCustom memb = (ValueCustom)iter.next();
View Full Code Here


           
            // make sure name is supplied for global element
            if (getName() == null) {
                vctx.addError("The 'name' attribute is required for a global definition", this);
            } else {
                m_qname = new QName(ens, getName());
            }
           
            // make sure prohibited attributes are not present
            if (getRef() != null || getForm() != -1 || getMinOccurs() != null || getMaxOccurs() != null) {
                vctx.addError("The 'ref', 'form', 'minOccurs' and 'maxOccurs' attributes are prohibited for a global element definition", this);
            }
           
        } else {
           
            // make sure name or reference is supplied for local element
            if (getName() == null && getRef() == null) {
                vctx.addError(
                    "Either a 'name' attribute or a 'ref' attribute is required for a local element definition", this);
            }
           
            // generate qname if name supplied
            if (getName() != null) {
                boolean def = schema.isElementQualifiedDefault();
                String uri = null;
                if (m_formChoice.isQualified(def)) {
                    uri = ens;
                }
                m_qname = new QName(uri, getName());
            }
           
            // make sure prohibited attributes are not present
            if (getSubstitutionGroup() != null || getBlock().isPresent() || getFinal().isPresent()) {
                vctx.addError("The 'substitutionGroup', 'block', and 'final' attributes are prohibited for a local element definition", this);
View Full Code Here

        // start with validating the attributes
        m_defRef.validate(vctx);
        m_formChoice.validate(vctx);
       
        // check type of definition
        QName ref = getRef();
        if (ref != null) {
           
            // make sure element reference is defined
            m_refElement = vctx.findElement(ref);
            if (m_refElement == null) {
View Full Code Here

         * Accumulate namespace used by element definition.
         *
         * @param node
         */
        public void exit(ElementElement node) {
            QName qname = node.getQName();
            if (qname != null) {
                m_uris.add(qname.getUri());
            }
            super.exit(node);
        }
View Full Code Here

            String base = qname.getName();
            String name = nameset.add(base);
            if (name.equals(base)) {
                return qname;
            } else {
                return new QName(uri, name);
            }
        } else {
            return null;
        }
    }
View Full Code Here

    public static void getDefinitions(BindingElement binding, final Map types, final Map elems, final Map formats) {
        TreeContext ctx = new TreeContext(new DummyClassLocator());
        ModelVisitor visitor = new ModelVisitor() {

            public boolean visit(MappingElement mapping) {
                QName qname = mapping.getTypeQName();
                if (qname != null) {
                    types.put(qname, mapping);
                }
                String name = mapping.getName();
                if (name != null) {
                    qname = new QName(mapping.getNamespace().getUri(), name);
                    elems.put(qname, mapping);
                }
                return false;
            }
           
            public boolean visit(FormatElement format) {
                QName qname = format.getQName();
                if (qname != null) {
                    formats.put(qname, formats);
                }
                return false;
            }
View Full Code Here

                while (comp != topcomp) {
                    if (comp.isGlobal()) {
                        if (!(item instanceof ReferenceItem)) {
                            refcomps.add(comp);
                        }
                        QName qname = ((INamed)comp).getQName();
                        if (qname == null) {
                            throw new IllegalStateException("Internal error - no name on global definition");
                        } else {
                            uritoprefix.put(qname.getUri(), qname.getPrefix());
                        }
                        break;
                    } else {
                        comp = comp.getParent();
                    }
                }
               
                // now check the actual item type
                if (item instanceof GroupItem) {
                   
                    // check non-inlined group which uses separate class
                    GroupItem childgroup = (GroupItem)item;
                    if (!childgroup.isIgnored()) {
                        if (childgroup.isInline()) {
                            scanItemTree(childgroup, comptoclas, refcomps, uritoprefix);
                        } else {
                           
                            // add component to class mapping to stop schema fragment generation when reached
                            TypeData genclas = childgroup.getGenerateClass();
                            if (genclas == null) {
                                throw new IllegalStateException("Internal error - no generate class");
                            } else {
                                comptoclas.put(childgroup.getSchemaComponent(), genclas);
                            }
                           
                            // check for type definition or reference used (with associated namespace reference)
                            QName tname = null;
                            comp = item.getSchemaComponent();
                            switch (comp.type()) {
                                case SchemaBase.ATTRIBUTE_TYPE:
                                    tname = ((AttributeElement)comp).getType();
                                    break;
                                case SchemaBase.ELEMENT_TYPE:
                                    tname = ((ElementElement)comp).getType();
                                    break;
                            }
                            if (tname != null) {
                                uritoprefix.put(tname.getUri(), tname.getPrefix());
                            }
                            QName rname = null;
                            if (comp instanceof IReference) {
                                rname = ((IReference)comp).getRef();
                            }
                            if (rname != null) {
                                uritoprefix.put(rname.getUri(), rname.getPrefix());
                            }
                        }
                    }
                   
                } else if (item instanceof ReferenceItem) {
                   
                    // make sure namespace collected for reference
                    DefinitionItem def = ((ReferenceItem)item).getDefinition();
                    AnnotatedBase defcomp = def.getSchemaComponent();
                    if (defcomp instanceof INamed) {
                        QName qname = ((INamed)defcomp).getQName();
                        if (qname == null && defcomp instanceof IReference) {
                            qname = ((IReference)defcomp).getRef();
                        }
                        if (qname != null) {
                            uritoprefix.put(qname.getUri(), qname.getPrefix());
                        }
                    }
                    TypeData genclas = def.getGenerateClass();
                    if (genclas != null) {
                        comptoclas.put(defcomp, genclas);
                    }
                   
                }
            }
        }
       
        // also check for substitution group used with element
        if (topcomp.type() == SchemaBase.ELEMENT_TYPE) {
            QName sname = ((ElementElement)topcomp).getSubstitutionGroup();
            if (sname != null) {
                uritoprefix.put(sname.getUri(), sname.getPrefix());
            }
        }
    }
View Full Code Here

            InsertionOrderedSet refcomps = new InsertionOrderedSet();
            AnnotatedBase grpcomp = group.getSchemaComponent();
            refcomps.add(grpcomp);
            Map uritoprefix = new HashMap();
            if (grpcomp instanceof INamed) {
                QName qname = ((INamed)grpcomp).getQName();
                if (qname == null && grpcomp instanceof IReference) {
                    qname = ((IReference)grpcomp).getRef();
                }
                if (qname != null && qname.getUri() != null) {
                    uritoprefix.put(qname.getUri(), qname.getPrefix());
                }
            }
            scanItemTree(group, comptoclas, refcomps, uritoprefix);
           
            // get full set of namespaces and corresponding prefixes needed for extracts
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.