开发者

XSD Generation of a runtime object

开发者 https://www.devze.com 2023-01-12 19:35 出处:网络
I am trying to generate a C# class based on an .xsd schema.This schema has several imports which I included on the command line in my batch file.It also has includes that should be resolved by using t

I am trying to generate a C# class based on an .xsd schema. This schema has several imports which I included on the command line in my batch file. It also has includes that should be resolved by using the schemaLocation to find the file on the disk. I am开发者_JS百科 getting errors for several types that are supposedly not declared. These definitions are in the "included" schemas in a folder beneath the schema where the value is used.


If you have the included schemas, XSD.EXE handles this fairly well, but you have to dig to find the documentation.

Look at this link in the poriton about using an XML file to direct XSD.EXE. The short version is that you'll create a small xml file with multiple <Schema> nodes which point to: the schema for which you actually need schemas AND the imported schemas.

Then you'll run XSD.EXE /p [yourXsdFile.xsd]. If you've follwed the instructions correctly (I've only done it once, so I'm no expert, and it took me a couple of tries to get the results I wanted) you'll get a single .cs file with all the necessary class data.

0

精彩评论

暂无评论...
验证码 换一张
取 消