0
votes

can anybody help me how to return the enumeration of my XSD complexType

I want to get Hz, and Orders enumeration.

<xs:complexType name="ScalarType">
    <xs:simpleContent>
      <xs:extension base="xs:float">
        <xs:attribute name="Units">
          <xs:simpleType>
            <xs:restriction base="xs:string">
              <xs:enumeration value="Hz"/>
              <xs:enumeration value="Orders"/>              
            </xs:restriction>
          </xs:simpleType>
        </xs:attribute>
      </xs:extension>
    </xs:simpleContent>
  </xs:complexType>

Thanks!

1
What do you mean by 'return'? You've got a XSD type definition there - you've created a type that must have a float element value with an attribute "Units" that must have one of two values. I don't see what there is to return.Nic Gibson
I want to extract the enum and put it in a List<string>. my list would contain Hz & Orders.user446428

1 Answers

1
votes

Using LINQ to XML:

Make an XElement reference referring to that complex type in your question.

then:

var listOfEnumerationStrings = yourComplexTypeElement
                                  .Descendants("xs" + "enumeration")
                                  .Select(a => a.Attribute("value").Value);