voidengine
voidengine

Reputation: 2579

Incorrect IsAbstract value in a referenced XmlSchemaElement

I'm working with an XML schema that contains abstract element definitions, such as

<element name="AbstractX" type="some:Type" abstract="true"/>

When loading this schema in an XmlSchemaSet, I can find this element in its GlobalElements and see that it has the IsAbstract property set to true. So far so good.

However, this element is also referenced in a type like this

<complexType name="ReferencingX">
    <complexContent>
        <extension base="some:otherBaseType">
            <sequence>
                <element ref="some:AbstractX"/>
            </sequence>
        </extension>
    </complexContent>
</complexType>

In the parsed XmlSchemaSet, when I navigate to the element through the complex type definition, it has IsAbstract set to false.

Is there some reason for that, or is it a bug in System.Xml.Schema?

(I've simplified the XSD for the sake of brevity, the schema in question is AIXM)

Upvotes: 2

Views: 96

Answers (1)

Petru Gardea
Petru Gardea

Reputation: 21638

No, it is not a bug.

What you're looking at in your code is a reference to an (abstract) element; references cannot be marked abstract (section 3.3.2 XML Schema Part 1, abstract is applicable only when the schema is the parent of the element).

You simply need to:

  • check if el.RefName.IsEmpty; in your case, it is not (since you used the ref attribute).
  • navigate to the appropriate definition in GlobalElements[el.RefName], cast the value to an XmlSchemaElement, and then check its IsAbstract property (which will be true in your case).

This should address your problem.

Upvotes: 1

Related Questions