Attribute Groups
HydraExpress supports attribute groups. HydraExpress does not generate a class for the attribute groups since attributes can only be simple types. Instead it expands the attribute group in the complex type definition that is referencing the attribute group. An example of the mapping for this is shown in example below:
<schema xmlns="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://roguewave.com/examples/xmlbinding"
xmlns:tns="http://roguewave.com/examples/xmlbinding">
<element name="Book">
<complexType>
<sequence>
<group ref="tns:BookElements"/>
</sequence>
<attributeGroup ref="tns:BookAttributes"/>
</complexType>
</element>
<group name="BookElements">
<sequence>
<element name="Title" type="string" minOccurs="1"
maxOccurs="1"/>
<element name="Author" type="string" minOccurs="1"
maxOccurs="unbounded"/>
<element name="Date" type="string" minOccurs="1"
maxOccurs="1"/>
<element name="ISBN" type="string" minOccurs="1"
maxOccurs="1"/>
<element name="Publisher" type="string" minOccurs="1"
maxOccurs="1"/>
</sequence>
</group>
<attributeGroup name="BookAttributes">
<attribute name="CoverType" type="string"/>
<attribute name="Height" type="float"/>
<attribute name="Width" type="float"/>
<attribute name="NumberOfPages" type="int"/>
</attributeGroup>
</schema>
Only one complex type is defined in the schema, so only one class is generated: Book. This class would contain the following methods:
[get|set]CoverType(),
[is|set]CoverTypeSet() [get|set]Height(),
[is|set]HeightSet() [get|set]Width(),
[is|set]WidthSet() [get|set]NumberOfPages(),
[is|set]NumberOfPagesSet() [get|set]Title() [get|set]Date() [get|set]ISBN() [get|set]Publisher() [get|set]AuthorVector() Attributes, as previously noted, are always simple types, so HydraExpress does not generate a class for them, or for the attribute group. The attributes in the attribute group are treated like any other attributes, with accessor methods and is...Set() and set...Set() methods for determining whether an attribute is present in the instance document.