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

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


                }
            };
        }

        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

        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) || ((!tn.getNamespaceURI().equals(uri) && tn.getNamespaceURI().length()>0) &&
                                                            (!((parentInfo instanceof ClassInfo) && (((ClassInfo)parentInfo).getTypeName() == null))))) {     // see Issue 517
                            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

/*      */
/*      */     private void writeArray(ArrayInfo<T, C> a, Schema schema)
/*      */     {
/*  765 */       ComplexType ct = schema.complexType().name(a.getTypeName().getLocalPart());
/*  766 */       ct._final("#all");
/*  767 */       LocalElement le = ct.sequence().element().name("item");
/*  768 */       le.type(a.getItemType().getTypeName());
/*  769 */       le.minOccurs(0).maxOccurs("unbounded");
/*  770 */       le.nillable(true);
/*  771 */       ct.commit();
/*      */     }
View Full Code Here

/*      */     {
/*  975 */       if (ep.isValueList()) {
/*  976 */         return new Tree.Term(ep) {
/*      */           protected void write(ContentModelContainer parent, boolean isOptional, boolean repeated) {
/*  978 */             TypeRef t = (TypeRef)this.val$ep.getTypes().get(0);
/*  979 */             LocalElement e = parent.element();
/*  980 */             e.block();
/*  981 */             QName tn = t.getTagName();
/*  982 */             e.name(tn.getLocalPart());
/*  983 */             com.sun.xml.bind.v2.schemagen.xmlschema.List lst = e.simpleType().list();
/*  984 */             XmlSchemaGenerator.Namespace.this.writeTypeRef(lst, t, "itemType");
/*  985 */             XmlSchemaGenerator.Namespace.this.elementFormDefault.writeForm(e, tn);
/*  986 */             writeOccurs(e, (isOptional) || (!this.val$ep.isRequired()), repeated);
/*      */           }
/*      */         };
/*      */       }
/*  991 */       ArrayList children = new ArrayList();
/*  992 */       for (TypeRef t : ep.getTypes()) {
/*  993 */         children.add(new Tree.Term(t) {
/*      */           protected void write(ContentModelContainer parent, boolean isOptional, boolean repeated) {
/*  995 */             LocalElement e = parent.element();
/*      */
/*  997 */             QName tn = this.val$t.getTagName();
/*      */
/*  999 */             if ((XmlSchemaGenerator.Namespace.this.canBeDirectElementRef(this.val$t, tn)) || ((!tn.getNamespaceURI().equals(XmlSchemaGenerator.Namespace.this.uri)) && (tn.getNamespaceURI().length() > 0))) {
/* 1000 */               e.ref(tn);
/*      */             } else {
/* 1002 */               e.name(tn.getLocalPart());
/* 1003 */               XmlSchemaGenerator.Namespace.this.writeTypeRef(e, this.val$t, "type");
/* 1004 */               XmlSchemaGenerator.Namespace.this.elementFormDefault.writeForm(e, tn);
/*      */             }
/*      */
/* 1007 */             if (this.val$t.isNillable()) {
/* 1008 */               e.nillable(true);
/*      */             }
/* 1010 */             if (this.val$t.getDefaultValue() != null)
/* 1011 */               e._default(this.val$t.getDefaultValue());
/* 1012 */             writeOccurs(e, isOptional, repeated);
/*      */           }
/*      */         });
/*      */       }
/* 1017 */       Tree choice = Tree.makeGroup(GroupKind.CHOICE, children).makeOptional(!ep.isRequired()).makeRepeated(ep.isCollection());
/*      */
/* 1022 */       QName ename = ep.getXmlName();
/* 1023 */       if (ename != null)
/* 1024 */         return new Tree.Term(ename, ep, choice) {
/*      */           protected void write(ContentModelContainer parent, boolean isOptional, boolean repeated) {
/* 1026 */             LocalElement e = parent.element();
/* 1027 */             if ((this.val$ename.getNamespaceURI().length() > 0) &&
/* 1028 */               (!this.val$ename.getNamespaceURI().equals(XmlSchemaGenerator.Namespace.this.uri)))
/*      */             {
/* 1031 */               e.ref(new QName(this.val$ename.getNamespaceURI(), this.val$ename.getLocalPart()));
/* 1032 */               return;
/*      */             }
/*      */
/* 1035 */             e.name(this.val$ename.getLocalPart());
/* 1036 */             XmlSchemaGenerator.Namespace.this.elementFormDefault.writeForm(e, this.val$ename);
/*      */
/* 1038 */             if (this.val$ep.isCollectionNillable()) {
/* 1039 */               e.nillable(true);
/*      */             }
/* 1041 */             writeOccurs(e, !this.val$ep.isCollectionRequired(), repeated);
/*      */
/* 1043 */             ComplexType p = e.complexType();
/* 1044 */             this.val$choice.write(p);
/*      */           }
/*      */         };
/* 1048 */       return choice;
/*      */     }
View Full Code Here

/* 1137 */       ArrayList children = new ArrayList();
/*      */
/* 1139 */       for (Element e : rp.getElements()) {
/* 1140 */         children.add(new Tree.Term(e) {
/*      */           protected void write(ContentModelContainer parent, boolean isOptional, boolean repeated) {
/* 1142 */             LocalElement eref = parent.element();
/*      */
/* 1144 */             boolean local = false;
/*      */
/* 1146 */             QName en = this.val$e.getElementName();
/* 1147 */             if (this.val$e.getScope() != null)
/*      */             {
/* 1149 */               boolean qualified = en.getNamespaceURI().equals(XmlSchemaGenerator.Namespace.this.uri);
/* 1150 */               boolean unqualified = en.getNamespaceURI().equals("");
/* 1151 */               if ((qualified) || (unqualified))
/*      */               {
/* 1155 */                 if (unqualified) {
/* 1156 */                   if (XmlSchemaGenerator.Namespace.this.elementFormDefault.isEffectivelyQualified)
/* 1157 */                     eref.form("unqualified");
/*      */                 }
/* 1159 */                 else if (!XmlSchemaGenerator.Namespace.this.elementFormDefault.isEffectivelyQualified) {
/* 1160 */                   eref.form("qualified");
/*      */                 }
/*      */
/* 1163 */                 local = true;
/* 1164 */                 eref.name(en.getLocalPart());
/*      */
/* 1167 */                 if ((this.val$e instanceof ClassInfo))
/* 1168 */                   XmlSchemaGenerator.Namespace.this.writeTypeRef(eref, (ClassInfo)this.val$e, "type");
/*      */                 else {
/* 1170 */                   XmlSchemaGenerator.Namespace.this.writeTypeRef(eref, ((ElementInfo)this.val$e).getContentType(), "type");
/*      */                 }
/*      */               }
/*      */             }
/* 1174 */             if (!local)
/* 1175 */               eref.ref(en);
/* 1176 */             writeOccurs(eref, isOptional, repeated);
/*      */           }
/*      */         });
/*      */       }
/* 1181 */       WildcardMode wc = rp.getWildcard();
/* 1182 */       if (wc != null) {
/* 1183 */         children.add(new Tree.Term(wc) {
/*      */           protected void write(ContentModelContainer parent, boolean isOptional, boolean repeated) {
/* 1185 */             Any any = parent.any();
/* 1186 */             String pcmode = XmlSchemaGenerator.access$2100(this.val$wc);
/* 1187 */             if (pcmode != null) any.processContents(pcmode);
/* 1188 */             any.namespace("##other");
/* 1189 */             writeOccurs(any, isOptional, repeated);
/*      */           }
/*      */         });
/*      */       }
/*      */
/* 1195 */       Tree choice = Tree.makeGroup(GroupKind.CHOICE, children).makeRepeated(rp.isCollection()).makeOptional(rp.isCollection());
/*      */
/* 1200 */       QName ename = rp.getXmlName();
/*      */
/* 1202 */       if (ename != null)
/* 1203 */         return new Tree.Term(ename, rp, choice) {
/*      */           protected void write(ContentModelContainer parent, boolean isOptional, boolean repeated) {
/* 1205 */             LocalElement e = parent.element().name(this.val$ename.getLocalPart());
/* 1206 */             XmlSchemaGenerator.Namespace.this.elementFormDefault.writeForm(e, this.val$ename);
/* 1207 */             if (this.val$rp.isCollectionNillable())
/* 1208 */               e.nillable(true);
/* 1209 */             writeOccurs(e, true, repeated);
/*      */
/* 1211 */             ComplexType p = e.complexType();
/* 1212 */             this.val$choice.write(p);
/*      */           }
/*      */         };
/* 1216 */       return choice;
/*      */     }
View Full Code Here

/*      */     {
/* 1227 */       return new Tree.Term(mp) {
/*      */         protected void write(ContentModelContainer parent, boolean isOptional, boolean repeated) {
/* 1229 */           QName ename = this.val$mp.getXmlName();
/*      */
/* 1231 */           LocalElement e = parent.element();
/* 1232 */           XmlSchemaGenerator.Namespace.this.elementFormDefault.writeForm(e, ename);
/* 1233 */           if (this.val$mp.isCollectionNillable()) {
/* 1234 */             e.nillable(true);
/*      */           }
/* 1236 */           e = e.name(ename.getLocalPart());
/* 1237 */           writeOccurs(e, isOptional, repeated);
/* 1238 */           ComplexType p = e.complexType();
/*      */
/* 1242 */           e = p.sequence().element();
/* 1243 */           e.name("entry").minOccurs(0).maxOccurs("unbounded");
/*      */
/* 1245 */           ExplicitGroup seq = e.complexType().sequence();
/* 1246 */           XmlSchemaGenerator.Namespace.this.writeKeyOrValue(seq, "key", this.val$mp.getKeyType());
/* 1247 */           XmlSchemaGenerator.Namespace.this.writeKeyOrValue(seq, "value", this.val$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.