[xsd-users] unnamed sequence of sequence

Emiliano Leporati emiliano.leporati at gmail.com
Tue Jul 13 05:48:50 EDT 2010


Hi,
i have a question about the class transposition of this XSD fragment:

    <complexType name="MeasurementLogType">
        <complexContent>
            <extension base="mxmbp:ProtocolBaseType">
                <choice>
                    <element name="MeasurementLogBlob" type="base64Binary"/>
                    <element name="MeasurementLogTSS" type="mxmidp:*
MeasurementLogTSSType*"/>
                </choice>
            </extension>
        </complexContent>
    </complexType>

    <complexType name="*MeasurementLogTSSType*">
        <complexContent>
            <extension base="mxmbp:ProtocolBaseType">
                <*sequence* maxOccurs="unbounded">
                    <*sequence*>
                        <element name="EventPCRIndex" type="integer"/>
                        <element name="EventClass"
type="mxmidp:EventClassType"/>
                        <element name="EventValue" type="base64Binary"/>
                        <element name="EventPCRValue" type="base64Binary"/>
                    </*sequence*>
                </*sequence*>
            </extension>
        </complexContent>
    </complexType>

reading the XSD code one would imagine a sequence of set of fours (every
element is mandatory), but the outer class representing the node containing
the MeasurementLogTSSType expose four distinct sequences, one for
EventPCRIndex, one for EventClass, and so on ...
the resulting XML appears like this:

  <p1:MeasurementLog>
    <p1:MeasurementLogTSS>
      <p1:EventPCRIndex>-1</p1:EventPCRIndex>
      <p1:EventPCRIndex>-1</p1:EventPCRIndex>
      <p1:EventClass>CONFIG_FILE</p1:EventClass>
      <p1:EventClass>LIBRARY</p1:EventClass>

<p1:EventValue>TVhNQ29uZmlndXJhdGlvbi1saW51eC11YmsueG1s</p1:EventValue>

<p1:EventValue>L3Vzci9sb2NhbC9saWIvbXhtX2VuZ2luZXMvbGlibXhtX3ViaWtfbXBlZzIx
ZmlsZV9lbmdpbmUuc28=</p1:EventValue>
      <p1:EventPCRValue></p1:EventPCRValue>
      <p1:EventPCRValue></p1:EventPCRValue>
    </p1:MeasurementLogTSS>
  </p1:MeasurementLog>

this XML fragment does not seem to match the XSD definition, and moreover,
having four distinct sequences lets us put different number of values for
every element ( one EventPCRIndex, two EventClass, three EventValue and no
EventPCRValue for example).

am I misinterpreting something or is this a bug in the xsd tool ?
is there a simple workaround to achieve the desired result, for example
giving a name to the inner sequence by defining it as a separate element ?

thanks

Emiliano Leporati


More information about the xsd-users mailing list