2017-05-17 7 views
2

私はトラブルattributeGrouprefとを使用しながら、xsd.exeを使用してのことだとXsd.exeではを使用する方法。私はそれを使ってC#クラスを生成します。attributeGroupのrefの

は、ここに私のXSDです:

<?xml version="1.0" encoding="utf-8"?> 
<xs:schema xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
      elementFormDefault="qualified" 
      xmlns:xs="http://www.w3.org/2001/XMLSchema" 
      version="1.0"> 

    <xs:attributeGroup name="PersonBaseAttributes"> 
    <xs:attribute name="Name" type="xs:string" use="required" /> <!-- Missing in .CS --> 
    <xs:attribute name="Born" type="xs:dateTime" use="required" /> <!-- Missing in .CS --> 
    </xs:attributeGroup> 

    <xs:attributeGroup name="SalesAttributes"> 
    <xs:attributeGroup ref="PersonBaseAttributes" /> 
    <xs:attribute name="Sales" type="xs:int" use="required" /> 
    </xs:attributeGroup> 

    <xs:attributeGroup name="BossAttributes"> 
    <xs:attributeGroup ref="PersonBaseAttributes" /> 
    <xs:attribute name="Department" type="xs:string" use="required" /> 
    </xs:attributeGroup> 

    <xs:element name="Boss" nillable="true" type="BossPerson" /> 
    <xs:element name="Sales" nillable="true" type="SalesPerson" /> 
    <xs:complexType name="SalesPerson"> 
    <xs:attributeGroup ref="SalesAttributes" /> 
    </xs:complexType> 
    <xs:complexType name="BossPerson"> 
    <xs:attributeGroup ref="BossAttributes" /> 
    </xs:complexType> 
</xs:schema> 

それは、この2つのクラスを生成:

public partial class SalesPerson { 

    private int salesField; 

    /// <remarks/> 
    [System.Xml.Serialization.XmlAttributeAttribute()] 
    public int Sales { 
     get { 
      return this.salesField; 
     } 
     set { 
      this.salesField = value; 
     } 
    } 
} 

public partial class BossPerson { 

    private string departmentField; 

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

生成されたクラスはPersonBaseAttributesからフィールドNameBornが欠落しています。 私のXSDが間違っているか、またはxsd.exeがそれを処理する方法を知らないのですか?

xsd.exeが処理できない場合は、他の方法がありますか?

私はこのようにそれを実行します。XMLスキーマは、私には正しいよう

xsd.exe foo.xsd /c 
+0

同じ問題があります。あなたは解決策を見つけることができましたか? –

+0

@ParvSharma - 残念ながら。私の場合、代わりに手動で行った。 – smoksnes

答えて

1

、属性NameBornのない要素BossまたはSalesは、スキーマに対して無効になります(例えば、酸素がこれらの属性を必要としませんあなたのスキーマが提供されている場合)。生成されたコードは、部分クラスで構成されている

注意。ツールは他の属性を他の場所で生成できましたか?

+0

残念ながら、他のクラス/ファイルは生成されません。 – smoksnes