Mixed complex type generates List<string> textField

Jan 2, 2010 at 9:16 PM

First of all, kudos to the authors on a great utility!

My question involves a schema containing a mixed complex type. 

The XML I'm trying to represent might look like this:

 <field name="a field name">the field value</field>

The cooresponding XSD looks like this:

<xs:complexType name="Field" mixed="true">
    <xs:attribute name="name" type="xs:string" />

I'm wondering if anybody can comment on why Xsd2Code exposes the value of the node as a List<string> rather then just a string?

public List<string> Text
		if ((this.textField == null))
			this.textField = new List<string>();
		return this.textField;
		this.textField = value;

My tests show it will always be a list of length 0 or 1.  Is there a different way to represnt this in the XSD that I may have overlooked?




Dec 12, 2013 at 9:03 AM
I would also be interested in this issue.
And also I want to add that if a mixed type contains a sequence of additional elements this elements are added as properties. So my question for that would be how to fill the class correctly so I would get a valid XML after serialization?


Jan 1, 2014 at 9:34 PM
Edited Jan 2, 2014 at 11:28 AM
I don't know why xsd2code generate a list of string in case of mixed="true".
May be a bug, i have to work on it.

But, if you want to produce an XML like this,
<?xml version="1.0"?>
<Field Name="a field name">the field value</Field>
Just create the element bellow,
<xs:element name="Field" xmlns:xs="http://www.w3.org/2001/XMLSchema">
            <xs:extension base="xs:string">
                <xs:attribute name="Name" type="xs:string" />