XmlSchemaClassGenerator icon indicating copy to clipboard operation
XmlSchemaClassGenerator copied to clipboard

XLink types are directly in generated classes, instead of being composed

Open sharadhr opened this issue 3 years ago • 1 comments

I notice that this issue was already (partially) fixed in #150, but I notice that upon attempting to generate the classes in the schema linked: https://www.fixm.aero/releases/FIXM-4.1.0/schemas/core/base/Airspace.xsd

In particular, consider the complexType SignificantPointType. After using the suggested -t- option to not generate interfaces, this is the resulting SignificantPointType class declaration:

//------------------------------------------------------------------------------
// <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.0.565.0 using the following command:
// XmlSchemaClassGenerator.Console -v --sf -r --nc --cn -t- -a- -o .\FixmLib\src\ .\**\*.xsd
namespace Base
{
    using System;
    using System.CodeDom.Compiler;
    using System.Collections.Generic;
    using System.Collections.ObjectModel;
    using System.ComponentModel;
    using System.ComponentModel.DataAnnotations;
    using System.Diagnostics;
    using System.Xml;
    using System.Xml.Schema;
    using System.Xml.Serialization;
    
    
    /// <summary>
    /// <para>A location type restricted to lat/long location, fix (waypoint) location, or FRD 
    ///            (radial distance offset).</para>
    /// </summary>
    [DescriptionAttribute("A location type restricted to lat/long location, fix (waypoint) location, or FRD " +
        "(radial distance offset).")]
    [GeneratedCodeAttribute("XmlSchemaClassGenerator", "2.0.565.0")]
    [SerializableAttribute()]
    [XmlTypeAttribute("SignificantPointType", Namespace="http://www.fixm.aero/base/4.1")]
    [DebuggerStepThroughAttribute()]
    [DesignerCategoryAttribute("code")]
    [XmlRootAttribute("SignificantPoint", Namespace="http://www.fixm.aero/base/4.1")]
    [XmlIncludeAttribute(typeof(DesignatedPointOrNavaidType))]
    [XmlIncludeAttribute(typeof(PositionPointType))]
    [XmlIncludeAttribute(typeof(RelativePointType))]
    public abstract partial class SignificantPointType : Base.ExtensibleType
    {
        
        [XmlIgnoreAttribute()]
        private Xlink.typeType _type = Xlink.typeType.simple;
        
        [DefaultValueAttribute(Xlink.typeType.simple)]
        [XmlAttributeAttribute("type", Namespace="http://www.w3.org/1999/xlink", Form=XmlSchemaForm.Qualified)]
        public Xlink.typeType type
        {
            get
            {
                return this._type;
            }
            set
            {
                this._type = value;
            }
        }
        
        [XmlAttributeAttribute("href", Namespace="http://www.w3.org/1999/xlink", Form=XmlSchemaForm.Qualified)]
        public String href { get; set; }
        
        /// <summary>
        /// <para xml:lang="en">Minimum length: 1.</para>
        /// </summary>
        [MinLengthAttribute(1)]
        [XmlAttributeAttribute("role", Namespace="http://www.w3.org/1999/xlink", Form=XmlSchemaForm.Qualified)]
        public String role { get; set; }
        
        /// <summary>
        /// <para xml:lang="en">Minimum length: 1.</para>
        /// </summary>
        [MinLengthAttribute(1)]
        [XmlAttributeAttribute("arcrole", Namespace="http://www.w3.org/1999/xlink", Form=XmlSchemaForm.Qualified)]
        public String arcrole { get; set; }
        
        [XmlAttributeAttribute("title", Namespace="http://www.w3.org/1999/xlink", Form=XmlSchemaForm.Qualified)]
        public String title { get; set; }
        
        [XmlAttributeAttribute("show", Namespace="http://www.w3.org/1999/xlink", Form=XmlSchemaForm.Qualified)]
        public Xlink.showType show { get; set; }
        
        /// <summary>
        /// <para xml:lang="en">Gets or sets a value indicating whether the show property is specified.</para>
        /// </summary>
        [XmlIgnoreAttribute()]
        public bool showSpecified { get; set; }
        
        [XmlAttributeAttribute("actuate", Namespace="http://www.w3.org/1999/xlink", Form=XmlSchemaForm.Qualified)]
        public Xlink.actuateType actuate { get; set; }
        
        /// <summary>
        /// <para xml:lang="en">Gets or sets a value indicating whether the actuate property is specified.</para>
        /// </summary>
        [XmlIgnoreAttribute()]
        public bool actuateSpecified { get; set; }
    }
}

I notice that the properties _type, role, arcrole, etc are from the XLink schema, and I would really rather not have them within the above class itself. Not having the -t- command-line option means that the resultant XLink classes are non-compilable and have to be manually fixed.

Is there no other solution?

sharadhr avatar Aug 05 '21 06:08 sharadhr

I can't repro. I have generated classes with the options shown in your example and they compile fine.

mganss avatar Aug 05 '21 11:08 mganss