users@jaxb.java.net

Problems with substitutionGroup

From: Vivian Steller <vivian.steller_at_informatik.uni-ulm.de>
Date: Wed, 26 Jan 2005 11:22:40 +0100

Hello,
I've a problem with substitution groups (at least I think so), again. All the
generated Code of JAXB seems quite right, including comments of allowed types
and so on... this is why I can't get behind...

Please, have a look at the following schema snippet:

################# XSD ##################
<xs:element name="diagrams" type="dm:Diagrams"/>
    <xs:complexType name="Diagrams">
                <xs:sequence>
                    <xs:element ref="dm:diagram" minOccurs="0"
maxOccurs="unbounded"/>
                </xs:sequence>
    </xs:complexType>

<!-- Abstract Diagram -->
    <xs:element name="diagram" type="dm:Diagram"/>
    <xs:complexType name="Diagram">
                <xs:sequence>
                    <xs:element ref="dm:cell" minOccurs="0"
maxOccurs="unbounded"/>
                </xs:sequence>
                <xs:attribute name="name" type="xs:string"/>
                <xs:attribute name="milestone" type="xs:int"/>
    </xs:complexType>

<!-- derived diagrams -->
    <xs:element name="system-profile-diagram" substitutionGroup="dm:diagram"
type="dm:SystemProfileDiagram"/>

    <xs:complexType name="SystemProfileDiagram">
        <xs:complexContent>
            <xs:extension base="dm:Diagram"/>
        </xs:complexContent>
    </xs:complexType>
################# XSD ##################

In a nutshell I've got a container "Diagrams" where I want to store Diagrams
of "Diagram"-derived types, like "SystemProfileDiagram" and others...

So far so good, the jaxb generated code looks well: (here the comment of the
Diagrams.getDiagram() Method...

"List ferkel.storage.diagram.DiagramsType.getDiagram()

Gets the value of the Diagram property.
This accessor method ...
For example, to add a new item, do as follows:
    getDiagram().add(newItem);
 
Objects of the following type(s) are allowed in the list
ferkel.storage.diagram.SystemProfileDiagram ferkel.storage...."


Now, I perfom the following code, resulting in a strange behaviour:

################# CODE ##################
SystemProfileDiagram dia = (SystemProfileDiagram)
diagramFactory.createSystemProfileDiagram();

Diagrams dias = (Diagrams) project.getDiagrams();
List diagramList = dias.getDiagram();
diagramList.add(dia);

System.out.println(diagramList.size());
System.out.println(project.getDiagrams().getDiagram().size());
################# CODE ##################

The output made by printlns is:
################# OUTPUT ##################
1 // that's still right
0 // something went wrong... :(
################# OUTPUT ##################

the whole xsd-schema is surrounded by another "project" schema, that's why
project occurs in the code above (but i don't think that this is relevant,
here).

I don't have any idea, what to do, because there's no exception or anything...
seems like a bug to me.

Thanks in advance for your help.
best regards
vivian

ps: i'm using jwdsp 1.4

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe_at_jaxb.dev.java.net
For additional commands, e-mail: users-help_at_jaxb.dev.java.net