Nickolodeon
Nickolodeon

Reputation: 2956

Generating 'relaxed' xsd from xml

How can xsd be generated so as to allow extra attributes in input xml be present for some tags?

Actually I am loading XmlReader with XmlReaderSettings which is loaded with the xsd file.

I use xsd.exe /c input.xml (Without /classes switch I would get an error that nested columns are not allowed).

Upvotes: 0

Views: 115

Answers (1)

Petru Gardea
Petru Gardea

Reputation: 21658

Unfortunately, assuming your primary artifact is your XML, there is no direct way to do such a thing. You will need to first generate an XSD from your XML, then inject <xs:anyAttribute/> in the appropriate places, then from that modified XSD generate the classes.

A quick search for anyAttribute may yield a number of references, such as this. Typically, you will have to add these attribute wildcard by hand, unless you have access to an automatic XML Schema refactoring that can do that for you. This should allow you to regenerate your "gold" XSD independently of your manual changes.

Upvotes: 2

Related Questions