Hi,
 
For the annotations inside <element ref=...> and <attributeGroup ref=...>, the 
answer is that those are not accessible as per XMLSchema; <element ref=...> 
corresponds to what XMLSchema calls a "particle" 
(http://www.w3.org/TR/xmlschema-1/#declare-element) and those don't have 
annotations and <attributeGroup ref=...> doesn't correspond to any component at 
all (http://www.w3.org/TR/xmlschema-1/#declare-attributeGroup). Now, one can 
ask why are they even allowed if they are not accessible and indeed if you look 
at the second link it says at some point " in the second [case] the ref 
attribute is required, and the element must be empty". So maybe XMLBeans should 
flag an error, but I have to say this is a "gray" area of the spec and I would 
have to check the Schema mailing lists to see if this has been brought up.
 
For the third case, <attribute name=...>, you need to get the 
SchemaLocalAttribute object representing that attribute (via 
SchemaType.getAttributeModel()) and that will have a getAnnotation() method.
 
Oh, and I should also mention that even in the cases where the annotations are 
not accessible, you can get the textual representation of the Schema as an 
XmlObject. Then, of course, you will get access to the annotations, if this is 
critical for your app, but you'll have to search for them.
 
Hope this helps,
Radu


________________________________

        From: Ward [mailto:[email protected]] 
        Sent: Friday, April 03, 2009 4:54 AM
        To: [email protected]
        Subject: Retrieving annotation/documentation of 
elements/attributes/attribute-groups
        
        
        Hello,
        
        I'm working with XMLBeans for some weeks now, but now I'm interested in 
accessing the documentation availlable in my xsd-scheme.
        Until now I only managed to get the documentation directly under any 
complextype, but not the documentation specific to any element, attribute or 
attributegroup
        
        Consider following snippet from my scheme:
        
            <complexType name="titleType">
                <annotation>
                    <documentation><!-- THIS DOCUMENTATION I CAN ACCESS -->
         The name given to a resource e.g. a media item, media object, sequence.
                        For a series - use the series title; for a programme - 
a programme title; for an
                        item - an item title. etc. To differentiate between a 
series title and programme
                        title when these are identical, recommended best 
practice is to use a date along
                        with the programme title. For example, "News" is a 
series title; "News 2007.11.12"
                        is a programme title. Titles are recorded as they 
appear. </documentation>
                </annotation>
                <sequence>
                    <element ref="dc:title">
                        <annotation>
                            <documentation> 
        <!--HOW CAN I ACCESS THIS DOCUMENTATION??? -->
        The EBU core metadata set is built as a refinement of the Dublin
                                Core. </documentation>
                        </annotation>
                    </element>
                </sequence>
                <attributeGroup ref="ebucore:typeGroup">
                    <annotation>
                        <documentation> 
        <!--HOW CAN I ACCESS THIS DOCUMENTATION??? -->
        The typeGroup is used to define the type of Title such as Episode,
                            Programme, Collection, Programme Group, Series, 
Item, Scene, Shot, Element,
                            Segment, Project, , Series Number, Episode Number, 
Scene Number, Take Number
                            Recording, Album, etc. The name of the type can be 
provided in the form of a
                            text label, or a link to a code of a classification 
scheme, optionally
                            accompanied by a definition</documentation>
                    </annotation>
                </attributeGroup>
                <attribute name="note" type="string">
                    <annotation>
                        <documentation> Optional addditional contextual 
information. <!--HOW CAN I ACCESS THIS DOCUMENTATION??? --> </documentation>
                    </annotation>
                </attribute>
            </complexType>
        
        Any ideas on this?
        
        Thanks in advance
        
        Ward
        

Reply via email to