Find annotation for xml element in related schema view

I have an xml type, USAddress defined in a schema:

<xsd:element name="MyUSAddress" type="USAddress"/>
<xsd:complexType name="USAddress">
  <xsd:sequence>
    <xsd:element name="name"   type="xsd:string"/>
    <xsd:element name="street" type="xsd:string">
      <xsd:annotation>
        <xsd:appinfo>Special Metadata</xsd:appinfo>
      </xsd:annotation>
    </xsd:element>
    <xsd:element name="city"   type="xsd:string"/>
    <xsd:element name="state"  type="xsd:string">
      <xsd:annotation>
        <xsd:appinfo>Special Metadata</xsd:appinfo>
      </xsd:annotation>
    </xsd:element>
    <xsd:element name="zip"    type="xsd:decimal"/>
  </xsd:sequence>
</xsd:complexType>

And the XML element in the data instance document:

<MyUSAddress>
   <name>Robert Smith</name>
   <street>8 Oak Avenue</street>
   <city>Old Town</city>
   <state>PA</state>
   <zip>95819</zip>
</MyUSAddress>

The schema and instance data are not known at compile time, so all analysis is performed dynamically. The simplicity of this scheme is for purposes only. Real schemes will be more complex.

Assuming I have a schema loaded in System.Xml.Schema.XmlSchema when I visit each node in my instance XML document , how can I get the associated schema element and read its appinfo annotation?

+3
source share
1 answer

XMLReader.SchemaInfo, node. SchemaType.Annotation.Items.

, / , , .

+3

All Articles