C# Help: Adding a complexType to the main XmlSchema

Posted by G33kKahuna on Stack Overflow See other posts from Stack Overflow or by G33kKahuna
Published on 2010-03-25T23:21:35Z Indexed on 2010/03/25 23:23 UTC
Read the original article Hit count: 400

Filed under:
|

I need to create program that creates a XML schema like below using System.Xml.XmlSchema namespace

I'm using the XmlSchemaComplexType to MyString and MyInteger but I can't seem to find a way to set the extension to base string and int respectively.

Any guidance is much appreciated ... thanks

<?xml version="1.0" encoding="utf-8" ?>
<xs:schema elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema">
    <xs:complexType name="MyString">
        <xs:simpleContent>
            <xs:extension base="xs:string">
                <xs:attribute name="modified" type="xs:boolean" />
            </xs:extension>
        </xs:simpleContent>
    </xs:complexType>
    <xs:complexType name="MyInteger">
        <xs:simpleContent>
            <xs:extension base="xs:int">
                <xs:attribute name="modified" type="xs:boolean" />
            </xs:extension>
        </xs:simpleContent>
    </xs:complexType>
    <xs:element name="data">
        <xs:complexType>
            <xs:sequence>
                <xs:element name="row">
                    <xs:complexType>
                        <xs:sequence>
                            <xs:element name="order_id" type="MyInteger" />
                            <xs:element name="order_status" type="MyString" />
                        </xs:sequence>
                    </xs:complexType>
                </xs:element>
            </xs:sequence>
        </xs:complexType>
    </xs:element>
</xs:schema>

© Stack Overflow or respective owner

Related posts about c#

Related posts about xmlschema