4

Is there an out-of-the-box way to deal with <xsd:list> in XmlSerializer ?

In my case I got a list of double, something like this:

<xs:complexType name="PositionType">
    <xs:simpleContent>
        <xs:extension base="doubleList">
        </xs:extension>
    </xs:simpleContent>
</xs:complexType>

<xs:simpleType name="doubleList">
    <xs:list itemType="xs:double"/>
</xs:simpleType>

<xs:element name="Test" type="PositionType"/>

An instance may look like this: <pos>10.3 20.2 -2.4</pos>

I tried to make xsd.exe reveal some secrets, but it generated this.. which fails:

private double[] textField;

[System.Xml.Serialization.XmlTextAttribute()]
public double[] Text {
    get {
        return this.textField;
    }
    set {
        this.textField = value;
    }
}

Exception:

  System.InvalidOperationException: Member 'Text' cannot be encoded using the XmlText attribute. You may use the XmlText attribute to encode primitives, enumerations, arrays of strings, or arrays of XmlNode.

Note that I am using existing schemas and have no way to influence design.

Oyvind
  • 568
  • 2
  • 6
  • 22
  • Are you saying that the generated class which is based on the xsd is generated incorrectly or have you altered the generated class? – Martijn B Nov 30 '11 at 12:07

0 Answers0