Pluralizing properties in generated code from xsd

I have an XSD that describes the schema for some of my data contracts in the application that I am creating. I am not the most experienced in writing xsd files, but so far nothing I tried has been able to solve my problem.

I have a schema section that looks like this:

<xs:complexType name="RecordSetDefinition">
  <xs:sequence>
    <xs:element name="RecordId" type="RecordIdDefinition" minOccurs="0" maxOccurs="unbounded" />
    <xs:element name="Record" type="RecordDefinition" minOccurs="0" maxOccurs="unbounded" />
  </xs:sequence>
  <xs:attribute name="Id" type="xs:string" />
</xs:complexType>

The XML this corresponds to is as follows:

<RecordSet Id="Test">
  <RecordId ...>
    ...
  </RecordId>
  <RecordId ...>
    ...
  </RecordId>
  <Record ...>
    ...
  </Record>
  <Record ...>
    ...
  </Record>
  <Record ...>
    ...
  </Record>
</RecordSet>

The idea is that my data contract for RecordSetDefinitionhas an array RecordIdDefinitionand RecordDefinitions. Run the generate command:

xsd \c \l:cs

It produces:

[System.CodeDom.Compiler.GeneratedCodeAttribute("xsd", "2.0.50727.1432")]
[System.SerializableAttribute()]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
[System.Xml.Serialization.XmlTypeAttribute(Namespace="...")]
public partial class RecordSetDefinition {

    private RecordIdDefinition[] recordIdField;

    private RecordDefinition[] recordField;

    private string idField;

    /// <remarks/>
    [System.Xml.Serialization.XmlElementAttribute("RecordId")]
    public RecordIdDefinition[] RecordId {
        get {
            return this.recordIdField;
        }
        set {
            this.recordIdField = value;
        }
    }

    /// <remarks/>
    [System.Xml.Serialization.XmlElementAttribute("Record")]
    public RecordDefinition[] Record {
        get {
            return this.recordField;
        }
        set {
            this.recordField = value;
        }
    }

    /// <remarks/>
    [System.Xml.Serialization.XmlAttributeAttribute()]
    public string Id {
        get {
            return this.idField;
        }
        set {
            this.idField = value;
        }
    }
}

That everything is fine and dandy ... except that the names of properties containing arrays of definitions are single, not multiple.

Question:

, , (.. RecordIds RecordId). XSD, xsd.exe #, XML?

XML , , . , , RecordIds, RecordId, RecordIds.RecordId[]. xs:choice RecordIds.Items[], , , .

, , , , .cs .xsd , .

+4
1

, xsd.exe

, . RecordIdList.RecordId[]?

. RecordIds , , .

xsd2code. , , , .

. script, .cs .

.

  • , , , , .
0

All Articles