tags:

views:

292

answers:

1

I have a simple schema that I am trying to read using XmlSchema.Read() method. I keep getting

The 'nillable' attribute is not supported in this context

Here is a simple code in C#

XmlSchema schema = null;

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

Below is the schema

<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"&gt;
<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>
A: 

Your schema is simply wrong. You've got some mismatched tags. Try this:

<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"&gt;
    <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>
John Saunders