You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am getting the following xsd (simplified) with different use of anyAttribute:
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified">
<!-- With attribute group it does not work -->
<xs:complexType name="SaleType">
<xs:attributeGroup ref="anyAttribute" />
</xs:complexType>
<!-- Without attribute group it does work -->
<xs:complexType name="OrderType">
<xs:anyAttribute namespace="##other" />
</xs:complexType>
<!-- If used with simple content it works-->
<xs:complexType name="PurchaseType">
<xs:simpleContent>
<xs:extension base="xs:string">
<xs:attributeGroup ref="anyAttribute" />
</xs:extension>
</xs:simpleContent>
</xs:complexType>
<!-- Attribute group with anyAttribute -->
<xs:attributeGroup name="anyAttribute">
<xs:anyAttribute namespace="##other" />
</xs:attributeGroup>
The problem is that only with the first one SaleType no code for anyAttribute is generated. Why is that?
As soon as I have an attributeGroup with anyAttribute in it no Code is generated for it, but If I add the anyAttribute in the complex type directly (OrderType) or if I have it in a simpleContent (complexContent does not work iirc) (PurchaseType) it works...
As a workaround I modify the xsd and put the anyAttribute in directly but there will be new versions in the future and I would rather avoid doing that.
Here the generated code (SaleType is completely empty except the interface which is also empty):
//------------------------------------------------------------------------------// <auto-generated>// This code was generated by a tool.// Runtime Version:4.0.30319.42000//// Changes to this file may cause incorrect behavior and will be lost if// the code is regenerated.// </auto-generated>//------------------------------------------------------------------------------// This code was generated by XmlSchemaClassGenerator version 2.1.1164.0namespaceOrder{[System.CodeDom.Compiler.GeneratedCodeAttribute("XmlSchemaClassGenerator","2.1.1164.0")][System.SerializableAttribute()][System.Xml.Serialization.XmlTypeAttribute("SaleType",Namespace="")][System.Diagnostics.DebuggerStepThroughAttribute()][System.ComponentModel.DesignerCategoryAttribute("code")]publicpartialclassSaleType:IanyAttribute{}[System.CodeDom.Compiler.GeneratedCodeAttribute("XmlSchemaClassGenerator","2.1.1164.0")]publicpartialinterfaceIanyAttribute{}[System.CodeDom.Compiler.GeneratedCodeAttribute("XmlSchemaClassGenerator","2.1.1164.0")][System.SerializableAttribute()][System.Xml.Serialization.XmlTypeAttribute("OrderType",Namespace="")][System.Diagnostics.DebuggerStepThroughAttribute()][System.ComponentModel.DesignerCategoryAttribute("code")]publicpartialclassOrderType{[System.Xml.Serialization.XmlIgnoreAttribute()]privateSystem.Collections.Generic.List<System.Xml.XmlAttribute>_anyAttribute;[System.Xml.Serialization.XmlAnyAttributeAttribute()]publicSystem.Collections.Generic.List<System.Xml.XmlAttribute>AnyAttribute{get{return_anyAttribute;}privateset{_anyAttribute=value;}}/// <summary>/// <para xml:lang="en">Gets a value indicating whether the AnyAttribute collection is empty.</para>/// </summary>[System.Xml.Serialization.XmlIgnoreAttribute()]publicboolAnyAttributeSpecified{get{return(this.AnyAttribute.Count!=0);}}/// <summary>/// <para xml:lang="en">Initializes a new instance of the <see cref="OrderType" /> class.</para>/// </summary>publicOrderType(){this._anyAttribute=newSystem.Collections.Generic.List<System.Xml.XmlAttribute>();}}[System.CodeDom.Compiler.GeneratedCodeAttribute("XmlSchemaClassGenerator","2.1.1164.0")][System.SerializableAttribute()][System.Xml.Serialization.XmlTypeAttribute("PurchaseType",Namespace="")][System.Diagnostics.DebuggerStepThroughAttribute()][System.ComponentModel.DesignerCategoryAttribute("code")]publicpartialclassPurchaseType:IanyAttribute{/// <summary>/// <para xml:lang="en">Gets or sets the text value.</para>/// </summary>[System.Xml.Serialization.XmlTextAttribute()]publicstringValue{get;set;}[System.Xml.Serialization.XmlIgnoreAttribute()]privateSystem.Collections.Generic.List<System.Xml.XmlAttribute>_anyAttribute;[System.Xml.Serialization.XmlAnyAttributeAttribute()]publicSystem.Collections.Generic.List<System.Xml.XmlAttribute>AnyAttribute{get{return_anyAttribute;}privateset{_anyAttribute=value;}}/// <summary>/// <para xml:lang="en">Gets a value indicating whether the AnyAttribute collection is empty.</para>/// </summary>[System.Xml.Serialization.XmlIgnoreAttribute()]publicboolAnyAttributeSpecified{get{return(this.AnyAttribute.Count!=0);}}/// <summary>/// <para xml:lang="en">Initializes a new instance of the <see cref="PurchaseType" /> class.</para>/// </summary>publicPurchaseType(){this._anyAttribute=newSystem.Collections.Generic.List<System.Xml.XmlAttribute>();}}}
I am getting the following xsd (simplified) with different use of
anyAttribute
:The problem is that only with the first one
SaleType
no code for anyAttribute is generated. Why is that?As soon as I have an attributeGroup with anyAttribute in it no Code is generated for it, but If I add the anyAttribute in the complex type directly (
OrderType
) or if I have it in a simpleContent (complexContent does not work iirc) (PurchaseType
) it works...As a workaround I modify the xsd and put the anyAttribute in directly but there will be new versions in the future and I would rather avoid doing that.
Here the generated code (SaleType is completely empty except the interface which is also empty):
Edit:
I found another weird case with complexContent:
StockType1
has the anyAttribute whileStockType2
has it with the attributeGroup.But in the produced code all types are empty:
The text was updated successfully, but these errors were encountered: