2009-08-24 11 views
0

J'ai un schéma simple que j'essaie de lire à l'aide de la méthode XmlSchema.Read(). Je continue à obtenirXmlSchema.read déclenche une exception lorsqu'un élément est déclaré nillable

The 'nillable' attribute is not supported in this context 

Voici un simple code en C#

XmlSchema schema = null; 

using (StreamReader reader = new StreamReader(<Path to Schema file name>) 
{ 
    schema = XmlSchema.Read(reader.BaseStream, null); 
} 

Ci-dessous le schéma

<xs:schema xmlns:b="http://schemas.microsoft.com/BizTalk/2003" xmlns="http://xyz.com.schema.bc.mySchema" attributeFormDefault="unqualified" elementFormDefault="qualified" targetNamespace="http://xyz.com.schema.bc.mySchema" xmlns:xs="http://www.w3.org/2001/XMLSchema"> 
<xs:element name="data"> 
    <xs:complexType> 
     <xs:sequence> 
      <xs:element name="Component"> 
       <xs:complexType> 
        <xs:sequence> 
         <xs:element minOccurs="1" maxOccurs="unbounded" name="row"> 
          <xs:complexType> 
           <xs:sequence> 
            <xs:element name="changed_by" type="xs:string" nillable="true" /> 
            <xs:element name="column_name" type="xs:string" nillable="true" /> 
            <xs:element name="comment_text" type="xs:string" nillable="true" /> 
            <xs:element name="is_approved" type="xs:string" nillable="true" /> 
            <xs:element name="log_at" type="xs:dateTime" nillable="true" /> 
            <xs:element name="new_val" type="xs:string" nillable="true" /> 
            <xs:element name="old_val" type="xs:string" nillable="true" /> 
            <xs:element name="person_id" type="xs:string" nillable="true" /> 
            <xs:element name="poh_id" type="xs:string" nillable="true" /> 
            <xs:element name="pol_id" type="xs:string" nillable="true" /> 
            <xs:element name="search_name" type="xs:string" nillable="true" /> 
            <xs:element name="unique_id" type="xs:integer" nillable="true" /> 
           </xs:sequence> 
          </xs:complexType> 
         </xs:element> 
        </xs:sequence> 
       </xs:complexType> 
      </xs:element> 
    </xs:complexType> 
</xs:element> 
</xs:schema> 

Répondre

0

Votre schéma est tout simplement faux. Vous avez des tags incompatibles. Essayez ceci:

<xs:schema xmlns:b="http://schemas.microsoft.com/BizTalk/2003" xmlns="http://xyz.com.schema.bc.mySchema" attributeFormDefault="unqualified" elementFormDefault="qualified" targetNamespace="http://xyz.com.schema.bc.mySchema" xmlns:xs="http://www.w3.org/2001/XMLSchema"> 
    <xs:element name="data"> 
     <xs:complexType> 
      <xs:sequence> 
       <xs:element name="Component"> 
        <xs:complexType> 
         <xs:sequence> 
          <xs:element minOccurs="1" maxOccurs="unbounded" name="row"> 
           <xs:complexType> 
            <xs:sequence> 
             <xs:element name="changed_by" type="xs:string" nillable="true"/> 
             <xs:element name="column_name" type="xs:string" nillable="true"/> 
             <xs:element name="comment_text" type="xs:string" nillable="true"/> 
             <xs:element name="is_approved" type="xs:string" nillable="true"/> 
             <xs:element name="log_at" type="xs:dateTime" nillable="true"/> 
             <xs:element name="new_val" type="xs:string" nillable="true"/> 
             <xs:element name="old_val" type="xs:string" nillable="true"/> 
             <xs:element name="person_id" type="xs:string" nillable="true"/> 
             <xs:element name="poh_id" type="xs:string" nillable="true"/> 
             <xs:element name="pol_id" type="xs:string" nillable="true"/> 
             <xs:element name="search_name" type="xs:string" nillable="true"/> 
             <xs:element name="unique_id" type="xs:integer" nillable="true"/> 
            </xs:sequence> 
           </xs:complexType> 
          </xs:element> 
         </xs:sequence> 
        </xs:complexType> 
       </xs:element> 
      </xs:sequence> 
     </xs:complexType> 
    </xs:element> 
</xs:schema> 
Questions connexes