users@jaxb.java.net

Reused group keeps general content property

From: Jochen Wiedmann <jochen.wiedmann_at_softwareag.com>
Date: Tue, 15 Mar 2005 21:50:53 +0100

Hi,

I have a schema, which uses a group twice. The first occurrence is
within an element with mixed content. The second occurrence is in a
child element.

I understand, that the first case requires, that the group is modeled
for the general content property. In other words, an atomic element is
represented as an object with getValue() and setValue() methods.

To my surprise, however, the same representation is used in the second
case. The only reason I can think of, is that the group is being reused.

My question is, whether this is as expected? And, if so, whether the
spec mandates this type of modeling or whether this could be done in a
different matter?

To reproduce the problem, see the schema below. In particular, see the
method

     MixedElementType.CdElementType.getD()

which I would expect to return a string.


Regards,

Jochen


<?xml version="1.0"?>
<xs:schema
     xmlns:xs="http://www.w3.org/2001/XMLSchema"
     xmlns:ng="http://ws.apache.org/jaxme/test/nestedGroups"
     xmlns:jaxb="http://java.sun.com/xml/ns/jaxb"
     xml:lang="EN"
     targetNamespace="http://ws.apache.org/jaxme/test/nestedGroups"
     elementFormDefault="qualified"
     attributeFormDefault="unqualified"
     jaxb:version="1.0">
   <xs:annotation><xs:documentation>
       This schema is for testing various kinds of nested groups.
   </xs:documentation></xs:annotation>

   <xs:group name="abGroup">
     <xs:sequence>
       <xs:element name="a" type="xs:string"/>
       <xs:element name="b" type="xs:int"/>
     </xs:sequence>
   </xs:group>

   <xs:group name="cdGroup">
     <xs:sequence>
       <xs:element name="c" type="xs:string"/>
       <xs:element name="d" type="xs:int"/>
     </xs:sequence>
   </xs:group>

   <xs:element name="MixedElement">
     <xs:annotation><xs:documentation>
       This is an extended type of nested groups: The outer element
       contains child elements with mixed content.
     </xs:documentation></xs:annotation>
     <xs:complexType mixed="true">
       <xs:sequence>
         <xs:element name="f" type="xs:float">
           <xs:annotation><xs:appinfo>
             <jaxb:property name="aFloat"/>
           </xs:appinfo></xs:annotation>
         </xs:element>
         <xs:choice>
           <xs:element name="g" type="xs:long"/>
           <xs:element name="h" type="xs:dateTime"/>
         </xs:choice>
         <xs:element name="abElement">
           <xs:complexType>
             <xs:group ref="ng:abGroup"/>
           </xs:complexType>
         </xs:element>
         <xs:group ref="ng:abGroup"/>
         <xs:element name="cdElement">
           <xs:complexType>
             <xs:group ref="ng:cdGroup"/>
           </xs:complexType>
         </xs:element>
         <xs:group ref="ng:cdGroup"/>
       </xs:sequence>
     </xs:complexType>
   </xs:element>
</xs:schema>