XmlSchemaClassGenerator icon indicating copy to clipboard operation
XmlSchemaClassGenerator copied to clipboard

Attributes with - symbol are not generated

Open gunhasiz opened this issue 9 months ago • 2 comments

``I've recently using your XmlSchemcaClassGenerator tool and it seems that attributes which contains - characted in name, are not generated in final XML.

For example for attribute: <xs:attribute name="ID-CLASS" type="xs:NMTOKEN" fixed="NAME"/>

Is there any solutions to this or is it a bug?

@EDIT

Actually it's different issue. Because of default value of attribute with fixed="NAME", XSCGen generates this:

[System.Xml.Serialization.XmlIgnoreAttribute()]
private string _idclass = "NAME";

[System.ComponentModel.DefaultValueAttribute("NAME")]
[System.Xml.Serialization.XmlAttributeAttribute("ID-CLASS")]
public string Idclass
    {
        get
        {
            return _idclass;
        }
        set
        {
            _idclass = value;
        }
    }

where deleting [System.ComponentModel.DefaultValueAttribute("NAME")] solves my problem. Why it's handled this way? How can this be solved?

gunhasiz avatar Mar 24 '25 11:03 gunhasiz

Do you expect the DefaultValueAttribute not to be generated?

mganss avatar Mar 29 '25 20:03 mganss

I do expect to have default value, that's correct. It doesn't matter if its encapsulated by private string or with DefaultValueAttribute. I expect to use that C# classes from schema to generate xml's with correct behaviour, so with example I gave, I expect to generate something like this:

<MY_TAG ID-CLASS="NAME">

but it generates

<MY_TAG>

Perhaps I'm doing something wrong?

gunhasiz avatar Mar 31 '25 07:03 gunhasiz