views:

33

answers:

0

I have a schema element that reads as follows:

<xs:complexType name="day-hours">
            <xs:choice>
                <xs:element name="twentyfourhours"/>
                <xs:element name="closed"/>
                <xs:element name="hours" type="smm:hours"/>
            </xs:choice>
        </xs:complexType>
        <xs:complexType name="hours">
            <xs:sequence>
                <xs:element name="open" type="smm:time"/>
                <xs:element name="close" type="smm:time"/>
            </xs:sequence>
        </xs:complexType>
        <xs:complexType name="time">
            <xs:simpleContent>
                <xs:extension base="xs:string">
                    <xs:attribute name="unit" use="required" type="smm:unit"/>
                </xs:extension>
            </xs:simpleContent>
        </xs:complexType>
        <xs:simpleType name="unit">
            <xs:restriction base="xs:string">
                <xs:enumeration value="AM" />
                <xs:enumeration value="PM" />
            </xs:restriction>
        </xs:simpleType>

XML should look like:

<day-hours><24hours/></day-hours>

or

<day-hours><closed/></day-hours>

or

<day-hours>
        <hours>
            <open unit="AM">9:00</open> <!-- open/close or closed or 24hour -->
            <close unit="PM">5:00</close>
        </hours>
        </monday>

How can I model this in castor? When I declare fields, I need to declare object fields, which in this case is actually going to make my life much harder, I'd rather just be able to output elements so that my "day-hours" handler can just return what the xml elements should look like.