Tool that can combine many XSD files into one?

放肆的年华 提交于 2019-11-28 06:52:56
Sandhya

What you can do is to create another new file called file.xsd containing all the schema names in it and then the trick is to name the last schema file with .\ as prefix.

File.xsd

<xsd xmlns='http://microsoft.com/dotnet/tools/xsd/'>
    <generateClasses language='CS' namespace='MyNamespace'>
        <schema>First.xsd</schema>
        <schema>Second.xsd</schema>
        <!-- more schema files here -->
        <schema>.\Third.xsd</schema>
    </generateClasses>
</xsd>

Now run the command “xsd.exe /p:file.xsd /classes” and you get the class file generated :)

For future references, another tool designed for XML Schema refactoring is QTAssistant - I am associated with it.

To clarify your question and hopefully help others... One thing that cannot be achieved as requested by you is that one cannot de-reference imports: an XSD file is associated with one XML Schema which doesn't allow more than one target namespace per xsd:schema element.

An xsd:include can be "inlined"; since files must have the same target namespace or match the "chameleon" namespace design approach, it is possible to merge the content of a file into the other.

An xsd:import cannot be "inlined"... unless you refactor target namespaces as well. However, this would not produce an equivalent schema set.

If you have a fully defined XML Schema set authored across 65 XSD files, with say 10 namespaces, the "canonical" set of re-factored XML Schema files has to have at least 10 files in it.

ewall

I did locate a tool (basically an XSLT) for doing this kind of thing: Paul Kiel's XML Schema Flattener, but I haven't got my hands on it yet.

Other sources say that tools like Oxygen XML Editor and XMLSpy can do it too, but I can't figure out how.

-> http://www.oxygenxml.com/xml_schema_editor.html#xml_schema_flatten

In my case, I solved the problem via another circuitous route: shortening the name of each input XSD so that XSD.EXE's combined output name--which you can't choose--is below the 260 character limit.

I just started using Altova XML Spy ( 1 day )

To flatten .xsd schema into one document... that will still validate, and supply references to click in eclipse...

  1. open up the .xsd that you are talking about...
  2. Menu Item called ( Schema Design ) has an item called ( Flatten Schema ).
  3. Click it. ( it will ask you where to save the new file... I just create an output folder or something.

It seems to work just fine.

Just add .\ prefix with the name of last .xsd(schema) file and enclose it in commas e.g ".\last.xsd". The output class will be generated with the last schema file name.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!