Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using XSD.exe to generate c# classes from multiple XSD schemas

Tags:

c#

.net

xml

xsd

I have 2 XSD files.

One XSD file lets say ABC.xsd contains the elements which are part of XML. The other XSD file lets say XYZ.xsd contains the definations of those elements.

Now in ABC.XSD(which holds the elements) schema tag along with other namespaces we have mentioned the schemalocation as well

<xs:schema schemaLocation="XYZ.xsd">

When I am executing xsd.exe to genereate my C# classes. It is generating classes but missing some definations from XYZ.xsd.

I am executing

xsd.exe "ABC.xsd" "XYZ.xsd" /c

Any help would be appreicate

EDIT 1: @Felice, in my XYZ.xsd I have defination like this

<xs:simpleType name="contactNumberType">
        <xs:annotation>
            <xs:documentation>Contact phone or fax number with national or international format.  Only numbers are allowed</xs:documentation>
        </xs:annotation>
        <xs:restriction base="xs:string">
            <xs:pattern value="\+?\p{N}{6,24}"/>
        </xs:restriction>
    </xs:simpleType>

See the pattern defined here, it is not appearing in the C# class. Any help. Sorry I am new to this . Thanks your answer worked

like image 315
Shax Avatar asked Jun 23 '11 11:06

Shax


1 Answers

Referencing the main XSD did not work for me.

I had to reference the dependant XSD files as per this link

http://bembengarifin.wordpress.com/2009/07/14/generate-net-class-from-xsd-with-references-to-other-xsd-using-xsd-exe/

like image 84
user1619480 Avatar answered Sep 23 '22 21:09

user1619480