Package com.sun.xml.internal.bind.v2.schemagen.xmlschema

Examples of com.sun.xml.internal.bind.v2.schemagen.xmlschema.LocalElement


            child.maxOccurs("unbounded");
        }
    }
   
    protected Occurs addChild(ExplicitGroup sq, QName name, TypeInfo typeInfo) {
        LocalElement le = null;;
        QName type = model.getBindingContext().getTypeName(typeInfo);
        if (type != null) {
            le = sq.element();
            le._attribute("name", name.getLocalPart());
            le.type(type);
        } else {
            if (typeInfo.type instanceof Class) {
                try {
                    QName elemName = model.getBindingContext().getElementName((Class)typeInfo.type);
                    if (elemName.getLocalPart().equals("any") && elemName.getNamespaceURI().equals(XsdNs)) {
                        return sq.any();
                    } else {
                        le = sq.element();
                        le.ref(elemName);
                    }
                } catch (JAXBException je) {
                    throw new WebServiceException(je.getMessage(), je);
                }
            }
View Full Code Here


         * writes the schema definition for the given array class
         */
        private void writeArray(ArrayInfo<T, C> a, Schema schema) {
            ComplexType ct = schema.complexType().name(a.getTypeName().getLocalPart());
            ct._final("#all");
            LocalElement le = ct.sequence().element().name("item");
            le.type(a.getItemType().getTypeName());
            le.minOccurs(0).maxOccurs("unbounded");
            le.nillable(true);
            ct.commit();
        }
View Full Code Here

        private Tree handleElementProp(final ElementPropertyInfo<T,C> ep) {
            if (ep.isValueList()) {
                return new Tree.Term() {
                    protected void write(ContentModelContainer parent, boolean isOptional, boolean repeated) {
                        TypeRef<T,C> t = ep.getTypes().get(0);
                        LocalElement e = parent.element();
                        e.block(); // we will write occurs later
                        QName tn = t.getTagName();
                        e.name(tn.getLocalPart());
                        List lst = e.simpleType().list();
                        writeTypeRef(lst,t, "itemType");
                        elementFormDefault.writeForm(e,tn);
                        writeOccurs(e,isOptional||!ep.isRequired(),repeated);
                    }
                };
            }

            ArrayList<Tree> children = new ArrayList<Tree>();
            for (final TypeRef<T,C> t : ep.getTypes()) {
                children.add(new Tree.Term() {
                    protected void write(ContentModelContainer parent, boolean isOptional, boolean repeated) {
                        LocalElement e = parent.element();

                        QName tn = t.getTagName();

                        PropertyInfo propInfo = t.getSource();
                        TypeInfo parentInfo = (propInfo == null) ? null : propInfo.parent();

                        if (canBeDirectElementRef(t, tn, parentInfo)) {
                            if ((!t.getTarget().isSimpleType()) && (t.getTarget() instanceof ClassInfo) && collisionChecker.findDuplicate((ClassInfo<T, C>) t.getTarget())) {
                                e.ref(new QName(uri, tn.getLocalPart()));
                            } else {

                                QName elemName = null;
                                if (t.getTarget() instanceof Element) {
                                    Element te = (Element) t.getTarget();
                                    elemName = te.getElementName();
                                }

                                Collection<TypeInfo> refs = propInfo.ref();
                                TypeInfo ti;
                                if ((refs != null) && (!refs.isEmpty()) && (elemName != null)
                                        && ((ti = refs.iterator().next()) == null || ti instanceof ClassInfoImpl)) {
                                    ClassInfoImpl cImpl = (ClassInfoImpl)ti;
                                    if ((cImpl != null) && (cImpl.getElementName() != null)) {
                                        e.ref(new QName(cImpl.getElementName().getNamespaceURI(), tn.getLocalPart()));
                                    } else {
                                        e.ref(new QName("", tn.getLocalPart()));
                                    }
                                } else {
                                    e.ref(tn);
                                }
                            }
                        } else {
                            e.name(tn.getLocalPart());
                            writeTypeRef(e,t, "type");
                            elementFormDefault.writeForm(e,tn);
                        }

                        if (t.isNillable()) {
                            e.nillable(true);
                        }
                        if(t.getDefaultValue()!=null)
                            e._default(t.getDefaultValue());
                        writeOccurs(e,isOptional,repeated);
                    }
                });
            }

            final Tree choice = Tree.makeGroup(GroupKind.CHOICE, children)
                    .makeOptional(!ep.isRequired())
                    .makeRepeated(ep.isCollection()); // see Spec table 8-13


            final QName ename = ep.getXmlName();
            if (ename != null) { // wrapped collection
                return new Tree.Term() {
                    protected void write(ContentModelContainer parent, boolean isOptional, boolean repeated) {
                        LocalElement e = parent.element();
                        if(ename.getNamespaceURI().length()>0) {
                            if (!ename.getNamespaceURI().equals(uri)) {
                                // TODO: we need to generate the corresponding element declaration for this
                                // table 8-25: Property/field element wrapper with ref attribute
                                e.ref(new QName(ename.getNamespaceURI(), ename.getLocalPart()));
                                return;
                            }
                        }
                        e.name(ename.getLocalPart());
                        elementFormDefault.writeForm(e,ename);

                        if(ep.isCollectionNillable()) {
                            e.nillable(true);
                        }
                        writeOccurs(e,!ep.isCollectionRequired(),repeated);

                        ComplexType p = e.complexType();
                        choice.write(p);
                    }
                };
            } else {// non-wrapped
                return choice;
View Full Code Here

            ArrayList<Tree> children = new ArrayList<Tree>();

            for (final Element<T,C> e : rp.getElements()) {
                children.add(new Tree.Term() {
                    protected void write(ContentModelContainer parent, boolean isOptional, boolean repeated) {
                        LocalElement eref = parent.element();

                        boolean local=false;

                        QName en = e.getElementName();
                        if(e.getScope()!=null) {
                            // scoped. needs to be inlined
                            boolean qualified = en.getNamespaceURI().equals(uri);
                            boolean unqualified = en.getNamespaceURI().equals("");
                            if(qualified || unqualified) {
                                // can be inlined indeed

                                // write form="..." if necessary
                                if(unqualified) {
                                    if(elementFormDefault.isEffectivelyQualified)
                                        eref.form("unqualified");
                                } else {
                                    if(!elementFormDefault.isEffectivelyQualified)
                                        eref.form("qualified");
                                }

                                local = true;
                                eref.name(en.getLocalPart());

                                // write out type reference
                                if(e instanceof ClassInfo) {
                                    writeTypeRef(eref,(ClassInfo<T,C>)e,"type");
                                } else {
                                    writeTypeRef(eref,((ElementInfo<T,C>)e).getContentType(),"type");
                                }
                            }
                        }
                        if(!local)
                            eref.ref(en);
                        writeOccurs(eref,isOptional,repeated);
                    }
                });
            }

            final WildcardMode wc = rp.getWildcard();
            if( wc != null ) {
                children.add(new Tree.Term() {
                    protected void write(ContentModelContainer parent, boolean isOptional, boolean repeated) {
                        Any any = parent.any();
                        final String pcmode = getProcessContentsModeName(wc);
                        if( pcmode != null ) any.processContents(pcmode);
                        any.namespace("##other");
                        writeOccurs(any,isOptional,repeated);
                    }
                });
            }


            final Tree choice = Tree.makeGroup(GroupKind.CHOICE, children).makeRepeated(rp.isCollection()).makeOptional(!rp.isRequired());

            final QName ename = rp.getXmlName();

            if (ename != null) { // wrapped
                return new Tree.Term() {
                    protected void write(ContentModelContainer parent, boolean isOptional, boolean repeated) {
                        LocalElement e = parent.element().name(ename.getLocalPart());
                        elementFormDefault.writeForm(e,ename);
                        if(rp.isCollectionNillable())
                            e.nillable(true);
                        writeOccurs(e,true,repeated);

                        ComplexType p = e.complexType();
                        choice.write(p);
                    }
                };
            } else { // unwrapped
                return choice;
View Full Code Here

        private Tree handleMapProp(final MapPropertyInfo<T,C> mp) {
            return new Tree.Term() {
                protected void write(ContentModelContainer parent, boolean isOptional, boolean repeated) {
                    QName ename = mp.getXmlName();

                    LocalElement e = parent.element();
                    elementFormDefault.writeForm(e,ename);
                    if(mp.isCollectionNillable())
                        e.nillable(true);

                    e = e.name(ename.getLocalPart());
                    writeOccurs(e,isOptional,repeated);
                    ComplexType p = e.complexType();

                    // TODO: entry, key, and value are always unqualified. that needs to be fixed, too.
                    // TODO: we need to generate the corresponding element declaration, if they are qualified
                    e = p.sequence().element();
                    e.name("entry").minOccurs(0).maxOccurs("unbounded");

                    ExplicitGroup seq = e.complexType().sequence();
                    writeKeyOrValue(seq, "key", mp.getKeyType());
                    writeKeyOrValue(seq, "value", mp.getValueType());
                }
            };
        }
View Full Code Here

                }
            };
        }

        private void writeKeyOrValue(ExplicitGroup seq, String tagName, NonElement<T, C> typeRef) {
            LocalElement key = seq.element().name(tagName);
            key.minOccurs(0);
            writeTypeRef(key, typeRef, "type");
        }
View Full Code Here

         * writes the schema definition for the given array class
         */
        private void writeArray(ArrayInfo<T, C> a, Schema schema) {
            ComplexType ct = schema.complexType().name(a.getTypeName().getLocalPart());
            ct._final("#all");
            LocalElement le = ct.sequence().element().name("item");
            le.type(a.getItemType().getTypeName());
            le.minOccurs(0).maxOccurs("unbounded");
            le.nillable(true);
            ct.commit();
        }
View Full Code Here

            QName ename = ep.getXmlName();
            Occurs occurs = null;

            if (ep.isValueList()) {
                TypeRef<T,C> t = ep.getTypes().get(0);
                LocalElement e = compositor.element();

                QName tn = t.getTagName();
                e.name(tn.getLocalPart());
                List lst = e.simpleType().list();
                writeTypeRef(lst,t, "itemType");
                elementFormDefault.writeForm(e,tn);
                return;
            }

            if (ep.isCollection()) {
                if (ename != null) { // wrapped collection
                    LocalElement e = compositor.element();
                    if(ename.getNamespaceURI().length()>0) {
                        if (!ename.getNamespaceURI().equals(this.uri)) {
                            // TODO: we need to generate the corresponding element declaration for this
                            // table 8-25: Property/field element wrapper with ref attribute
                            e.ref(new QName(ename.getNamespaceURI(), ename.getLocalPart()));
                            return;
                        }
                    }
                    elementFormDefault.writeForm(e,ename);

                    ComplexType p = e.name(ename.getLocalPart()).complexType();
                    if(ep.isCollectionNillable()) {
                        e.nillable(true);
                    } else {
                        e.minOccurs(0);
                    }
                    if (ep.getTypes().size() == 1) {
                        compositor = p.sequence();
                    } else {
                        compositor = p.choice();
                        occurs = compositor;
                    }
                } else { // unwrapped collection
                    if (ep.getTypes().size() > 1) {
                        compositor = compositor.choice();
                        occurs = compositor;
                    }
                }
            } else {
                if (ep.getTypes().size() > 1) {
                    compositor = compositor.choice();
                    occurs = compositor;
                }
            }


            // fill in the content model
            for (TypeRef<T,C> t : ep.getTypes()) {
                LocalElement e = compositor.element();
                if (occurs == null) occurs = e;
                QName tn = t.getTagName();

                if(canBeDirectElementRef(t,tn) || (!tn.getNamespaceURI().equals(uri) && tn.getNamespaceURI().length()>0)) {
                    e.ref(tn);
                } else {
                    e.name(tn.getLocalPart());
                    writeTypeRef(e,t, "type");
                    elementFormDefault.writeForm(e,tn);
                }

                if (t.isNillable()) {
                    e.nillable(true);
                }
                if(t.getDefaultValue()!=null)
                    e._default(t.getDefaultValue());
            }

            if (ep.isCollection())
                occurs.maxOccurs("unbounded");
View Full Code Here

            QName ename = rp.getXmlName();
            Occurs occurs = null;

            if (rp.isCollection()) {
                if (ename != null) { // wrapped collection
                    LocalElement e = compositor.element();
                    ComplexType p = e.name(ename.getLocalPart()).complexType();
                    elementFormDefault.writeForm(e,ename);
                    if(rp.isCollectionNillable())
                        e.nillable(true);
                    if (rp.getElements().size() == 1) {
                        compositor = p.sequence();
                    } else {
                        compositor = p.choice();
                        occurs = compositor;
                    }
                } else { // unwrapped collection
                    if (rp.getElements().size() > 1) {
                        compositor = compositor.choice();
                        occurs = compositor;
                    }
                }
            }

            // fill in content model
            TODO.checkSpec("should we loop in the case of a non-collection ep?");
            for (Element<T,C> e : rp.getElements()) {
                LocalElement eref = compositor.element();
                if (occurs == null) occurs = eref;

                QName en = e.getElementName();
                if(e.getScope()!=null) {
                    // scoped. needs to be inlined
                    boolean qualified = en.getNamespaceURI().equals(uri);
                    boolean unqualified = en.getNamespaceURI().equals("");
                    if(qualified || unqualified) {
                        // can be inlined indeed

                        // write form="..." if necessary
                        if(unqualified) {
                            if(elementFormDefault.isEffectivelyQualified)
                                eref.form("unqualified");
                        } else {
                            if(!elementFormDefault.isEffectivelyQualified)
                                eref.form("qualified");
                        }

                        eref.name(en.getLocalPart());

                        // write out type reference
                        if(e instanceof ClassInfo) {
                            writeTypeRef(eref,(ClassInfo<T,C>)e,"type");
                        } else {
                            writeTypeRef(eref,((ElementInfo<T,C>)e).getContentType(),"type");
                        }
                        continue;
                    }
                }
                eref.ref(en);
            }

            WildcardMode wc = rp.getWildcard();
            if( wc != null ) {
                Any any = compositor.any();
View Full Code Here

         * @param compositor the schema compositor (sequence or all)
         */
        private void handleMapProp(MapPropertyInfo<T,C> mp, ExplicitGroup compositor) {
            QName ename = mp.getXmlName();

            LocalElement e = compositor.element();
            elementFormDefault.writeForm(e,ename);
            if(mp.isCollectionNillable())
                e.nillable(true);
            ComplexType p = e.name(ename.getLocalPart()).complexType();

            // TODO: entry, key, and value are always unqualified. that needs to be fixed, too.
            // TODO: we need to generate the corresponding element declaration, if they are qualified
            e = p.sequence().element();
            e.name("entry").minOccurs(0).maxOccurs("unbounded");

            ExplicitGroup seq = e.complexType().sequence();
            writeKeyOrValue(seq, "key", mp.getKeyType());
            writeKeyOrValue(seq, "value", mp.getValueType());
        }
View Full Code Here

TOP

Related Classes of com.sun.xml.internal.bind.v2.schemagen.xmlschema.LocalElement

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.