Package org.jibx.schema.elements

Examples of org.jibx.schema.elements.UnionElement


                break;
            }
           
            case SchemaBase.UNION_TYPE:
            {
                UnionElement union = ((UnionElement)component);
                QName[] types = union.getMemberTypes();
                if (types != null) {
                    ArrayList repls = new ArrayList();
                    boolean changed = false;
                    for (int i = 0; i < types.length; i++) {
                        QName type = types[i];
                        QName repl = replaceAndReference(type, vctx);
                        changed = changed || repl != type;
                        if (repl != null) {
                            repls.add(repl);
                        }
                    }
                    if (changed) {
                        if (repls.size() > 0) {
                            union.setMemberTypes((QName[])repls.toArray(new QName[repls.size()]));
                        } else {
                            union.setMemberTypes(null);
                        }
                    }
                }
                break;
            }
View Full Code Here


        // handle union normalization after all children have been normalized
        if (topcomp.type() == SchemaBase.UNION_TYPE) {
           
            // start by checking duplicates in the member types
            compact = false;
            UnionElement union = (UnionElement)topcomp;
            Set typeset = new HashSet();
            ArrayList keeptypes = new ArrayList();
            QName[] membertypes = union.getMemberTypes();
            if (membertypes != null) {
                for (int i = 0; i < membertypes.length; i++) {
                    QName type = membertypes[i];
                    if (typeset.contains(type)) {
                        if (s_logger.isDebugEnabled()) {
                            s_logger.debug(lead + "removed redundant member type " + type + " from " + path);
                        }
                    } else {
                        typeset.add(type);
                        keeptypes.add(type);
                    }
                }
            }
           
            // then check inline types for duplicates, simplifying where possible
            count = union.getChildCount();
            for (int i = 0; i < count; i++) {
                SchemaBase child = topcomp.getChild(i);
                if (child instanceof OpenAttrBase) {
                   
                    // child schema component must be an inline simple type definition
                    SimpleTypeElement simple = (SimpleTypeElement)child;
                    boolean keeper = false;
                    SchemaBase derivation = simple.getDerivation();
                    QName repltype = null;
                    if (derivation != null) {
                       
                        // keep the inline definition by default, but check for replacement cases
                        keeper = true;
                        if (derivation.type() == SchemaBase.RESTRICTION_TYPE) {
                            SimpleRestrictionElement innerrestrict = (SimpleRestrictionElement)derivation;
                            if (innerrestrict.getChildCount() == 0) {
                               
                                // treat empty restriction the same as a member type from list
                                repltype = innerrestrict.getBase();
                                if (typeset.contains(repltype)) {
                                    keeper = false;
                                }
                               
                            }
                        } else if (derivation.type() == SchemaBase.UNION_TYPE) {
                            UnionElement innerunion = (UnionElement)derivation;
                            QName[] innertypes = innerunion.getMemberTypes();
                            FilteredSegmentList innerinlines = innerunion.getInlineBaseList();
                            if (innertypes.length + innerinlines.size() == 1) {
                               
                                // replace child union with single type from union
                                if (innertypes.length == 1) {
                                   
View Full Code Here

TOP

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

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.