Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/unity3d/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/cmake/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
是否有任何方法可以忽略此操作<;选择>;元素由xsd.exe绑定_Xsd_Xsd.exe - Fatal编程技术网

是否有任何方法可以忽略此操作<;选择>;元素由xsd.exe绑定

是否有任何方法可以忽略此操作<;选择>;元素由xsd.exe绑定,xsd,xsd.exe,Xsd,Xsd.exe,我的模式中有以下元素: <xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema"> <xs:complexType name="optimizeModelBase"> <xs:attribute name="name" type="xs:string"/> <

我的模式中有以下元素:

<xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified"
xmlns:xs="http://www.w3.org/2001/XMLSchema">
  <xs:complexType name="optimizeModelBase">
    <xs:attribute name="name" type="xs:string"/>
  </xs:complexType>

  <xs:complexType name="riskModel">
    <xs:complexContent>
      <xs:extension base="optimizeModelBase">
        <xs:attribute name="type" type="xs:string" use="required"/>        
      </xs:extension>      
    </xs:complexContent>
  </xs:complexType>

  <xs:complexType name="fullCovariance">
    <xs:complexContent>
      <xs:extension base="optimizeModelBase">
        <xs:attribute name="fromDate" type="xs:date" use="required"/>
        <xs:attribute name="toDate" type="xs:date" use="required"/>
        <xs:attribute name="windowSize" type="xs:int" use="required"/>
      </xs:extension>
    </xs:complexContent>    
  </xs:complexType>
问题是元素的ID标记被忽略,xsd.exe任意命名属性“Item”。我必须承认,这不是一个大问题,但它开始让我烦恼。更让人恼火的是,如果在同一级别有其他元素,xsd.exe会将它们绑定为“Item1”、“Item2”等


有人知道是否可以不让xsd.exe将我的选择元素命名为“Item”,而是可以输入我自己的属性名吗?

我到处搜索,但似乎没有解决问题的方法。根据链接:


choice元素的任意命名似乎是不可重写的。希望这些信息对其他人有帮助

我曾经解析过一个自动生成的xsd.exe文件,并使用NRefactory对其进行了更改。

我自己在处理xsd.exe时遇到了这个限制。就XSD.exe如何解释所有元素类型的ID属性而言,这似乎是一种相当统一的做法。我很想听听微软开发团队的人对XSD.exe为何以这种方式工作的合理解释

有趣的是,我一直在研究一个SchemaImporterExtension,它将利用choice元素的ID属性来精确地实现您所描述的,一种定制choice映射对象成员的字段/属性名称的方法

不幸的是,XSD.exe似乎不仅不支持ID属性绑定,而且似乎还没有将ID包含在XmlSchemaChoice对象中,该对象反映了已解析模式文档中的choice元素

也许我遗漏了什么,但如果这确实是我的预期行为,而不是我的错误,那么在我的估计中,这是一个相当荒谬的遗漏,它说明了MS schema自动生成工具中反映了多少中性XSD表示

XSD.exe遵循我将称之为XML模式标准的“精简而中庸”的解释。很明显,现在WCF消除了XSD.exe,猜猜怎么着?WCF的svcutil工具可以识别更小的XML模式;svcutil IIRC甚至不支持选项元素绑定


在某种程度上,我甚至不确定MS自动生成工具将为您带来什么价值,因为您将不得不使用简单的XSD结构(我的意思是,无选择元素支持?真的吗?)来封装您的业务对象建模。

今天正好遇到了这个问题

我有一个解决方法,所以你可以用一个小组而不是选择来回避这个问题

以上述xsd为基础:

重写:

<xs:choice id="RiskModelParameter">
  <xs:element name="RiskModel" type="riskModel"/>
  <xs:element name="FullCovariance" type="fullCovariance"/>
</xs:choice>

如果需要多个RiskModels和FullConvariance对象项,可以添加一个新元素,在序列中包含RiskModelGroup


祝你好运

对于那些仍然想知道的人:只需使用XSDObjectGenerator(微软制造)。它通过为类中的每个选项添加一个对象来管理XsdChoice。这样,您就不必为Item属性寻找正确的元素。 例如:

<xs:complexType name="AccountSchemeName1Choice">
    <xs:sequence>
        <xs:choice>
            <xs:element name="Cd" type="ExternalAccountIdentification1Code"/>
            <xs:element name="Prtry" type="Max35Text"/>
        </xs:choice>
    </xs:sequence>
</xs:complexType>

谢谢,但我确实只需要发送一个或另一个xml节点。服务器端根据xml的形式进行切换。因此,发送两个节点(即使其中一个节点为零)将无法工作。文本墙!目前还不完全清楚这是否回答了这个问题。我建议您添加一些格式、段落、标题等,以使其更易于阅读。设置了文本墙的格式,以便我可以阅读,因此,就在这里
<xs:choice id="RiskModelParameter">
  <xs:element name="RiskModel" type="riskModel"/>
  <xs:element name="FullCovariance" type="fullCovariance"/>
</xs:choice>
<xs:group name="RiskModelGroup">
    <xs:sequence>
        <xs:element name="RiskModel" type="riskModel"/>
        <xs:element name="FullCovariance" type="fullCovariance"/>
    </xs:sequence>
</xs:group>
<xs:element name="Foo">
  <xs:complexType>
    <xs:sequence>
      <xs:element name="SomeFieldId" type="xs:int" />
      <xs:group ref="RiskModelGroup" minOccurs="1" maxOccurs="1"/>
    </xs:sequence>
    </xs:complexType>
</xs:element>
public partial class Foo {

    private int someFieldIdField;

    private riskModel riskModelField;

    private fullCovariance fullCovarianceField;

    /// <remarks/>
    public int SomeFieldId {
        get {
            return this.someFieldIdField;
        }
        set {
            this.someFieldIdField = value;
        }
    }

    /// <remarks/>
    public riskModel RiskModel {
        get {
            return this.riskModelField;
        }
        set {
            this.riskModelField = value;
        }
    }

    /// <remarks/>
    public fullCovariance FullCovariance {
        get {
            return this.fullCovarianceField;
        }
        set {
            this.fullCovarianceField = value;
        }
    }
}
Foo f = new Foo()
f.RiskModel.name
f.FullCovariance.fromDate
<xs:complexType name="AccountSchemeName1Choice">
    <xs:sequence>
        <xs:choice>
            <xs:element name="Cd" type="ExternalAccountIdentification1Code"/>
            <xs:element name="Prtry" type="Max35Text"/>
        </xs:choice>
    </xs:sequence>
</xs:complexType>
[XmlType(TypeName = "AccountSchemeName1Choice", Namespace = Declarations.SchemaVersion), Serializable]
public class AccountSchemeName1Choice : INotifyPropertyChanged
{

    [XmlElement(ElementName = "Cd", IsNullable = false, Form = XmlSchemaForm.Qualified, DataType = "string", Namespace = Declarations.SchemaVersion)]
    public string __Cd;

    [XmlIgnore]
    public string Cd
    {
        get { return __Cd; }
        set { __Cd = value; RaisePropertyChanged("Cd"); }
    }

    [XmlElement(ElementName = "Prtry", IsNullable = false, Form = XmlSchemaForm.Qualified, DataType = "string", Namespace = Declarations.SchemaVersion)]
    public string __Prtry;

    [XmlIgnore]
    public string Prtry
    {
        get { return __Prtry; }
        set { __Prtry = value; RaisePropertyChanged("Prtry"); }
    }

    public AccountSchemeName1Choice()
    {
    }

    [field: NonSerialized]
    public event PropertyChangedEventHandler PropertyChanged;
    private void RaisePropertyChanged(string propertyName)
    {
        if (PropertyChanged != null) PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
    }
}