[xsd-users] Accessing elements in sequence of choices. Elements are complex types

B Hart bhartsb at gmail.com
Wed Mar 14 19:45:44 EDT 2012


Given:

<xs:complexType name="E19" id="InterventionProcedure">
        <xs:sequence>
            <xs:element name="E19_01_0" id="ProcedurePerformed"
minOccurs="0" maxOccurs="unbounded">
                <xs:annotation>
                    <xs:documentation>The procedures performed on the
patient</xs:documentation>
                </xs:annotation>
                <xs:complexType>
                    <xs:sequence>
                        <xs:choice>
                            <xs:element name="ProcedurePTA"
type="ProcedurePTA"/>
                            <xs:element name="P89.700" type="P89.700"/>
                            <xs:element name="P89.701" type="P89.701"/>
                        </xs:choice>
                    </xs:sequence>
                </xs:complexType>
            </xs:element>
        </xs:sequence>
    </xs:complexType>
</xs:schema>

with the complex types defined as:

<xs:complexType name="ProcedurePTA">
        <xs:sequence minOccurs="1">
            <xs:element ref="E19_02"/>
            <xs:element ref="E19_03"/>
        </xs:sequence>
    </xs:complexType>
    <xs:complexType name="P89.700">
        <xs:sequence minOccurs="1">
            <xs:element ref="E19_01"/>
            <xs:element ref="E19_02"/>
            <xs:element ref="E19_03"/>
            <xs:element ref="E19_09"/>
        </xs:sequence>
    </xs:complexType>
    <xs:complexType name="P89.701">
        <xs:sequence minOccurs="1">
            <xs:element ref="E19_01"/>
            <xs:element ref="E19_02"/>
            <xs:element ref="E19_03"/>
            <xs:element ref="E19_09"/>
        </xs:sequence>
    </xs:complexType>

How do I check if a choice of the three above procedures is reported in the
corresponding XML, and then access it's elements?

A snippet of the corresponding XML looks like:

<E19>
        <E19_01_0>
          <ProcedurePTA>
            <E19_02>1</E19_02>
            <E19_03>89.701</E19_03>
          </ProcedurePTA>
        </E19_01_0>

         <E19_01_0>
          <ProcedurePTA>
            <E19_02>1</E19_02>
            <E19_03>38.992</E19_03>
          </ProcedurePTA>
        </E19_01_0>
</E19>

Thank you!


More information about the xsd-users mailing list