简体   繁体   English

使用XSD.exe从多个XSD架构生成c#类

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

I have 2 XSD files. 我有2个XSD文件。

One XSD file lets say ABC.xsd contains the elements which are part of XML. 一个XSD文件可以说ABC.xsd包含属于XML的元素。 The other XSD file lets say XYZ.xsd contains the definations of those elements. 另一个XSD文件让我们说XYZ.xsd包含这些元素的定义。

Now in ABC.XSD(which holds the elements) schema tag along with other namespaces we have mentioned the schemalocation as well 现在在ABC.XSD(包含元素)模式标记以及其他名称空间中,我们也提到了schemalocation

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

When I am executing xsd.exe to genereate my C# classes. 当我执行xsd.exe来生成我的C#类时。 It is generating classes but missing some definations from XYZ.xsd. 它正在生成类,但缺少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 编辑1: @Felice,在我的XYZ.xsd中,我有这样的定义

<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. 看到这里定义的模式,它没有出现在C#类中。 Any help. 任何帮助。 Sorry I am new to this . 对不起,我是新来的。 Thanks your answer worked 谢谢你的回答

Referencing the main XSD did not work for me. 引用主XSD对我不起作用。

I had to reference the dependant XSD files as per this link 我必须根据此链接引用依赖的XSD文件

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

只传递“main”xsd作为参数,确保另一个位于main的相同位置,它应该可以工作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM