开发者

generate classes from xsd schema without inheritence

I have a series of fairly complex xsd schema files and I would like to create c# classes out of them. I use xsd.exe in Visual Studio 8 and classes are generated fine. However, I would like to bypass inheritance, meaning no classes should inherit from a parent class.

I need this because I create a Web Service with these classes as parameters to my web service methods. The wsdl for the web service generates tags for these child classes. As far as I understand SAP does not accept extension tags when creating a web service client. Therefore I need a开发者_如何学运维 work around for this.

Any help is greatly appreciated.


XML Schema permits inheritence via the xs:extension element,, which allows you to modify a base complexType. When mapping this XML Schema to C# (or Java), it makes sense to map this to class inheritance.

So I guess what you want to do is rather than map to an inheritence hierarchy when an xs:extension is encountered, you want to instead copy the extended properties onto the generated class, i.e. bringing all the super-class methods into the sub-class. I very much doubt you will find an tool that will have this as an option, it is quite an obscure requirement!

Personally I would tackle this by transforming your XML Schema into the structure you want, then using your schema-to-C# tool. A suitable technology for this transformation is XSLT. However, you could write your own tool using Linq-to-XML or other XML manipulation APIs.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜