You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@xmlbeans.apache.org by Radu Preotiuc-Pietro <ra...@bea.com> on 2003/11/12 01:02:51 UTC

XMLSchema annotations

Hi xmlbeans-dev. As you know, the schema API in XMLBeans doesn't have a way to access schema annotations, so I have been working on a patch to XMLBeans that adds this. It should be useful for implementing anything that needs schema annotations, like JAXB (JSR 31).
So, this patch adds annotation support to the SOM. In a few words, Schema components that can be annotated implement now a SchemaAnnotated interface, which contains a single method returning a SchemaAnnotation object, where all the information is retrieved from. 

Can I ask somebody to review the patch and merge it in for v2?

CVS diff:

Index: build.xml
===================================================================
RCS file: /home/cvs/xml-xmlbeans/v2/build.xml,v
retrieving revision 1.19
diff -r1.19 build.xml
841c841
<       <arg line="${repackage_arg} -name sXMLSCHEMA -cp ${xsdschema.compile.path} -srconly -d build/classes/xsdschema -src build/src/xsdschema src/xsdschema/schema"/>
---
>       <arg line="${repackage_arg} -name sXMLSCHEMA -cp ${xsdschema.compile.path} -srconly -d build/classes/xsdschema -noann -src build/src/xsdschema src/xsdschema/schema"/>
863c863
<       <arg line="${repackage_arg} -name sXMLLANG -d build/classes/xmlschema -src build/src/xmlschema -srconly src/xmlschema/schema"/>
---
>       <arg line="${repackage_arg} -name sXMLLANG -noann -d build/classes/xmlschema -src build/src/xmlschema -srconly src/xmlschema/schema"/>
897c897
<       <arg line="${repackage_arg} -name sXMLCONFIG -srconly -src build/src/configschema -d build/classes/configschema src/configschema/schema"/>
---
>       <arg line="${repackage_arg} -name sXMLCONFIG -srconly -noann -src build/src/configschema -d build/classes/configschema src/configschema/schema"/>
919c919
<       <arg line="${repackage_arg} -name sXMLTOOLS -srconly -src build/src/toolschema -d build/classes/toolschema src/toolschema"/>
---
>       <arg line="${repackage_arg} -name sXMLTOOLS -srconly -noann -src build/src/toolschema -d build/classes/toolschema src/toolschema"/>
Index: bin/dumpxsb
===================================================================
RCS file: /home/cvs/xml-xmlbeans/v2/bin/dumpxsb,v
retrieving revision 1.1
diff -r1.1 dumpxsb
1c1
< #!/#in/sh
---
> #!/bin/sh
7c7
< cp=$cp:$XMLBEANS_HOME/build/libuxbean.jar
---
> cp=$cp:$XMLBEANS_HOME/build/ar/xbean.jar
9,10c9
< java
< classpath $cp org.apache.xmleeans.impl.tool.psbDumper $*
---
> java -classpath $cp org.apache.xmlbeans.impl.tool.XsbDumper $*
Index: bin/scomp
===================================================================
RCS file: /home/cvs/xml-xmlbeans/v2/bin/scomp,v
retrieving revision 1.1
diff -r1.1 scomp
7c7
< cp=$cp:$XMLBEANS_HOME/build/ar/xbean.jar
---
>     cp=$cp:$XMLBEANS_HOME/build/ar/xbean.jar:$XMLBEANS_HOME/build/lib/jsr173_07_api.jar
9c9
< java -classpath $cp ort.apache.xmlbeanseimpl.toolmSchemaCompiler $*
---
> java -classpath $cp org.apache.xmlbeans.impl.tool.SchemaCompiler $*
Index: src/typeimpl/org/apache/xmlbeans/impl/schema/BuiltinSchemaTypeSystem.java===================================================================
RCS file: /home/cvs/xml-xmlbeans/v2/src/typeimpl/org/apache/xmlbeans/impl/schema/BuiltinSchemaTypeSystem.java,v
retrieving revision 1.1
diff -r1.1 BuiltinSchemaTypeSystem.java
58a59
> import org.apache.xmlbeans.SchemaAnnotation;
98a100
>     private static final SchemaAnnotation[] EMPTY_SCHEMAANNOTATION_ARRAY = new SchemaAnnotation[0];
483a486,493
>     }
>
>     /*
>      * Returns the top-level annotations.
>      */
>     public SchemaAnnotation[] annotations()
>     {
>         return EMPTY_SCHEMAANNOTATION_ARRAY;
cvs server: src/typeimpl/org/apache/xmlbeans/impl/schema/SchemaAnnotationImpl.java is a new entry, no comparison available
Index: src/typeimpl/org/apache/xmlbeans/impl/schema/SchemaAttributeGroupImpl.java
===================================================================
RCS file: /home/cvs/xml-xmlbeans/v2/src/typeimpl/org/apache/xmlbeans/impl/schema/SchemaAttributeGroupImpl.java,v
retrieving revision 1.1
diff -r1.1 SchemaAttributeGroupImpl.java
59a60
> import org.apache.xmlbeans.SchemaAnnotation;
72a74
>     private SchemaAnnotation _annotation;
85c87
<     public void init(QName name, String targetNamespace, boolean chameleon, boolean redefinition, XmlObject x)
---
>     public void init(QName name, String targetNamespace, boolean chameleon, boolean redefinition, XmlObject x, SchemaAnnotation a)
93a96
>         _annotation = a;
114a118,120
>
>     public SchemaAnnotation getAnnotation()
>         { return _annotation; }
Index: src/typeimpl/org/apache/xmlbeans/impl/schema/SchemaIdentityConstraintImpl.java
===================================================================
RCS file: /home/cvs/xml-xmlbeans/v2/src/typeimpl/org/apache/xmlbeans/impl/schema/SchemaIdentityConstraintImpl.java,v
retrieving revision 1.1
diff -r1.1 SchemaIdentityConstraintImpl.java
60a61
> import org.apache.xmlbeans.SchemaAnnotation;
76a78
>     private SchemaAnnotation _annotation;
105a108,117
>     }
>
>     public void setAnnotation(SchemaAnnotation ann)
>     {
>         _annotation = ann;
>     }
>
>     public SchemaAnnotation getAnnotation()
>     {
>         return _annotation;
Index: src/typeimpl/org/apache/xmlbeans/impl/schema/SchemaLocalAttributeImpl.java
===================================================================
RCS file: /home/cvs/xml-xmlbeans/v2/src/typeimpl/org/apache/xmlbeans/impl/schema/SchemaLocalAttributeImpl.java,v
retrieving revision 1.1
diff -r1.1 SchemaLocalAttributeImpl.java
59a60
> import org.apache.xmlbeans.SchemaAnnotation;
77c78
<     public void init(QName name, SchemaType.Ref typeref, int use, String deftext, XmlObject parseObject, XmlValueRef defvalue, boolean isFixed, SOAPArrayType
wsdlArray)
---
>     public void init(QName name, SchemaType.Ref typeref, int use, String deftext, XmlObject parseObject, XmlValueRef defvalue, boolean isFixed, SOAPArrayType
wsdlArray, SchemaAnnotation ann)
89a91
>         _annotation = ann;
99a102
>     private SchemaAnnotation _annotation;
130a134,136
>
>     public SchemaAnnotation getAnnotation()
>         { return _annotation; }
Index: src/typeimpl/org/apache/xmlbeans/impl/schema/SchemaLocalElementImpl.java
===================================================================
RCS file: /home/cvs/xml-xmlbeans/v2/src/typeimpl/org/apache/xmlbeans/impl/schema/SchemaLocalElementImpl.java,v
retrieving revision 1.1
diff -r1.1 SchemaLocalElementImpl.java
58a59
> import org.apache.xmlbeans.SchemaAnnotation;
71a73
>     private SchemaAnnotation _annotation;
113a116,120
>     public void setAnnotation(SchemaAnnotation ann)
>     {
>         _annotation = ann;
>     }
>
116a124,128
>     }
>
>     public SchemaAnnotation getAnnotation()
>     {
>         return _annotation;
Index: src/typeimpl/org/apache/xmlbeans/impl/schema/SchemaModelGroupImpl.java
===================================================================
RCS file: /home/cvs/xml-xmlbeans/v2/src/typeimpl/org/apache/xmlbeans/impl/schema/SchemaModelGroupImpl.java,v
retrieving revision 1.1
diff -r1.1 SchemaModelGroupImpl.java
59c59
< import org.apache.xmlbeans.SchemaModelGroup;
---
> import org.apache.xmlbeans.SchemaAnnotation;
60a61
> import org.apache.xmlbeans.SchemaModelGroup;
72a74
>     private SchemaAnnotation _annotation;
85c87
<     public void init(QName name, String targetNamespace, boolean chameleon, boolean redefinition, XmlObject x)
---
>     public void init(QName name, String targetNamespace, boolean chameleon, boolean redefinition, XmlObject x, SchemaAnnotation a)
93a96
>         _annotation = a;
117a121,123
>
>     public SchemaAnnotation getAnnotation()
>         { return _annotation; }
Index: src/typeimpl/org/apache/xmlbeans/impl/schema/SchemaTypeImpl.java
===================================================================
RCS file: /home/cvs/xml-xmlbeans/v2/src/typeimpl/org/apache/xmlbeans/impl/schema/SchemaTypeImpl.java,v
retrieving revision 1.2
diff -r1.2 SchemaTypeImpl.java
63a64
> import org.apache.xmlbeans.SchemaAnnotation;
90a92,94
>     // annotation on the type
>     private SchemaAnnotation _annotation;
>
416a421,426
>
>     public void setAnnotation(SchemaAnnotation ann)
>         { assertUnresolved(); _annotation = ann; }
>
>     public SchemaAnnotation getAnnotation()
>         { return _annotation; }
Index: src/typeimpl/org/apache/xmlbeans/impl/schema/SchemaTypeSystemImpl.java
===================================================================
RCS file: /home/cvs/xml-xmlbeans/v2/src/typeimpl/org/apache/xmlbeans/impl/schema/SchemaTypeSystemImpl.java,v
retrieving revision 1.1
diff -r1.1 SchemaTypeSystemImpl.java
85a86
> import org.apache.xmlbeans.SchemaAnnotation;
111a113,114
> import org.w3.x2001.xmlSchema.AppinfoDocument;
> import org.w3.x2001.xmlSchema.DocumentationDocument;
118c121
<     public static final int MINOR_VERSION = 18; // must be <= to be compatible---
>     public static final int MINOR_VERSION = 19; // must be <= to be compatible352a356,359
>             if (reader.atLeast(2, 19, 0))
>             {
>                 _annotations = reader.readAnnotations();
>             }
607a615
>         _annotations = state.annotations();
890a899,901
>     // top-level annotations
>     private List _annotations;
>
912a924
>     static private final SchemaAnnotation[] EMPTY_ANN_ARRAY = new SchemaAnnotation[0];
1305a1318
>             writeAnnotations(annotations());
1469a1483,1594
>         void writeAnnotation(SchemaAnnotation a)
>         {
>             // Write attributes
>             if (a == null)
>             {
>                 writeInt(-1);
>                 return;
>             }
>             SchemaAnnotation.Attribute[] attributes = a.getAttributes();
>             writeInt(attributes.length);
>             for (int i = 0; i < attributes.length; i++)
>             {
>                 QName name = attributes[i].getName();
>                 String value = attributes[i].getValue();
>                 writeQName(name);
>                 writeString(value);
>             }
>
>             // Write documentation items
>             XmlObject[] documentationItems = a.getUserInformation();
>             writeInt(documentationItems.length);
>             XmlOptions opt = new XmlOptions().setSaveOuter().
>                 setSaveAggresiveNamespaces();
>             for (int i = 0; i < documentationItems.length; i++)
>             {
>                 XmlObject doc = documentationItems[i];
>                 writeString(doc.xmlText(opt));
>             }
>
>             // Write application info items
>             XmlObject[] appInfoItems = a.getApplicationInformation();
>             writeInt(appInfoItems.length);
>             for (int i = 0; i < appInfoItems.length; i++)
>             {
>                 XmlObject doc = appInfoItems[i];
>                 writeString(doc.xmlText(opt));
>             }
>         }
>
>         SchemaAnnotation readAnnotation()
>         {
>             if (!atLeast(2, 19, 0))
>                 return null; // no annotations for this version of the file
>             // Read attributes
>             int n = readInt();
>             if (n == -1)
>                 return null;
>             SchemaAnnotation.Attribute[] attributes =
>                 new SchemaAnnotation.Attribute[n];
>             for (int i = 0; i < n; i++)
>             {
>                 QName name = readQName();
>                 String value = readString();
>                 attributes[i] = new SchemaAnnotationImpl.AttributeImpl(name, value);
>             }
>
>             // Read documentation items
>             n = readInt();
>             DocumentationDocument.Documentation[] documentationItems =
>                 new DocumentationDocument.Documentation[n];
>             for (int i = 0; i <  n; i++)
>             {
>                 String doc = readString();
>                 try
>                 {
>                     documentationItems[i] = DocumentationDocument.Factory.
>                         parse(doc).getDocumentation();
>                 }
>                 catch (XmlException e)
>                 {
>                     throw new RuntimeException( e.getMessage(), e );
>                 }
>             }
>
>             // Read application info items
>             n = readInt();
>             AppinfoDocument.Appinfo[] appInfoItems =
>                 new AppinfoDocument.Appinfo[n];
>             for (int i = 0; i < n; i++)
>             {
>                 String appInfo = readString();
>                 try
>                 {
>                     appInfoItems[i] = AppinfoDocument.Factory.
>                         parse(appInfo).getAppinfo();
>                 }
>                 catch(XmlException e)
>                 {
>                     throw new RuntimeException( e.getMessage(), e );
>                 }
>             }
>
>             return new SchemaAnnotationImpl(getTypeSystem(), appInfoItems,
>                 documentationItems, attributes);
>         }
>
>         void writeAnnotations(SchemaAnnotation[] anns)
>         {
>             writeInt(anns.length);
>             for (int i = 0; i < anns.length; i++)
>                 writeAnnotation(anns[i]);
>         }
>
>         List readAnnotations()
>         {
>             int n = readInt();
>             List result = new ArrayList(n);
>             for (int i = 0; i < n; i++)
>                 result.add(readAnnotation());
>             return result;
>         }
>
1789a1915
>                 impl.setAnnotation(readAnnotation());
1857a1984
>                 impl.setAnnotation(readAnnotation());
2064a2192
>             writeAnnotation(type.getAnnotation());
2269c2397
<                 result.init(readQName(), readString(), readShort() == 1, atLeast(2, 15, 0) ? readShort() == 1 : false, GroupDocument.Factory.parse( readString() ).getGroup());
---
>                 result.init(readQName(), readString(), readShort() == 1, atLeast(2, 15, 0) ? readShort() == 1 : false, GroupDocument.Factory.parse( readString() ).getGroup(), readAnnotation());
2281c2409
<                 result.init( readQName(), readString(), readShort() == 1, atLeast(2, 15, 0) ? readShort() == 1 : false, AttributeGroupDocument.Factory.parse(
readString() ).getAttributeGroup());
---
>                 result.init( readQName(), readString(), readShort() == 1, atLeast(2, 15, 0) ? readShort() == 1 : false, AttributeGroupDocument.Factory.parse(
readString() ).getAttributeGroup(), readAnnotation());
2291,2292c2419,2420
<             // name, type, use, deftext, defval, fixed, soaparraytype
<             result.init(readQName(), readTypeRef(), readShort(), readString(), null, atLeast(2, 16, 0) ? readXmlValueObject() : null, readShort() == 1, readSOAPArrayType());
---
>             // name, type, use, deftext, defval, fixed, soaparraytype, annotation
>             result.init(readQName(), readTypeRef(), readShort(), readString(), null, atLeast(2, 16, 0) ? readXmlValueObject() : null, readShort() == 1, readSOAPArrayType(), readAnnotation());
2303a2432
>             writeAnnotation(attr.getAnnotation());
2310a2440
>             writeAnnotation(idc.getAnnotation());
2390a2521
>                     lresult.setAnnotation(readAnnotation());
2477a2609
>                     writeAnnotation(lpart.getAnnotation());
2584a2717
>             writeAnnotation(impl.getAnnotation());
2594a2728
>             writeAnnotation(impl.getAnnotation());
3118a3253,3262
>         return result;
>     }
>
>     public SchemaAnnotation[] annotations()
>     {
>         if (_annotations.isEmpty())
>             return EMPTY_ANN_ARRAY;
>
>         SchemaAnnotation[] result = new SchemaAnnotation[_annotations.size()];>         result = (SchemaAnnotation[]) _annotations.toArray(result);
Index: src/typeimpl/org/apache/xmlbeans/impl/schema/StscSimpleTypeResolver.java
===================================================================
RCS file: /home/cvs/xml-xmlbeans/v2/src/typeimpl/org/apache/xmlbeans/impl/schema/StscSimpleTypeResolver.java,v
retrieving revision 1.1
diff -r1.1 StscSimpleTypeResolver.java
220a221,222
>             SchemaAnnotationImpl ann = SchemaAnnotationImpl.getAnnotation(state.sts(), parseInner);
>             itemImpl.setAnnotation(ann);
331a334,335
>             SchemaAnnotationImpl ann = SchemaAnnotationImpl.getAnnotation(state.sts(), simpleTypes[i]);
>             mImpl.setAnnotation(ann);
444a449,450
>             SchemaAnnotationImpl ann = SchemaAnnotationImpl.getAnnotation(state.sts(), parseInner);
>             baseImpl.setAnnotation(ann);
Index: src/typeimpl/org/apache/xmlbeans/impl/schema/StscState.java
===================================================================
RCS file: /home/cvs/xml-xmlbeans/v2/src/typeimpl/org/apache/xmlbeans/impl/schema/StscState.java,v
retrieving revision 1.1
diff -r1.1 StscState.java
120a121
>     private List _annotations       = new ArrayList();
122a124
>     private boolean _noAnn;
309a312,313
>         _noAnn = options.hasOption(XmlOptions.COMPILE_NO_ANNOTATIONS) ? true :>             !"true".equals(System.getProperty("xmlbean.schemaannotations", "true"));
343c347,354
<
---
>
>     /**
>      * True if annotations should be skipped
>      */
>     public boolean noAnn()
>     {
>         return _noAnn;
>     }
751a763,773
>
>     /* ANNOTATIONS ===========================================*/
>
>     void addAnnotation(SchemaAnnotationImpl ann)
>     {
>         if (ann != null)
>             _annotations.add(ann);
>     }
>
>     List annotations()
>     { return _annotations; }
Index: src/typeimpl/org/apache/xmlbeans/impl/schema/StscTranslator.java
===================================================================
RCS file: /home/cvs/xml-xmlbeans/v2/src/typeimpl/org/apache/xmlbeans/impl/schema/StscTranslator.java,v
retrieving revision 1.1
diff -r1.1 StscTranslator.java
184c184,188
<
---
>
>         AnnotationDocument.Annotation[] annotations = schema.getAnnotationArray();
>         for (int i = 0; i < annotations.length; i++)
>             state.addAnnotation(SchemaAnnotationImpl.getAnnotation(state.sts(), schema, annotations[i]));
>
379a384
>         sType.setAnnotation(SchemaAnnotationImpl.getAnnotation(state.sts(), xsdType));
413a419
>         sType.setAnnotation(SchemaAnnotationImpl.getAnnotation(state.sts(), xsdType));
445a452
>         target.setAnnotation(referenced.getAnnotation());
455c462,463
<             referenced.getWSDLArrayType() );
---
>             referenced.getWSDLArrayType(),
>             referenced.getAnnotation());
602a611,612
>         SchemaAnnotationImpl ann = SchemaAnnotationImpl.getAnnotation(state.sts(), xsdElt);
>         impl.setAnnotation(ann);
611c621
<         XmlObject typedef = xsdElt.getComplexType();
---
>         Annotated typedef = xsdElt.getComplexType();
633a644
>             sTypeImpl.setAnnotation(SchemaAnnotationImpl.getAnnotation(state.sts(), typedef));
812a824,825
>         SchemaAnnotationImpl ann = SchemaAnnotationImpl.getAnnotation(state.sts(), parseIC);
>         ic.setAnnotation(ann);
852,853c865,868
<         SchemaModelGroupImpl result = new SchemaModelGroupImpl(StscState.get().sts());
<         result.init(QNameHelper.forLNS(name, targetNamespace), targetNamespace, chameleon, redefinition, namedGroup);
---
>         SchemaTypeSystemImpl sts = StscState.get().sts();
>         SchemaModelGroupImpl result = new SchemaModelGroupImpl(sts);
>         SchemaAnnotationImpl ann = SchemaAnnotationImpl.getAnnotation(sts, namedGroup);
>         result.init(QNameHelper.forLNS(name, targetNamespace), targetNamespace, chameleon, redefinition, namedGroup, ann);
865,866c880,883
<         SchemaAttributeGroupImpl result = new SchemaAttributeGroupImpl(StscState.get().sts());
<         result.init(QNameHelper.forLNS(name, targetNamespace), targetNamespace, chameleon, redefinition, attrGroup);
---
>         SchemaTypeSystemImpl ts = StscState.get().sts();
>         SchemaAttributeGroupImpl result = new SchemaAttributeGroupImpl(ts);
>         SchemaAnnotationImpl ann = SchemaAnnotationImpl.getAnnotation(ts, attrGroup);
>         result.init(QNameHelper.forLNS(name, targetNamespace), targetNamespace, chameleon, redefinition, attrGroup, ann);
989c1006
<             XmlObject typedef = xsdAttr.getSimpleType();
---
>             LocalSimpleType typedef = xsdAttr.getSimpleType();
1006a1024
>                 sTypeImpl.setAnnotation(SchemaAnnotationImpl.getAnnotation(state.sts(), typedef));
1061a1080,1081
>         SchemaAnnotationImpl ann = SchemaAnnotationImpl.getAnnotation(state.sts(),
>             xsdAttr);
1067c1087
<             wat);
---
>             wat, ann);
Index: src/xmlcomp/org/apache/xmlbeans/impl/tool/SchemaCompiler.java
===================================================================
RCS file: /home/cvs/xml-xmlbeans/v2/src/xmlcomp/org/apache/xmlbeans/impl/tool/SchemaCompiler.java,v
retrieving revision 1.1
diff -r1.1 SchemaCompiler.java
99a100
>             System.out.println("    -noann - ignore annotations");
157a159
>         boolean noAnn = (cl.getOpt("noann") != null);
297a300
>         params.setNoAnn(noAnn);
338a342
>         private boolean noAnn;
504a509,518
>         public boolean isNoAnn()
>         {
>             return noAnn;
>         }
>
>         public void setNoAnn(boolean noAnn)
>         {
>             this.noAnn = noAnn;
>         }
>
609,610c623,625
<         boolean download, boolean noUpa, boolean noPvr, Set mdefNamespaces,
<         File baseDir, Map sourcesToCopyMap, Collection outerErrorListener)
---
>         boolean download, boolean noUpa, boolean noPvr, boolean noAnn,
>         Set mdefNamespaces, File baseDir, Map sourcesToCopyMap,
>         Collection outerErrorListener)
755a771,772
>         if (noAnn)
>             opts.setCompileNoAnnotations();
796a814
>         boolean noAnn = params.isNoAnn();
823c841
<         SchemaTypeSystem system = loadTypeSystem(name, xsdFiles, wsdlFiles, configFiles, cpResourceLoader, download, noUpa, noPvr, mdefNamespaces, baseDir, sourcesToCopyMap, errorListener);
---
>         SchemaTypeSystem system = loadTypeSystem(name, xsdFiles, wsdlFiles, configFiles, cpResourceLoader, download, noUpa, noPvr, noAnn, mdefNamespaces, baseDir, sourcesToCopyMap, errorListener);
Index: src/xmlcomp/org/apache/xmlbeans/impl/tool/XsbDumper.java
===================================================================
RCS file: /home/cvs/xml-xmlbeans/v2/src/xmlcomp/org/apache/xmlbeans/impl/tool/XsbDumper.java,v
retrieving revision 1.1
diff -r1.1 XsbDumper.java
175c175
<     public static final int MINOR_VERSION = 16;
---
>     public static final int MINOR_VERSION = 19;
431a432,435
>         // version 19 annotations
>         if (atLeast(2, 19, 0))
>             dumpAnnotations();
>
658a663,725
>     void dumpAnnotation()
>     {
>         if (!atLeast(2, 19, 0))
>             return; // no annotations in this version of the file
>
>         int n = readInt();
>         if (n == -1)
>             return; // no annotation present
>         emit("Annotation");
>         boolean empty = true;
>         indent();
>         if (n > 0)
>         {
>             emit("Attributes (" + n + "):");
>             indent();
>             for (int i = 0; i < n; i++)
>             {
>                 emit("Name: " + qnameString(readQName()) +
>                     ", Value: " + readString());
>             }
>             outdent();
>             empty = false;
>         }
>
>         n = readInt();
>         if (n > 0)
>         {
>             emit("Documentation elements (" + n + "):");
>             indent();
>             for (int i = 0; i < n; i++)
>                 emit(readString());
>             outdent();
>             empty = false;
>         }
>
>         n = readInt();
>         if (n > 0)
>         {
>             emit("Appinfo elements (" + n + "):");
>             indent();
>             for (int i = 0; i < n; i++)
>                 emit(readString());
>             outdent();
>             empty = false;
>         }
>         if (empty)
>             emit("<empty>");
>         outdent();
>     }
>
>     void dumpAnnotations()
>     {
>         int n = readInt();
>         if (n > 0)
>         {
>             emit("Top-level annotations (" + n + "):");
>             indent();
>             for (int i = 0; i < n; i++)
>                 dumpAnnotation();
>             outdent();
>         }
>     }
>
685a753
>                 dumpAnnotation();
687a756,757
>                     if (atLeast(2, 17, 0))
>                         emit("Substitution group ref: " + readHandle());
806c876,877
<
---
>         dumpAnnotation();
>
976a1048
>         dumpAnnotation();
1006a1079
>         dumpAnnotation();
1017a1091
>         dumpAnnotation();
1070c1144,1145
<         emit("Flags: " + propertyflagsString(readShort()));
---
>         short propflags = readShort();
>         emit("Flags: " + propertyflagsString(propflags));
1083a1159,1167
>         if ((propflags & FLAG_PROP_ISATTR) == 0 && atLeast(2, 17, 0))
>         {
>             short size = readShort();
>             emit("Accepted names (" + size + ")");
>             indent();
>             for (int i = 0; i < size; i++)
>                 emit(qnameString(readQName()));
>             outdent();
>         }
cvs server: src/xmlpublic/org/apache/xmlbeans/SchemaAnnotated.java is a new entry, no comparison available
cvs server: src/xmlpublic/org/apache/xmlbeans/SchemaAnnotation.java is a new entry, no comparison available
Index: src/xmlpublic/org/apache/xmlbeans/SchemaAttributeGroup.java
===================================================================
RCS file: /home/cvs/xml-xmlbeans/v2/src/xmlpublic/org/apache/xmlbeans/SchemaAttributeGroup.java,v
retrieving revision 1.1
diff -r1.1 SchemaAttributeGroup.java
74c74
< public interface SchemaAttributeGroup extends SchemaComponent
---
> public interface SchemaAttributeGroup extends SchemaComponent, SchemaAnnotatedIndex: src/xmlpublic/org/apache/xmlbeans/SchemaComponent.java
===================================================================
RCS file: /home/cvs/xml-xmlbeans/v2/src/xmlpublic/org/apache/xmlbeans/SchemaComponent.java,v
retrieving revision 1.1
diff -r1.1 SchemaComponent.java
92a93,94
>     /** An annotation. See {@link #getComponentType} */
>     static final int ANNOTATION = 8;
Index: src/xmlpublic/org/apache/xmlbeans/SchemaIdentityConstraint.java
===================================================================
RCS file: /home/cvs/xml-xmlbeans/v2/src/xmlpublic/org/apache/xmlbeans/SchemaIdentityConstraint.java,v
retrieving revision 1.1
diff -r1.1 SchemaIdentityConstraint.java
65c65
< public interface SchemaIdentityConstraint extends SchemaComponent
---
> public interface SchemaIdentityConstraint extends SchemaComponent, SchemaAnnotated
Index: src/xmlpublic/org/apache/xmlbeans/SchemaLocalAttribute.java
===================================================================
RCS file: /home/cvs/xml-xmlbeans/v2/src/xmlpublic/org/apache/xmlbeans/SchemaLocalAttribute.java,v
retrieving revision 1.1
diff -r1.1 SchemaLocalAttribute.java
62c62
< public interface SchemaLocalAttribute extends SchemaField
---
> public interface SchemaLocalAttribute extends SchemaField, SchemaAnnotated
Index: src/xmlpublic/org/apache/xmlbeans/SchemaLocalElement.java
===================================================================
RCS file: /home/cvs/xml-xmlbeans/v2/src/xmlpublic/org/apache/xmlbeans/SchemaLocalElement.java,v
retrieving revision 1.1
diff -r1.1 SchemaLocalElement.java
62c62
< public interface SchemaLocalElement extends SchemaField
---
> public interface SchemaLocalElement extends SchemaField, SchemaAnnotated
Index: src/xmlpublic/org/apache/xmlbeans/SchemaModelGroup.java
===================================================================
RCS file: /home/cvs/xml-xmlbeans/v2/src/xmlpublic/org/apache/xmlbeans/SchemaModelGroup.java,v
retrieving revision 1.1
diff -r1.1 SchemaModelGroup.java
72c72
< public interface SchemaModelGroup extends SchemaComponent
---
> public interface SchemaModelGroup extends SchemaComponent, SchemaAnnotated
Index: src/xmlpublic/org/apache/xmlbeans/SchemaType.java
===================================================================
RCS file: /home/cvs/xml-xmlbeans/v2/src/xmlpublic/org/apache/xmlbeans/SchemaType.java,v
retrieving revision 1.1
diff -r1.1 SchemaType.java
170c170
< public interface SchemaType extends SchemaComponent
---
> public interface SchemaType extends SchemaComponent, SchemaAnnotated
Index: src/xmlpublic/org/apache/xmlbeans/SchemaTypeSystem.java
===================================================================
RCS file: /home/cvs/xml-xmlbeans/v2/src/xmlpublic/org/apache/xmlbeans/SchemaTypeSystem.java,v
retrieving revision 1.1
diff -r1.1 SchemaTypeSystem.java
216a217,220
>      * Returns the top-level annotations */
>     public SchemaAnnotation[] annotations();
>
>     /**
Index: src/xmlpublic/org/apache/xmlbeans/XmlOptions.java
===================================================================
RCS file: /home/cvs/xml-xmlbeans/v2/src/xmlpublic/org/apache/xmlbeans/XmlOptions.java,v
retrieving revision 1.1
diff -r1.1 XmlOptions.java
526c526,536
<
---
>
>     /**
>      * if this option is set, the schema compiler will skip annotations when
>      * processing Schema components.
>      *
>      * @see XmlBeans#compileXsd
>      */
>     public XmlOptions setCompileNoAnnotations() {
>         return set( COMPILE_NO_ANNOTATIONS );
>     }
>
654a665,666
>     /** @exclude */
>     public static final String COMPILE_NO_ANNOTATIONS          =  "COMPILE_NO_ANNOTATIONS";

- ---------------------------------------------------------------------
To unsubscribe, e-mail:   xmlbeans-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xmlbeans-dev-help@xml.apache.org
Apache XMLBeans Project -- URL: http://xml.apache.org/xmlbeans/


Re: XMLSchema annotations

Posted by David Bau <da...@bea.com>.
Radu, thanks a ton for this.  The design looks good to me, and SOM support
for schema annotations will be very useful.

I'll get the change checked in to v2 soon.

David


----- Original Message ----- 
From: "Radu Preotiuc-Pietro" <ra...@bea.com>
To: <xm...@xml.apache.org>
Sent: Tuesday, November 11, 2003 7:02 PM
Subject: [xmlbeans-cvs] XMLSchema annotations


Hi xmlbeans-dev. As you know, the schema API in XMLBeans doesn't have a way
to access schema annotations, so I have been working on a patch to XMLBeans
that adds this. It should be useful for implementing anything that needs
schema annotations, like JAXB (JSR 31).
So, this patch adds annotation support to the SOM. In a few words, Schema
components that can be annotated implement now a SchemaAnnotated interface,
which contains a single method returning a SchemaAnnotation object, where
all the information is retrieved from.

Can I ask somebody to review the patch and merge it in for v2?

CVS diff:

Index: build.xml
===================================================================
RCS file: /home/cvs/xml-xmlbeans/v2/build.xml,v
retrieving revision 1.19
diff -r1.19 build.xml
841c841
<       <arg line="${repackage_arg} -name sXMLSCHEMA -cp
${xsdschema.compile.path} -srconly -d build/classes/xsdschema -src
build/src/xsdschema src/xsdschema/schema"/>
---
>       <arg line="${repackage_arg} -name sXMLSCHEMA -cp
${xsdschema.compile.path} -srconly -d build/classes/xsdschema -noann -src
build/src/xsdschema src/xsdschema/schema"/>
863c863
<       <arg line="${repackage_arg} -name sXMLLANG -d
build/classes/xmlschema -src build/src/xmlschema -srconly
src/xmlschema/schema"/>
---
>       <arg line="${repackage_arg} -name sXMLLANG -noann -d
build/classes/xmlschema -src build/src/xmlschema -srconly
src/xmlschema/schema"/>
897c897
<       <arg line="${repackage_arg} -name sXMLCONFIG -srconly -src
build/src/configschema -d build/classes/configschema
src/configschema/schema"/>
---
>       <arg line="${repackage_arg} -name sXMLCONFIG -srconly -noann -src
build/src/configschema -d build/classes/configschema
src/configschema/schema"/>
919c919
<       <arg line="${repackage_arg} -name sXMLTOOLS -srconly -src
build/src/toolschema -d build/classes/toolschema src/toolschema"/>
---
>       <arg line="${repackage_arg} -name sXMLTOOLS -srconly -noann -src
build/src/toolschema -d build/classes/toolschema src/toolschema"/>
Index: bin/dumpxsb
===================================================================
RCS file: /home/cvs/xml-xmlbeans/v2/bin/dumpxsb,v
retrieving revision 1.1
diff -r1.1 dumpxsb
1c1
< #!/#in/sh
---
> #!/bin/sh
7c7
< cp=$cp:$XMLBEANS_HOME/build/libuxbean.jar
---
> cp=$cp:$XMLBEANS_HOME/build/ar/xbean.jar
9,10c9
< java
< classpath $cp org.apache.xmleeans.impl.tool.psbDumper $*
---
> java -classpath $cp org.apache.xmlbeans.impl.tool.XsbDumper $*
Index: bin/scomp
===================================================================
RCS file: /home/cvs/xml-xmlbeans/v2/bin/scomp,v
retrieving revision 1.1
diff -r1.1 scomp
7c7
< cp=$cp:$XMLBEANS_HOME/build/ar/xbean.jar
---
>
cp=$cp:$XMLBEANS_HOME/build/ar/xbean.jar:$XMLBEANS_HOME/build/lib/jsr173_07_
api.jar
9c9
< java -classpath $cp ort.apache.xmlbeanseimpl.toolmSchemaCompiler $*
---
> java -classpath $cp org.apache.xmlbeans.impl.tool.SchemaCompiler $*
Index:
src/typeimpl/org/apache/xmlbeans/impl/schema/BuiltinSchemaTypeSystem.java===
================================================================
RCS file:
/home/cvs/xml-xmlbeans/v2/src/typeimpl/org/apache/xmlbeans/impl/schema/Built
inSchemaTypeSystem.java,v
retrieving revision 1.1
diff -r1.1 BuiltinSchemaTypeSystem.java
58a59
> import org.apache.xmlbeans.SchemaAnnotation;
98a100
>     private static final SchemaAnnotation[] EMPTY_SCHEMAANNOTATION_ARRAY =
new SchemaAnnotation[0];
483a486,493
>     }
>
>     /*
>      * Returns the top-level annotations.
>      */
>     public SchemaAnnotation[] annotations()
>     {
>         return EMPTY_SCHEMAANNOTATION_ARRAY;
cvs server:
src/typeimpl/org/apache/xmlbeans/impl/schema/SchemaAnnotationImpl.java is a
new entry, no comparison available
Index:
src/typeimpl/org/apache/xmlbeans/impl/schema/SchemaAttributeGroupImpl.java
===================================================================
RCS file:
/home/cvs/xml-xmlbeans/v2/src/typeimpl/org/apache/xmlbeans/impl/schema/Schem
aAttributeGroupImpl.java,v
retrieving revision 1.1
diff -r1.1 SchemaAttributeGroupImpl.java
59a60
> import org.apache.xmlbeans.SchemaAnnotation;
72a74
>     private SchemaAnnotation _annotation;
85c87
<     public void init(QName name, String targetNamespace, boolean
chameleon, boolean redefinition, XmlObject x)
---
>     public void init(QName name, String targetNamespace, boolean
chameleon, boolean redefinition, XmlObject x, SchemaAnnotation a)
93a96
>         _annotation = a;
114a118,120
>
>     public SchemaAnnotation getAnnotation()
>         { return _annotation; }
Index:
src/typeimpl/org/apache/xmlbeans/impl/schema/SchemaIdentityConstraintImpl.ja
va
===================================================================
RCS file:
/home/cvs/xml-xmlbeans/v2/src/typeimpl/org/apache/xmlbeans/impl/schema/Schem
aIdentityConstraintImpl.java,v
retrieving revision 1.1
diff -r1.1 SchemaIdentityConstraintImpl.java
60a61
> import org.apache.xmlbeans.SchemaAnnotation;
76a78
>     private SchemaAnnotation _annotation;
105a108,117
>     }
>
>     public void setAnnotation(SchemaAnnotation ann)
>     {
>         _annotation = ann;
>     }
>
>     public SchemaAnnotation getAnnotation()
>     {
>         return _annotation;
Index:
src/typeimpl/org/apache/xmlbeans/impl/schema/SchemaLocalAttributeImpl.java
===================================================================
RCS file:
/home/cvs/xml-xmlbeans/v2/src/typeimpl/org/apache/xmlbeans/impl/schema/Schem
aLocalAttributeImpl.java,v
retrieving revision 1.1
diff -r1.1 SchemaLocalAttributeImpl.java
59a60
> import org.apache.xmlbeans.SchemaAnnotation;
77c78
<     public void init(QName name, SchemaType.Ref typeref, int use, String
deftext, XmlObject parseObject, XmlValueRef defvalue, boolean isFixed,
SOAPArrayType
wsdlArray)
---
>     public void init(QName name, SchemaType.Ref typeref, int use, String
deftext, XmlObject parseObject, XmlValueRef defvalue, boolean isFixed,
SOAPArrayType
wsdlArray, SchemaAnnotation ann)
89a91
>         _annotation = ann;
99a102
>     private SchemaAnnotation _annotation;
130a134,136
>
>     public SchemaAnnotation getAnnotation()
>         { return _annotation; }
Index:
src/typeimpl/org/apache/xmlbeans/impl/schema/SchemaLocalElementImpl.java
===================================================================
RCS file:
/home/cvs/xml-xmlbeans/v2/src/typeimpl/org/apache/xmlbeans/impl/schema/Schem
aLocalElementImpl.java,v
retrieving revision 1.1
diff -r1.1 SchemaLocalElementImpl.java
58a59
> import org.apache.xmlbeans.SchemaAnnotation;
71a73
>     private SchemaAnnotation _annotation;
113a116,120
>     public void setAnnotation(SchemaAnnotation ann)
>     {
>         _annotation = ann;
>     }
>
116a124,128
>     }
>
>     public SchemaAnnotation getAnnotation()
>     {
>         return _annotation;
Index:
src/typeimpl/org/apache/xmlbeans/impl/schema/SchemaModelGroupImpl.java
===================================================================
RCS file:
/home/cvs/xml-xmlbeans/v2/src/typeimpl/org/apache/xmlbeans/impl/schema/Schem
aModelGroupImpl.java,v
retrieving revision 1.1
diff -r1.1 SchemaModelGroupImpl.java
59c59
< import org.apache.xmlbeans.SchemaModelGroup;
---
> import org.apache.xmlbeans.SchemaAnnotation;
60a61
> import org.apache.xmlbeans.SchemaModelGroup;
72a74
>     private SchemaAnnotation _annotation;
85c87
<     public void init(QName name, String targetNamespace, boolean
chameleon, boolean redefinition, XmlObject x)
---
>     public void init(QName name, String targetNamespace, boolean
chameleon, boolean redefinition, XmlObject x, SchemaAnnotation a)
93a96
>         _annotation = a;
117a121,123
>
>     public SchemaAnnotation getAnnotation()
>         { return _annotation; }
Index: src/typeimpl/org/apache/xmlbeans/impl/schema/SchemaTypeImpl.java
===================================================================
RCS file:
/home/cvs/xml-xmlbeans/v2/src/typeimpl/org/apache/xmlbeans/impl/schema/Schem
aTypeImpl.java,v
retrieving revision 1.2
diff -r1.2 SchemaTypeImpl.java
63a64
> import org.apache.xmlbeans.SchemaAnnotation;
90a92,94
>     // annotation on the type
>     private SchemaAnnotation _annotation;
>
416a421,426
>
>     public void setAnnotation(SchemaAnnotation ann)
>         { assertUnresolved(); _annotation = ann; }
>
>     public SchemaAnnotation getAnnotation()
>         { return _annotation; }
Index:
src/typeimpl/org/apache/xmlbeans/impl/schema/SchemaTypeSystemImpl.java
===================================================================
RCS file:
/home/cvs/xml-xmlbeans/v2/src/typeimpl/org/apache/xmlbeans/impl/schema/Schem
aTypeSystemImpl.java,v
retrieving revision 1.1
diff -r1.1 SchemaTypeSystemImpl.java
85a86
> import org.apache.xmlbeans.SchemaAnnotation;
111a113,114
> import org.w3.x2001.xmlSchema.AppinfoDocument;
> import org.w3.x2001.xmlSchema.DocumentationDocument;
118c121
<     public static final int MINOR_VERSION = 18; // must be <= to be
compatible---
>     public static final int MINOR_VERSION = 19; // must be <= to be
compatible352a356,359
>             if (reader.atLeast(2, 19, 0))
>             {
>                 _annotations = reader.readAnnotations();
>             }
607a615
>         _annotations = state.annotations();
890a899,901
>     // top-level annotations
>     private List _annotations;
>
912a924
>     static private final SchemaAnnotation[] EMPTY_ANN_ARRAY = new
SchemaAnnotation[0];
1305a1318
>             writeAnnotations(annotations());
1469a1483,1594
>         void writeAnnotation(SchemaAnnotation a)
>         {
>             // Write attributes
>             if (a == null)
>             {
>                 writeInt(-1);
>                 return;
>             }
>             SchemaAnnotation.Attribute[] attributes = a.getAttributes();
>             writeInt(attributes.length);
>             for (int i = 0; i < attributes.length; i++)
>             {
>                 QName name = attributes[i].getName();
>                 String value = attributes[i].getValue();
>                 writeQName(name);
>                 writeString(value);
>             }
>
>             // Write documentation items
>             XmlObject[] documentationItems = a.getUserInformation();
>             writeInt(documentationItems.length);
>             XmlOptions opt = new XmlOptions().setSaveOuter().
>                 setSaveAggresiveNamespaces();
>             for (int i = 0; i < documentationItems.length; i++)
>             {
>                 XmlObject doc = documentationItems[i];
>                 writeString(doc.xmlText(opt));
>             }
>
>             // Write application info items
>             XmlObject[] appInfoItems = a.getApplicationInformation();
>             writeInt(appInfoItems.length);
>             for (int i = 0; i < appInfoItems.length; i++)
>             {
>                 XmlObject doc = appInfoItems[i];
>                 writeString(doc.xmlText(opt));
>             }
>         }
>
>         SchemaAnnotation readAnnotation()
>         {
>             if (!atLeast(2, 19, 0))
>                 return null; // no annotations for this version of the
file
>             // Read attributes
>             int n = readInt();
>             if (n == -1)
>                 return null;
>             SchemaAnnotation.Attribute[] attributes =
>                 new SchemaAnnotation.Attribute[n];
>             for (int i = 0; i < n; i++)
>             {
>                 QName name = readQName();
>                 String value = readString();
>                 attributes[i] = new
SchemaAnnotationImpl.AttributeImpl(name, value);
>             }
>
>             // Read documentation items
>             n = readInt();
>             DocumentationDocument.Documentation[] documentationItems =
>                 new DocumentationDocument.Documentation[n];
>             for (int i = 0; i <  n; i++)
>             {
>                 String doc = readString();
>                 try
>                 {
>                     documentationItems[i] = DocumentationDocument.Factory.
>                         parse(doc).getDocumentation();
>                 }
>                 catch (XmlException e)
>                 {
>                     throw new RuntimeException( e.getMessage(), e );
>                 }
>             }
>
>             // Read application info items
>             n = readInt();
>             AppinfoDocument.Appinfo[] appInfoItems =
>                 new AppinfoDocument.Appinfo[n];
>             for (int i = 0; i < n; i++)
>             {
>                 String appInfo = readString();
>                 try
>                 {
>                     appInfoItems[i] = AppinfoDocument.Factory.
>                         parse(appInfo).getAppinfo();
>                 }
>                 catch(XmlException e)
>                 {
>                     throw new RuntimeException( e.getMessage(), e );
>                 }
>             }
>
>             return new SchemaAnnotationImpl(getTypeSystem(), appInfoItems,
>                 documentationItems, attributes);
>         }
>
>         void writeAnnotations(SchemaAnnotation[] anns)
>         {
>             writeInt(anns.length);
>             for (int i = 0; i < anns.length; i++)
>                 writeAnnotation(anns[i]);
>         }
>
>         List readAnnotations()
>         {
>             int n = readInt();
>             List result = new ArrayList(n);
>             for (int i = 0; i < n; i++)
>                 result.add(readAnnotation());
>             return result;
>         }
>
1789a1915
>                 impl.setAnnotation(readAnnotation());
1857a1984
>                 impl.setAnnotation(readAnnotation());
2064a2192
>             writeAnnotation(type.getAnnotation());
2269c2397
<                 result.init(readQName(), readString(), readShort() == 1,
atLeast(2, 15, 0) ? readShort() == 1 : false, GroupDocument.Factory.parse(
readString() ).getGroup());
---
>                 result.init(readQName(), readString(), readShort() == 1,
atLeast(2, 15, 0) ? readShort() == 1 : false, GroupDocument.Factory.parse(
readString() ).getGroup(), readAnnotation());
2281c2409
<                 result.init( readQName(), readString(), readShort() == 1,
atLeast(2, 15, 0) ? readShort() == 1 : false,
AttributeGroupDocument.Factory.parse(
readString() ).getAttributeGroup());
---
>                 result.init( readQName(), readString(), readShort() == 1,
atLeast(2, 15, 0) ? readShort() == 1 : false,
AttributeGroupDocument.Factory.parse(
readString() ).getAttributeGroup(), readAnnotation());
2291,2292c2419,2420
<             // name, type, use, deftext, defval, fixed, soaparraytype
<             result.init(readQName(), readTypeRef(), readShort(),
readString(), null, atLeast(2, 16, 0) ? readXmlValueObject() : null,
readShort() == 1, readSOAPArrayType());
---
>             // name, type, use, deftext, defval, fixed, soaparraytype,
annotation
>             result.init(readQName(), readTypeRef(), readShort(),
readString(), null, atLeast(2, 16, 0) ? readXmlValueObject() : null,
readShort() == 1, readSOAPArrayType(), readAnnotation());
2303a2432
>             writeAnnotation(attr.getAnnotation());
2310a2440
>             writeAnnotation(idc.getAnnotation());
2390a2521
>                     lresult.setAnnotation(readAnnotation());
2477a2609
>                     writeAnnotation(lpart.getAnnotation());
2584a2717
>             writeAnnotation(impl.getAnnotation());
2594a2728
>             writeAnnotation(impl.getAnnotation());
3118a3253,3262
>         return result;
>     }
>
>     public SchemaAnnotation[] annotations()
>     {
>         if (_annotations.isEmpty())
>             return EMPTY_ANN_ARRAY;
>
>         SchemaAnnotation[] result = new
SchemaAnnotation[_annotations.size()];>         result =
(SchemaAnnotation[]) _annotations.toArray(result);
Index:
src/typeimpl/org/apache/xmlbeans/impl/schema/StscSimpleTypeResolver.java
===================================================================
RCS file:
/home/cvs/xml-xmlbeans/v2/src/typeimpl/org/apache/xmlbeans/impl/schema/StscS
impleTypeResolver.java,v
retrieving revision 1.1
diff -r1.1 StscSimpleTypeResolver.java
220a221,222
>             SchemaAnnotationImpl ann =
SchemaAnnotationImpl.getAnnotation(state.sts(), parseInner);
>             itemImpl.setAnnotation(ann);
331a334,335
>             SchemaAnnotationImpl ann =
SchemaAnnotationImpl.getAnnotation(state.sts(), simpleTypes[i]);
>             mImpl.setAnnotation(ann);
444a449,450
>             SchemaAnnotationImpl ann =
SchemaAnnotationImpl.getAnnotation(state.sts(), parseInner);
>             baseImpl.setAnnotation(ann);
Index: src/typeimpl/org/apache/xmlbeans/impl/schema/StscState.java
===================================================================
RCS file:
/home/cvs/xml-xmlbeans/v2/src/typeimpl/org/apache/xmlbeans/impl/schema/StscS
tate.java,v
retrieving revision 1.1
diff -r1.1 StscState.java
120a121
>     private List _annotations       = new ArrayList();
122a124
>     private boolean _noAnn;
309a312,313
>         _noAnn = options.hasOption(XmlOptions.COMPILE_NO_ANNOTATIONS) ?
true :>
!"true".equals(System.getProperty("xmlbean.schemaannotations", "true"));
343c347,354
<
---
>
>     /**
>      * True if annotations should be skipped
>      */
>     public boolean noAnn()
>     {
>         return _noAnn;
>     }
751a763,773
>
>     /* ANNOTATIONS ===========================================*/
>
>     void addAnnotation(SchemaAnnotationImpl ann)
>     {
>         if (ann != null)
>             _annotations.add(ann);
>     }
>
>     List annotations()
>     { return _annotations; }
Index: src/typeimpl/org/apache/xmlbeans/impl/schema/StscTranslator.java
===================================================================
RCS file:
/home/cvs/xml-xmlbeans/v2/src/typeimpl/org/apache/xmlbeans/impl/schema/StscT
ranslator.java,v
retrieving revision 1.1
diff -r1.1 StscTranslator.java
184c184,188
<
---
>
>         AnnotationDocument.Annotation[] annotations =
schema.getAnnotationArray();
>         for (int i = 0; i < annotations.length; i++)
>
state.addAnnotation(SchemaAnnotationImpl.getAnnotation(state.sts(), schema,
annotations[i]));
>
379a384
>
sType.setAnnotation(SchemaAnnotationImpl.getAnnotation(state.sts(),
xsdType));
413a419
>
sType.setAnnotation(SchemaAnnotationImpl.getAnnotation(state.sts(),
xsdType));
445a452
>         target.setAnnotation(referenced.getAnnotation());
455c462,463
<             referenced.getWSDLArrayType() );
---
>             referenced.getWSDLArrayType(),
>             referenced.getAnnotation());
602a611,612
>         SchemaAnnotationImpl ann =
SchemaAnnotationImpl.getAnnotation(state.sts(), xsdElt);
>         impl.setAnnotation(ann);
611c621
<         XmlObject typedef = xsdElt.getComplexType();
---
>         Annotated typedef = xsdElt.getComplexType();
633a644
>
sTypeImpl.setAnnotation(SchemaAnnotationImpl.getAnnotation(state.sts(),
typedef));
812a824,825
>         SchemaAnnotationImpl ann =
SchemaAnnotationImpl.getAnnotation(state.sts(), parseIC);
>         ic.setAnnotation(ann);
852,853c865,868
<         SchemaModelGroupImpl result = new
SchemaModelGroupImpl(StscState.get().sts());
<         result.init(QNameHelper.forLNS(name, targetNamespace),
targetNamespace, chameleon, redefinition, namedGroup);
---
>         SchemaTypeSystemImpl sts = StscState.get().sts();
>         SchemaModelGroupImpl result = new SchemaModelGroupImpl(sts);
>         SchemaAnnotationImpl ann = SchemaAnnotationImpl.getAnnotation(sts,
namedGroup);
>         result.init(QNameHelper.forLNS(name, targetNamespace),
targetNamespace, chameleon, redefinition, namedGroup, ann);
865,866c880,883
<         SchemaAttributeGroupImpl result = new
SchemaAttributeGroupImpl(StscState.get().sts());
<         result.init(QNameHelper.forLNS(name, targetNamespace),
targetNamespace, chameleon, redefinition, attrGroup);
---
>         SchemaTypeSystemImpl ts = StscState.get().sts();
>         SchemaAttributeGroupImpl result = new
SchemaAttributeGroupImpl(ts);
>         SchemaAnnotationImpl ann = SchemaAnnotationImpl.getAnnotation(ts,
attrGroup);
>         result.init(QNameHelper.forLNS(name, targetNamespace),
targetNamespace, chameleon, redefinition, attrGroup, ann);
989c1006
<             XmlObject typedef = xsdAttr.getSimpleType();
---
>             LocalSimpleType typedef = xsdAttr.getSimpleType();
1006a1024
>
sTypeImpl.setAnnotation(SchemaAnnotationImpl.getAnnotation(state.sts(),
typedef));
1061a1080,1081
>         SchemaAnnotationImpl ann =
SchemaAnnotationImpl.getAnnotation(state.sts(),
>             xsdAttr);
1067c1087
<             wat);
---
>             wat, ann);
Index: src/xmlcomp/org/apache/xmlbeans/impl/tool/SchemaCompiler.java
===================================================================
RCS file:
/home/cvs/xml-xmlbeans/v2/src/xmlcomp/org/apache/xmlbeans/impl/tool/SchemaCo
mpiler.java,v
retrieving revision 1.1
diff -r1.1 SchemaCompiler.java
99a100
>             System.out.println("    -noann - ignore annotations");
157a159
>         boolean noAnn = (cl.getOpt("noann") != null);
297a300
>         params.setNoAnn(noAnn);
338a342
>         private boolean noAnn;
504a509,518
>         public boolean isNoAnn()
>         {
>             return noAnn;
>         }
>
>         public void setNoAnn(boolean noAnn)
>         {
>             this.noAnn = noAnn;
>         }
>
609,610c623,625
<         boolean download, boolean noUpa, boolean noPvr, Set
mdefNamespaces,
<         File baseDir, Map sourcesToCopyMap, Collection outerErrorListener)
---
>         boolean download, boolean noUpa, boolean noPvr, boolean noAnn,
>         Set mdefNamespaces, File baseDir, Map sourcesToCopyMap,
>         Collection outerErrorListener)
755a771,772
>         if (noAnn)
>             opts.setCompileNoAnnotations();
796a814
>         boolean noAnn = params.isNoAnn();
823c841
<         SchemaTypeSystem system = loadTypeSystem(name, xsdFiles,
wsdlFiles, configFiles, cpResourceLoader, download, noUpa, noPvr,
mdefNamespaces, baseDir, sourcesToCopyMap, errorListener);
---
>         SchemaTypeSystem system = loadTypeSystem(name, xsdFiles,
wsdlFiles, configFiles, cpResourceLoader, download, noUpa, noPvr, noAnn,
mdefNamespaces, baseDir, sourcesToCopyMap, errorListener);
Index: src/xmlcomp/org/apache/xmlbeans/impl/tool/XsbDumper.java
===================================================================
RCS file:
/home/cvs/xml-xmlbeans/v2/src/xmlcomp/org/apache/xmlbeans/impl/tool/XsbDumpe
r.java,v
retrieving revision 1.1
diff -r1.1 XsbDumper.java
175c175
<     public static final int MINOR_VERSION = 16;
---
>     public static final int MINOR_VERSION = 19;
431a432,435
>         // version 19 annotations
>         if (atLeast(2, 19, 0))
>             dumpAnnotations();
>
658a663,725
>     void dumpAnnotation()
>     {
>         if (!atLeast(2, 19, 0))
>             return; // no annotations in this version of the file
>
>         int n = readInt();
>         if (n == -1)
>             return; // no annotation present
>         emit("Annotation");
>         boolean empty = true;
>         indent();
>         if (n > 0)
>         {
>             emit("Attributes (" + n + "):");
>             indent();
>             for (int i = 0; i < n; i++)
>             {
>                 emit("Name: " + qnameString(readQName()) +
>                     ", Value: " + readString());
>             }
>             outdent();
>             empty = false;
>         }
>
>         n = readInt();
>         if (n > 0)
>         {
>             emit("Documentation elements (" + n + "):");
>             indent();
>             for (int i = 0; i < n; i++)
>                 emit(readString());
>             outdent();
>             empty = false;
>         }
>
>         n = readInt();
>         if (n > 0)
>         {
>             emit("Appinfo elements (" + n + "):");
>             indent();
>             for (int i = 0; i < n; i++)
>                 emit(readString());
>             outdent();
>             empty = false;
>         }
>         if (empty)
>             emit("<empty>");
>         outdent();
>     }
>
>     void dumpAnnotations()
>     {
>         int n = readInt();
>         if (n > 0)
>         {
>             emit("Top-level annotations (" + n + "):");
>             indent();
>             for (int i = 0; i < n; i++)
>                 dumpAnnotation();
>             outdent();
>         }
>     }
>
685a753
>                 dumpAnnotation();
687a756,757
>                     if (atLeast(2, 17, 0))
>                         emit("Substitution group ref: " + readHandle());
806c876,877
<
---
>         dumpAnnotation();
>
976a1048
>         dumpAnnotation();
1006a1079
>         dumpAnnotation();
1017a1091
>         dumpAnnotation();
1070c1144,1145
<         emit("Flags: " + propertyflagsString(readShort()));
---
>         short propflags = readShort();
>         emit("Flags: " + propertyflagsString(propflags));
1083a1159,1167
>         if ((propflags & FLAG_PROP_ISATTR) == 0 && atLeast(2, 17, 0))
>         {
>             short size = readShort();
>             emit("Accepted names (" + size + ")");
>             indent();
>             for (int i = 0; i < size; i++)
>                 emit(qnameString(readQName()));
>             outdent();
>         }
cvs server: src/xmlpublic/org/apache/xmlbeans/SchemaAnnotated.java is a new
entry, no comparison available
cvs server: src/xmlpublic/org/apache/xmlbeans/SchemaAnnotation.java is a new
entry, no comparison available
Index: src/xmlpublic/org/apache/xmlbeans/SchemaAttributeGroup.java
===================================================================
RCS file:
/home/cvs/xml-xmlbeans/v2/src/xmlpublic/org/apache/xmlbeans/SchemaAttributeG
roup.java,v
retrieving revision 1.1
diff -r1.1 SchemaAttributeGroup.java
74c74
< public interface SchemaAttributeGroup extends SchemaComponent
---
> public interface SchemaAttributeGroup extends SchemaComponent,
SchemaAnnotatedIndex: src/xmlpublic/org/apache/xmlbeans/SchemaComponent.java
===================================================================
RCS file:
/home/cvs/xml-xmlbeans/v2/src/xmlpublic/org/apache/xmlbeans/SchemaComponent.
java,v
retrieving revision 1.1
diff -r1.1 SchemaComponent.java
92a93,94
>     /** An annotation. See {@link #getComponentType} */
>     static final int ANNOTATION = 8;
Index: src/xmlpublic/org/apache/xmlbeans/SchemaIdentityConstraint.java
===================================================================
RCS file:
/home/cvs/xml-xmlbeans/v2/src/xmlpublic/org/apache/xmlbeans/SchemaIdentityCo
nstraint.java,v
retrieving revision 1.1
diff -r1.1 SchemaIdentityConstraint.java
65c65
< public interface SchemaIdentityConstraint extends SchemaComponent
---
> public interface SchemaIdentityConstraint extends SchemaComponent,
SchemaAnnotated
Index: src/xmlpublic/org/apache/xmlbeans/SchemaLocalAttribute.java
===================================================================
RCS file:
/home/cvs/xml-xmlbeans/v2/src/xmlpublic/org/apache/xmlbeans/SchemaLocalAttri
bute.java,v
retrieving revision 1.1
diff -r1.1 SchemaLocalAttribute.java
62c62
< public interface SchemaLocalAttribute extends SchemaField
---
> public interface SchemaLocalAttribute extends SchemaField, SchemaAnnotated
Index: src/xmlpublic/org/apache/xmlbeans/SchemaLocalElement.java
===================================================================
RCS file:
/home/cvs/xml-xmlbeans/v2/src/xmlpublic/org/apache/xmlbeans/SchemaLocalEleme
nt.java,v
retrieving revision 1.1
diff -r1.1 SchemaLocalElement.java
62c62
< public interface SchemaLocalElement extends SchemaField
---
> public interface SchemaLocalElement extends SchemaField, SchemaAnnotated
Index: src/xmlpublic/org/apache/xmlbeans/SchemaModelGroup.java
===================================================================
RCS file:
/home/cvs/xml-xmlbeans/v2/src/xmlpublic/org/apache/xmlbeans/SchemaModelGroup
.java,v
retrieving revision 1.1
diff -r1.1 SchemaModelGroup.java
72c72
< public interface SchemaModelGroup extends SchemaComponent
---
> public interface SchemaModelGroup extends SchemaComponent, SchemaAnnotated
Index: src/xmlpublic/org/apache/xmlbeans/SchemaType.java
===================================================================
RCS file:
/home/cvs/xml-xmlbeans/v2/src/xmlpublic/org/apache/xmlbeans/SchemaType.java,
v
retrieving revision 1.1
diff -r1.1 SchemaType.java
170c170
< public interface SchemaType extends SchemaComponent
---
> public interface SchemaType extends SchemaComponent, SchemaAnnotated
Index: src/xmlpublic/org/apache/xmlbeans/SchemaTypeSystem.java
===================================================================
RCS file:
/home/cvs/xml-xmlbeans/v2/src/xmlpublic/org/apache/xmlbeans/SchemaTypeSystem
.java,v
retrieving revision 1.1
diff -r1.1 SchemaTypeSystem.java
216a217,220
>      * Returns the top-level annotations */
>     public SchemaAnnotation[] annotations();
>
>     /**
Index: src/xmlpublic/org/apache/xmlbeans/XmlOptions.java
===================================================================
RCS file:
/home/cvs/xml-xmlbeans/v2/src/xmlpublic/org/apache/xmlbeans/XmlOptions.java,
v
retrieving revision 1.1
diff -r1.1 XmlOptions.java
526c526,536
<
---
>
>     /**
>      * if this option is set, the schema compiler will skip annotations
when
>      * processing Schema components.
>      *
>      * @see XmlBeans#compileXsd
>      */
>     public XmlOptions setCompileNoAnnotations() {
>         return set( COMPILE_NO_ANNOTATIONS );
>     }
>
654a665,666
>     /** @exclude */
>     public static final String COMPILE_NO_ANNOTATIONS          =
"COMPILE_NO_ANNOTATIONS";

- ---------------------------------------------------------------------
To unsubscribe, e-mail:   xmlbeans-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xmlbeans-dev-help@xml.apache.org
Apache XMLBeans Project -- URL: http://xml.apache.org/xmlbeans/



- ---------------------------------------------------------------------
To unsubscribe, e-mail:   xmlbeans-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xmlbeans-dev-help@xml.apache.org
Apache XMLBeans Project -- URL: http://xml.apache.org/xmlbeans/


Re: XMLSchema annotations

Posted by David Bau <da...@bea.com>.
Radu, thanks a ton for this.  The design looks good to me, and SOM support
for schema annotations will be very useful.

I'll get the change checked in to v2 soon.

David


----- Original Message ----- 
From: "Radu Preotiuc-Pietro" <ra...@bea.com>
To: <xm...@xml.apache.org>
Sent: Tuesday, November 11, 2003 7:02 PM
Subject: [xmlbeans-cvs] XMLSchema annotations


Hi xmlbeans-dev. As you know, the schema API in XMLBeans doesn't have a way
to access schema annotations, so I have been working on a patch to XMLBeans
that adds this. It should be useful for implementing anything that needs
schema annotations, like JAXB (JSR 31).
So, this patch adds annotation support to the SOM. In a few words, Schema
components that can be annotated implement now a SchemaAnnotated interface,
which contains a single method returning a SchemaAnnotation object, where
all the information is retrieved from.

Can I ask somebody to review the patch and merge it in for v2?

CVS diff:

Index: build.xml
===================================================================
RCS file: /home/cvs/xml-xmlbeans/v2/build.xml,v
retrieving revision 1.19
diff -r1.19 build.xml
841c841
<       <arg line="${repackage_arg} -name sXMLSCHEMA -cp
${xsdschema.compile.path} -srconly -d build/classes/xsdschema -src
build/src/xsdschema src/xsdschema/schema"/>
---
>       <arg line="${repackage_arg} -name sXMLSCHEMA -cp
${xsdschema.compile.path} -srconly -d build/classes/xsdschema -noann -src
build/src/xsdschema src/xsdschema/schema"/>
863c863
<       <arg line="${repackage_arg} -name sXMLLANG -d
build/classes/xmlschema -src build/src/xmlschema -srconly
src/xmlschema/schema"/>
---
>       <arg line="${repackage_arg} -name sXMLLANG -noann -d
build/classes/xmlschema -src build/src/xmlschema -srconly
src/xmlschema/schema"/>
897c897
<       <arg line="${repackage_arg} -name sXMLCONFIG -srconly -src
build/src/configschema -d build/classes/configschema
src/configschema/schema"/>
---
>       <arg line="${repackage_arg} -name sXMLCONFIG -srconly -noann -src
build/src/configschema -d build/classes/configschema
src/configschema/schema"/>
919c919
<       <arg line="${repackage_arg} -name sXMLTOOLS -srconly -src
build/src/toolschema -d build/classes/toolschema src/toolschema"/>
---
>       <arg line="${repackage_arg} -name sXMLTOOLS -srconly -noann -src
build/src/toolschema -d build/classes/toolschema src/toolschema"/>
Index: bin/dumpxsb
===================================================================
RCS file: /home/cvs/xml-xmlbeans/v2/bin/dumpxsb,v
retrieving revision 1.1
diff -r1.1 dumpxsb
1c1
< #!/#in/sh
---
> #!/bin/sh
7c7
< cp=$cp:$XMLBEANS_HOME/build/libuxbean.jar
---
> cp=$cp:$XMLBEANS_HOME/build/ar/xbean.jar
9,10c9
< java
< classpath $cp org.apache.xmleeans.impl.tool.psbDumper $*
---
> java -classpath $cp org.apache.xmlbeans.impl.tool.XsbDumper $*
Index: bin/scomp
===================================================================
RCS file: /home/cvs/xml-xmlbeans/v2/bin/scomp,v
retrieving revision 1.1
diff -r1.1 scomp
7c7
< cp=$cp:$XMLBEANS_HOME/build/ar/xbean.jar
---
>
cp=$cp:$XMLBEANS_HOME/build/ar/xbean.jar:$XMLBEANS_HOME/build/lib/jsr173_07_
api.jar
9c9
< java -classpath $cp ort.apache.xmlbeanseimpl.toolmSchemaCompiler $*
---
> java -classpath $cp org.apache.xmlbeans.impl.tool.SchemaCompiler $*
Index:
src/typeimpl/org/apache/xmlbeans/impl/schema/BuiltinSchemaTypeSystem.java===
================================================================
RCS file:
/home/cvs/xml-xmlbeans/v2/src/typeimpl/org/apache/xmlbeans/impl/schema/Built
inSchemaTypeSystem.java,v
retrieving revision 1.1
diff -r1.1 BuiltinSchemaTypeSystem.java
58a59
> import org.apache.xmlbeans.SchemaAnnotation;
98a100
>     private static final SchemaAnnotation[] EMPTY_SCHEMAANNOTATION_ARRAY =
new SchemaAnnotation[0];
483a486,493
>     }
>
>     /*
>      * Returns the top-level annotations.
>      */
>     public SchemaAnnotation[] annotations()
>     {
>         return EMPTY_SCHEMAANNOTATION_ARRAY;
cvs server:
src/typeimpl/org/apache/xmlbeans/impl/schema/SchemaAnnotationImpl.java is a
new entry, no comparison available
Index:
src/typeimpl/org/apache/xmlbeans/impl/schema/SchemaAttributeGroupImpl.java
===================================================================
RCS file:
/home/cvs/xml-xmlbeans/v2/src/typeimpl/org/apache/xmlbeans/impl/schema/Schem
aAttributeGroupImpl.java,v
retrieving revision 1.1
diff -r1.1 SchemaAttributeGroupImpl.java
59a60
> import org.apache.xmlbeans.SchemaAnnotation;
72a74
>     private SchemaAnnotation _annotation;
85c87
<     public void init(QName name, String targetNamespace, boolean
chameleon, boolean redefinition, XmlObject x)
---
>     public void init(QName name, String targetNamespace, boolean
chameleon, boolean redefinition, XmlObject x, SchemaAnnotation a)
93a96
>         _annotation = a;
114a118,120
>
>     public SchemaAnnotation getAnnotation()
>         { return _annotation; }
Index:
src/typeimpl/org/apache/xmlbeans/impl/schema/SchemaIdentityConstraintImpl.ja
va
===================================================================
RCS file:
/home/cvs/xml-xmlbeans/v2/src/typeimpl/org/apache/xmlbeans/impl/schema/Schem
aIdentityConstraintImpl.java,v
retrieving revision 1.1
diff -r1.1 SchemaIdentityConstraintImpl.java
60a61
> import org.apache.xmlbeans.SchemaAnnotation;
76a78
>     private SchemaAnnotation _annotation;
105a108,117
>     }
>
>     public void setAnnotation(SchemaAnnotation ann)
>     {
>         _annotation = ann;
>     }
>
>     public SchemaAnnotation getAnnotation()
>     {
>         return _annotation;
Index:
src/typeimpl/org/apache/xmlbeans/impl/schema/SchemaLocalAttributeImpl.java
===================================================================
RCS file:
/home/cvs/xml-xmlbeans/v2/src/typeimpl/org/apache/xmlbeans/impl/schema/Schem
aLocalAttributeImpl.java,v
retrieving revision 1.1
diff -r1.1 SchemaLocalAttributeImpl.java
59a60
> import org.apache.xmlbeans.SchemaAnnotation;
77c78
<     public void init(QName name, SchemaType.Ref typeref, int use, String
deftext, XmlObject parseObject, XmlValueRef defvalue, boolean isFixed,
SOAPArrayType
wsdlArray)
---
>     public void init(QName name, SchemaType.Ref typeref, int use, String
deftext, XmlObject parseObject, XmlValueRef defvalue, boolean isFixed,
SOAPArrayType
wsdlArray, SchemaAnnotation ann)
89a91
>         _annotation = ann;
99a102
>     private SchemaAnnotation _annotation;
130a134,136
>
>     public SchemaAnnotation getAnnotation()
>         { return _annotation; }
Index:
src/typeimpl/org/apache/xmlbeans/impl/schema/SchemaLocalElementImpl.java
===================================================================
RCS file:
/home/cvs/xml-xmlbeans/v2/src/typeimpl/org/apache/xmlbeans/impl/schema/Schem
aLocalElementImpl.java,v
retrieving revision 1.1
diff -r1.1 SchemaLocalElementImpl.java
58a59
> import org.apache.xmlbeans.SchemaAnnotation;
71a73
>     private SchemaAnnotation _annotation;
113a116,120
>     public void setAnnotation(SchemaAnnotation ann)
>     {
>         _annotation = ann;
>     }
>
116a124,128
>     }
>
>     public SchemaAnnotation getAnnotation()
>     {
>         return _annotation;
Index:
src/typeimpl/org/apache/xmlbeans/impl/schema/SchemaModelGroupImpl.java
===================================================================
RCS file:
/home/cvs/xml-xmlbeans/v2/src/typeimpl/org/apache/xmlbeans/impl/schema/Schem
aModelGroupImpl.java,v
retrieving revision 1.1
diff -r1.1 SchemaModelGroupImpl.java
59c59
< import org.apache.xmlbeans.SchemaModelGroup;
---
> import org.apache.xmlbeans.SchemaAnnotation;
60a61
> import org.apache.xmlbeans.SchemaModelGroup;
72a74
>     private SchemaAnnotation _annotation;
85c87
<     public void init(QName name, String targetNamespace, boolean
chameleon, boolean redefinition, XmlObject x)
---
>     public void init(QName name, String targetNamespace, boolean
chameleon, boolean redefinition, XmlObject x, SchemaAnnotation a)
93a96
>         _annotation = a;
117a121,123
>
>     public SchemaAnnotation getAnnotation()
>         { return _annotation; }
Index: src/typeimpl/org/apache/xmlbeans/impl/schema/SchemaTypeImpl.java
===================================================================
RCS file:
/home/cvs/xml-xmlbeans/v2/src/typeimpl/org/apache/xmlbeans/impl/schema/Schem
aTypeImpl.java,v
retrieving revision 1.2
diff -r1.2 SchemaTypeImpl.java
63a64
> import org.apache.xmlbeans.SchemaAnnotation;
90a92,94
>     // annotation on the type
>     private SchemaAnnotation _annotation;
>
416a421,426
>
>     public void setAnnotation(SchemaAnnotation ann)
>         { assertUnresolved(); _annotation = ann; }
>
>     public SchemaAnnotation getAnnotation()
>         { return _annotation; }
Index:
src/typeimpl/org/apache/xmlbeans/impl/schema/SchemaTypeSystemImpl.java
===================================================================
RCS file:
/home/cvs/xml-xmlbeans/v2/src/typeimpl/org/apache/xmlbeans/impl/schema/Schem
aTypeSystemImpl.java,v
retrieving revision 1.1
diff -r1.1 SchemaTypeSystemImpl.java
85a86
> import org.apache.xmlbeans.SchemaAnnotation;
111a113,114
> import org.w3.x2001.xmlSchema.AppinfoDocument;
> import org.w3.x2001.xmlSchema.DocumentationDocument;
118c121
<     public static final int MINOR_VERSION = 18; // must be <= to be
compatible---
>     public static final int MINOR_VERSION = 19; // must be <= to be
compatible352a356,359
>             if (reader.atLeast(2, 19, 0))
>             {
>                 _annotations = reader.readAnnotations();
>             }
607a615
>         _annotations = state.annotations();
890a899,901
>     // top-level annotations
>     private List _annotations;
>
912a924
>     static private final SchemaAnnotation[] EMPTY_ANN_ARRAY = new
SchemaAnnotation[0];
1305a1318
>             writeAnnotations(annotations());
1469a1483,1594
>         void writeAnnotation(SchemaAnnotation a)
>         {
>             // Write attributes
>             if (a == null)
>             {
>                 writeInt(-1);
>                 return;
>             }
>             SchemaAnnotation.Attribute[] attributes = a.getAttributes();
>             writeInt(attributes.length);
>             for (int i = 0; i < attributes.length; i++)
>             {
>                 QName name = attributes[i].getName();
>                 String value = attributes[i].getValue();
>                 writeQName(name);
>                 writeString(value);
>             }
>
>             // Write documentation items
>             XmlObject[] documentationItems = a.getUserInformation();
>             writeInt(documentationItems.length);
>             XmlOptions opt = new XmlOptions().setSaveOuter().
>                 setSaveAggresiveNamespaces();
>             for (int i = 0; i < documentationItems.length; i++)
>             {
>                 XmlObject doc = documentationItems[i];
>                 writeString(doc.xmlText(opt));
>             }
>
>             // Write application info items
>             XmlObject[] appInfoItems = a.getApplicationInformation();
>             writeInt(appInfoItems.length);
>             for (int i = 0; i < appInfoItems.length; i++)
>             {
>                 XmlObject doc = appInfoItems[i];
>                 writeString(doc.xmlText(opt));
>             }
>         }
>
>         SchemaAnnotation readAnnotation()
>         {
>             if (!atLeast(2, 19, 0))
>                 return null; // no annotations for this version of the
file
>             // Read attributes
>             int n = readInt();
>             if (n == -1)
>                 return null;
>             SchemaAnnotation.Attribute[] attributes =
>                 new SchemaAnnotation.Attribute[n];
>             for (int i = 0; i < n; i++)
>             {
>                 QName name = readQName();
>                 String value = readString();
>                 attributes[i] = new
SchemaAnnotationImpl.AttributeImpl(name, value);
>             }
>
>             // Read documentation items
>             n = readInt();
>             DocumentationDocument.Documentation[] documentationItems =
>                 new DocumentationDocument.Documentation[n];
>             for (int i = 0; i <  n; i++)
>             {
>                 String doc = readString();
>                 try
>                 {
>                     documentationItems[i] = DocumentationDocument.Factory.
>                         parse(doc).getDocumentation();
>                 }
>                 catch (XmlException e)
>                 {
>                     throw new RuntimeException( e.getMessage(), e );
>                 }
>             }
>
>             // Read application info items
>             n = readInt();
>             AppinfoDocument.Appinfo[] appInfoItems =
>                 new AppinfoDocument.Appinfo[n];
>             for (int i = 0; i < n; i++)
>             {
>                 String appInfo = readString();
>                 try
>                 {
>                     appInfoItems[i] = AppinfoDocument.Factory.
>                         parse(appInfo).getAppinfo();
>                 }
>                 catch(XmlException e)
>                 {
>                     throw new RuntimeException( e.getMessage(), e );
>                 }
>             }
>
>             return new SchemaAnnotationImpl(getTypeSystem(), appInfoItems,
>                 documentationItems, attributes);
>         }
>
>         void writeAnnotations(SchemaAnnotation[] anns)
>         {
>             writeInt(anns.length);
>             for (int i = 0; i < anns.length; i++)
>                 writeAnnotation(anns[i]);
>         }
>
>         List readAnnotations()
>         {
>             int n = readInt();
>             List result = new ArrayList(n);
>             for (int i = 0; i < n; i++)
>                 result.add(readAnnotation());
>             return result;
>         }
>
1789a1915
>                 impl.setAnnotation(readAnnotation());
1857a1984
>                 impl.setAnnotation(readAnnotation());
2064a2192
>             writeAnnotation(type.getAnnotation());
2269c2397
<                 result.init(readQName(), readString(), readShort() == 1,
atLeast(2, 15, 0) ? readShort() == 1 : false, GroupDocument.Factory.parse(
readString() ).getGroup());
---
>                 result.init(readQName(), readString(), readShort() == 1,
atLeast(2, 15, 0) ? readShort() == 1 : false, GroupDocument.Factory.parse(
readString() ).getGroup(), readAnnotation());
2281c2409
<                 result.init( readQName(), readString(), readShort() == 1,
atLeast(2, 15, 0) ? readShort() == 1 : false,
AttributeGroupDocument.Factory.parse(
readString() ).getAttributeGroup());
---
>                 result.init( readQName(), readString(), readShort() == 1,
atLeast(2, 15, 0) ? readShort() == 1 : false,
AttributeGroupDocument.Factory.parse(
readString() ).getAttributeGroup(), readAnnotation());
2291,2292c2419,2420
<             // name, type, use, deftext, defval, fixed, soaparraytype
<             result.init(readQName(), readTypeRef(), readShort(),
readString(), null, atLeast(2, 16, 0) ? readXmlValueObject() : null,
readShort() == 1, readSOAPArrayType());
---
>             // name, type, use, deftext, defval, fixed, soaparraytype,
annotation
>             result.init(readQName(), readTypeRef(), readShort(),
readString(), null, atLeast(2, 16, 0) ? readXmlValueObject() : null,
readShort() == 1, readSOAPArrayType(), readAnnotation());
2303a2432
>             writeAnnotation(attr.getAnnotation());
2310a2440
>             writeAnnotation(idc.getAnnotation());
2390a2521
>                     lresult.setAnnotation(readAnnotation());
2477a2609
>                     writeAnnotation(lpart.getAnnotation());
2584a2717
>             writeAnnotation(impl.getAnnotation());
2594a2728
>             writeAnnotation(impl.getAnnotation());
3118a3253,3262
>         return result;
>     }
>
>     public SchemaAnnotation[] annotations()
>     {
>         if (_annotations.isEmpty())
>             return EMPTY_ANN_ARRAY;
>
>         SchemaAnnotation[] result = new
SchemaAnnotation[_annotations.size()];>         result =
(SchemaAnnotation[]) _annotations.toArray(result);
Index:
src/typeimpl/org/apache/xmlbeans/impl/schema/StscSimpleTypeResolver.java
===================================================================
RCS file:
/home/cvs/xml-xmlbeans/v2/src/typeimpl/org/apache/xmlbeans/impl/schema/StscS
impleTypeResolver.java,v
retrieving revision 1.1
diff -r1.1 StscSimpleTypeResolver.java
220a221,222
>             SchemaAnnotationImpl ann =
SchemaAnnotationImpl.getAnnotation(state.sts(), parseInner);
>             itemImpl.setAnnotation(ann);
331a334,335
>             SchemaAnnotationImpl ann =
SchemaAnnotationImpl.getAnnotation(state.sts(), simpleTypes[i]);
>             mImpl.setAnnotation(ann);
444a449,450
>             SchemaAnnotationImpl ann =
SchemaAnnotationImpl.getAnnotation(state.sts(), parseInner);
>             baseImpl.setAnnotation(ann);
Index: src/typeimpl/org/apache/xmlbeans/impl/schema/StscState.java
===================================================================
RCS file:
/home/cvs/xml-xmlbeans/v2/src/typeimpl/org/apache/xmlbeans/impl/schema/StscS
tate.java,v
retrieving revision 1.1
diff -r1.1 StscState.java
120a121
>     private List _annotations       = new ArrayList();
122a124
>     private boolean _noAnn;
309a312,313
>         _noAnn = options.hasOption(XmlOptions.COMPILE_NO_ANNOTATIONS) ?
true :>
!"true".equals(System.getProperty("xmlbean.schemaannotations", "true"));
343c347,354
<
---
>
>     /**
>      * True if annotations should be skipped
>      */
>     public boolean noAnn()
>     {
>         return _noAnn;
>     }
751a763,773
>
>     /* ANNOTATIONS ===========================================*/
>
>     void addAnnotation(SchemaAnnotationImpl ann)
>     {
>         if (ann != null)
>             _annotations.add(ann);
>     }
>
>     List annotations()
>     { return _annotations; }
Index: src/typeimpl/org/apache/xmlbeans/impl/schema/StscTranslator.java
===================================================================
RCS file:
/home/cvs/xml-xmlbeans/v2/src/typeimpl/org/apache/xmlbeans/impl/schema/StscT
ranslator.java,v
retrieving revision 1.1
diff -r1.1 StscTranslator.java
184c184,188
<
---
>
>         AnnotationDocument.Annotation[] annotations =
schema.getAnnotationArray();
>         for (int i = 0; i < annotations.length; i++)
>
state.addAnnotation(SchemaAnnotationImpl.getAnnotation(state.sts(), schema,
annotations[i]));
>
379a384
>
sType.setAnnotation(SchemaAnnotationImpl.getAnnotation(state.sts(),
xsdType));
413a419
>
sType.setAnnotation(SchemaAnnotationImpl.getAnnotation(state.sts(),
xsdType));
445a452
>         target.setAnnotation(referenced.getAnnotation());
455c462,463
<             referenced.getWSDLArrayType() );
---
>             referenced.getWSDLArrayType(),
>             referenced.getAnnotation());
602a611,612
>         SchemaAnnotationImpl ann =
SchemaAnnotationImpl.getAnnotation(state.sts(), xsdElt);
>         impl.setAnnotation(ann);
611c621
<         XmlObject typedef = xsdElt.getComplexType();
---
>         Annotated typedef = xsdElt.getComplexType();
633a644
>
sTypeImpl.setAnnotation(SchemaAnnotationImpl.getAnnotation(state.sts(),
typedef));
812a824,825
>         SchemaAnnotationImpl ann =
SchemaAnnotationImpl.getAnnotation(state.sts(), parseIC);
>         ic.setAnnotation(ann);
852,853c865,868
<         SchemaModelGroupImpl result = new
SchemaModelGroupImpl(StscState.get().sts());
<         result.init(QNameHelper.forLNS(name, targetNamespace),
targetNamespace, chameleon, redefinition, namedGroup);
---
>         SchemaTypeSystemImpl sts = StscState.get().sts();
>         SchemaModelGroupImpl result = new SchemaModelGroupImpl(sts);
>         SchemaAnnotationImpl ann = SchemaAnnotationImpl.getAnnotation(sts,
namedGroup);
>         result.init(QNameHelper.forLNS(name, targetNamespace),
targetNamespace, chameleon, redefinition, namedGroup, ann);
865,866c880,883
<         SchemaAttributeGroupImpl result = new
SchemaAttributeGroupImpl(StscState.get().sts());
<         result.init(QNameHelper.forLNS(name, targetNamespace),
targetNamespace, chameleon, redefinition, attrGroup);
---
>         SchemaTypeSystemImpl ts = StscState.get().sts();
>         SchemaAttributeGroupImpl result = new
SchemaAttributeGroupImpl(ts);
>         SchemaAnnotationImpl ann = SchemaAnnotationImpl.getAnnotation(ts,
attrGroup);
>         result.init(QNameHelper.forLNS(name, targetNamespace),
targetNamespace, chameleon, redefinition, attrGroup, ann);
989c1006
<             XmlObject typedef = xsdAttr.getSimpleType();
---
>             LocalSimpleType typedef = xsdAttr.getSimpleType();
1006a1024
>
sTypeImpl.setAnnotation(SchemaAnnotationImpl.getAnnotation(state.sts(),
typedef));
1061a1080,1081
>         SchemaAnnotationImpl ann =
SchemaAnnotationImpl.getAnnotation(state.sts(),
>             xsdAttr);
1067c1087
<             wat);
---
>             wat, ann);
Index: src/xmlcomp/org/apache/xmlbeans/impl/tool/SchemaCompiler.java
===================================================================
RCS file:
/home/cvs/xml-xmlbeans/v2/src/xmlcomp/org/apache/xmlbeans/impl/tool/SchemaCo
mpiler.java,v
retrieving revision 1.1
diff -r1.1 SchemaCompiler.java
99a100
>             System.out.println("    -noann - ignore annotations");
157a159
>         boolean noAnn = (cl.getOpt("noann") != null);
297a300
>         params.setNoAnn(noAnn);
338a342
>         private boolean noAnn;
504a509,518
>         public boolean isNoAnn()
>         {
>             return noAnn;
>         }
>
>         public void setNoAnn(boolean noAnn)
>         {
>             this.noAnn = noAnn;
>         }
>
609,610c623,625
<         boolean download, boolean noUpa, boolean noPvr, Set
mdefNamespaces,
<         File baseDir, Map sourcesToCopyMap, Collection outerErrorListener)
---
>         boolean download, boolean noUpa, boolean noPvr, boolean noAnn,
>         Set mdefNamespaces, File baseDir, Map sourcesToCopyMap,
>         Collection outerErrorListener)
755a771,772
>         if (noAnn)
>             opts.setCompileNoAnnotations();
796a814
>         boolean noAnn = params.isNoAnn();
823c841
<         SchemaTypeSystem system = loadTypeSystem(name, xsdFiles,
wsdlFiles, configFiles, cpResourceLoader, download, noUpa, noPvr,
mdefNamespaces, baseDir, sourcesToCopyMap, errorListener);
---
>         SchemaTypeSystem system = loadTypeSystem(name, xsdFiles,
wsdlFiles, configFiles, cpResourceLoader, download, noUpa, noPvr, noAnn,
mdefNamespaces, baseDir, sourcesToCopyMap, errorListener);
Index: src/xmlcomp/org/apache/xmlbeans/impl/tool/XsbDumper.java
===================================================================
RCS file:
/home/cvs/xml-xmlbeans/v2/src/xmlcomp/org/apache/xmlbeans/impl/tool/XsbDumpe
r.java,v
retrieving revision 1.1
diff -r1.1 XsbDumper.java
175c175
<     public static final int MINOR_VERSION = 16;
---
>     public static final int MINOR_VERSION = 19;
431a432,435
>         // version 19 annotations
>         if (atLeast(2, 19, 0))
>             dumpAnnotations();
>
658a663,725
>     void dumpAnnotation()
>     {
>         if (!atLeast(2, 19, 0))
>             return; // no annotations in this version of the file
>
>         int n = readInt();
>         if (n == -1)
>             return; // no annotation present
>         emit("Annotation");
>         boolean empty = true;
>         indent();
>         if (n > 0)
>         {
>             emit("Attributes (" + n + "):");
>             indent();
>             for (int i = 0; i < n; i++)
>             {
>                 emit("Name: " + qnameString(readQName()) +
>                     ", Value: " + readString());
>             }
>             outdent();
>             empty = false;
>         }
>
>         n = readInt();
>         if (n > 0)
>         {
>             emit("Documentation elements (" + n + "):");
>             indent();
>             for (int i = 0; i < n; i++)
>                 emit(readString());
>             outdent();
>             empty = false;
>         }
>
>         n = readInt();
>         if (n > 0)
>         {
>             emit("Appinfo elements (" + n + "):");
>             indent();
>             for (int i = 0; i < n; i++)
>                 emit(readString());
>             outdent();
>             empty = false;
>         }
>         if (empty)
>             emit("<empty>");
>         outdent();
>     }
>
>     void dumpAnnotations()
>     {
>         int n = readInt();
>         if (n > 0)
>         {
>             emit("Top-level annotations (" + n + "):");
>             indent();
>             for (int i = 0; i < n; i++)
>                 dumpAnnotation();
>             outdent();
>         }
>     }
>
685a753
>                 dumpAnnotation();
687a756,757
>                     if (atLeast(2, 17, 0))
>                         emit("Substitution group ref: " + readHandle());
806c876,877
<
---
>         dumpAnnotation();
>
976a1048
>         dumpAnnotation();
1006a1079
>         dumpAnnotation();
1017a1091
>         dumpAnnotation();
1070c1144,1145
<         emit("Flags: " + propertyflagsString(readShort()));
---
>         short propflags = readShort();
>         emit("Flags: " + propertyflagsString(propflags));
1083a1159,1167
>         if ((propflags & FLAG_PROP_ISATTR) == 0 && atLeast(2, 17, 0))
>         {
>             short size = readShort();
>             emit("Accepted names (" + size + ")");
>             indent();
>             for (int i = 0; i < size; i++)
>                 emit(qnameString(readQName()));
>             outdent();
>         }
cvs server: src/xmlpublic/org/apache/xmlbeans/SchemaAnnotated.java is a new
entry, no comparison available
cvs server: src/xmlpublic/org/apache/xmlbeans/SchemaAnnotation.java is a new
entry, no comparison available
Index: src/xmlpublic/org/apache/xmlbeans/SchemaAttributeGroup.java
===================================================================
RCS file:
/home/cvs/xml-xmlbeans/v2/src/xmlpublic/org/apache/xmlbeans/SchemaAttributeG
roup.java,v
retrieving revision 1.1
diff -r1.1 SchemaAttributeGroup.java
74c74
< public interface SchemaAttributeGroup extends SchemaComponent
---
> public interface SchemaAttributeGroup extends SchemaComponent,
SchemaAnnotatedIndex: src/xmlpublic/org/apache/xmlbeans/SchemaComponent.java
===================================================================
RCS file:
/home/cvs/xml-xmlbeans/v2/src/xmlpublic/org/apache/xmlbeans/SchemaComponent.
java,v
retrieving revision 1.1
diff -r1.1 SchemaComponent.java
92a93,94
>     /** An annotation. See {@link #getComponentType} */
>     static final int ANNOTATION = 8;
Index: src/xmlpublic/org/apache/xmlbeans/SchemaIdentityConstraint.java
===================================================================
RCS file:
/home/cvs/xml-xmlbeans/v2/src/xmlpublic/org/apache/xmlbeans/SchemaIdentityCo
nstraint.java,v
retrieving revision 1.1
diff -r1.1 SchemaIdentityConstraint.java
65c65
< public interface SchemaIdentityConstraint extends SchemaComponent
---
> public interface SchemaIdentityConstraint extends SchemaComponent,
SchemaAnnotated
Index: src/xmlpublic/org/apache/xmlbeans/SchemaLocalAttribute.java
===================================================================
RCS file:
/home/cvs/xml-xmlbeans/v2/src/xmlpublic/org/apache/xmlbeans/SchemaLocalAttri
bute.java,v
retrieving revision 1.1
diff -r1.1 SchemaLocalAttribute.java
62c62
< public interface SchemaLocalAttribute extends SchemaField
---
> public interface SchemaLocalAttribute extends SchemaField, SchemaAnnotated
Index: src/xmlpublic/org/apache/xmlbeans/SchemaLocalElement.java
===================================================================
RCS file:
/home/cvs/xml-xmlbeans/v2/src/xmlpublic/org/apache/xmlbeans/SchemaLocalEleme
nt.java,v
retrieving revision 1.1
diff -r1.1 SchemaLocalElement.java
62c62
< public interface SchemaLocalElement extends SchemaField
---
> public interface SchemaLocalElement extends SchemaField, SchemaAnnotated
Index: src/xmlpublic/org/apache/xmlbeans/SchemaModelGroup.java
===================================================================
RCS file:
/home/cvs/xml-xmlbeans/v2/src/xmlpublic/org/apache/xmlbeans/SchemaModelGroup
.java,v
retrieving revision 1.1
diff -r1.1 SchemaModelGroup.java
72c72
< public interface SchemaModelGroup extends SchemaComponent
---
> public interface SchemaModelGroup extends SchemaComponent, SchemaAnnotated
Index: src/xmlpublic/org/apache/xmlbeans/SchemaType.java
===================================================================
RCS file:
/home/cvs/xml-xmlbeans/v2/src/xmlpublic/org/apache/xmlbeans/SchemaType.java,
v
retrieving revision 1.1
diff -r1.1 SchemaType.java
170c170
< public interface SchemaType extends SchemaComponent
---
> public interface SchemaType extends SchemaComponent, SchemaAnnotated
Index: src/xmlpublic/org/apache/xmlbeans/SchemaTypeSystem.java
===================================================================
RCS file:
/home/cvs/xml-xmlbeans/v2/src/xmlpublic/org/apache/xmlbeans/SchemaTypeSystem
.java,v
retrieving revision 1.1
diff -r1.1 SchemaTypeSystem.java
216a217,220
>      * Returns the top-level annotations */
>     public SchemaAnnotation[] annotations();
>
>     /**
Index: src/xmlpublic/org/apache/xmlbeans/XmlOptions.java
===================================================================
RCS file:
/home/cvs/xml-xmlbeans/v2/src/xmlpublic/org/apache/xmlbeans/XmlOptions.java,
v
retrieving revision 1.1
diff -r1.1 XmlOptions.java
526c526,536
<
---
>
>     /**
>      * if this option is set, the schema compiler will skip annotations
when
>      * processing Schema components.
>      *
>      * @see XmlBeans#compileXsd
>      */
>     public XmlOptions setCompileNoAnnotations() {
>         return set( COMPILE_NO_ANNOTATIONS );
>     }
>
654a665,666
>     /** @exclude */
>     public static final String COMPILE_NO_ANNOTATIONS          =
"COMPILE_NO_ANNOTATIONS";

- ---------------------------------------------------------------------
To unsubscribe, e-mail:   xmlbeans-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xmlbeans-dev-help@xml.apache.org
Apache XMLBeans Project -- URL: http://xml.apache.org/xmlbeans/



- ---------------------------------------------------------------------
To unsubscribe, e-mail:   xmlbeans-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xmlbeans-dev-help@xml.apache.org
Apache XMLBeans Project -- URL: http://xml.apache.org/xmlbeans/