I need to group some attribute for use in different types, but if I
nest an attributegroup inside another one I miss the nested attribute
in class generated with xsd.exe.
For example if I use the following two schemas xsd.exe give me the same
class.
First Schema:
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns="http://example.org/"
targetNamespace="http://example.org/" elementFormDefault="qualified">
<xsd:attributeGroup name="Gruppo1">
<xsd:attribute name="attributo1" type="xsd:int" use="required"/>
<xsd:attribute name="attributo2" type="xsd:string"
use="required"/>
</xsd:attributeGroup>
<xsd:attributeGroup name="Gruppo2">
<xsd:attribute name="attributo3" type="xsd:int" use="required"/>
<xsd:attribute name="attributo4" type="xsd:string"
use="required"/>
</xsd:attributeGroup>
<xsd:complexType name="key">
<xsd:sequence>
<xsd:element name="key" type="xsd:string"/>
</xsd:sequence>
<xsd:attributeGroup ref="Gruppo1" />
</xsd:complexType>
<xsd:element name="key" type="key"/>
</xsd:schema>
Second Schema:
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns="http://example.org/"
targetNamespace="http://example.org/" elementFormDefault="qualified">
<xsd:attributeGroup name="Gruppo1">
<xsd:attributeGroup ref="Gruppo2" />
<xsd:attribute name="attributo1" type="xsd:int" use="required"/>
<xsd:attribute name="attributo2" type="xsd:string"
use="required"/>
</xsd:attributeGroup>
<xsd:attributeGroup name="Gruppo2">
<xsd:attribute name="attributo3" type="xsd:int" use="required"/>
<xsd:attribute name="attributo4" type="xsd:string"
use="required"/>
</xsd:attributeGroup>
<xsd:complexType name="key">
<xsd:sequence>
<xsd:element name="key" type="xsd:string"/>
</xsd:sequence>
<xsd:attributeGroup ref="Gruppo1" />
</xsd:complexType>
<xsd:element name="key" type="key"/>
</xsd:schema>
xsd.exe generate the same class:
//------------------------------------------------------------------------------
// <autogenerated>
// This code was generated by a tool.
// Runtime Version: 1.1.4322.2032
//
// Changes to this file may cause incorrect behavior and will be
lost if
// the code is regenerated.
// </autogenerated>
//------------------------------------------------------------------------------
//
// This source code was auto-generated by xsd, Version=1.1.4322.2032.
//
using System.Xml.Serialization;
/// <remarks/>
[System.Xml.Serialization.XmlTypeAttribute(Namespac e="http://example.org/")]
[System.Xml.Serialization.XmlRootAttribute(Namespac e="http://example.org/",
IsNullable=false)]
public class key {
/// <remarks/>
[System.Xml.Serialization.XmlElementAttribute("key" )]
public string key1;
/// <remarks/>
[System.Xml.Serialization.XmlAttributeAttribute()]
public int attributo1;
/// <remarks/>
[System.Xml.Serialization.XmlAttributeAttribute()]
public string attributo2;
}
I would like to have some both the attributes of both attributes group
in the same class.
Where is my error?
Thank you