2

I have two XSD files with common elements and complex types. These XSD were generated by Maximo. How can I merge/flatten the XSDs into one?

The same namespace has been used in both XSDs.

kjhughes
  • 106,133
  • 27
  • 181
  • 240
user0
  • 653
  • 1
  • 7
  • 11
  • Merging named types should be straightforward if there are no name clashes. Merging elements and attributes is probably manual labor (depending on the desired outcome structure). – zx485 Nov 27 '19 at 12:14
  • yeah.. thats what I am expecting to do but there are almost 20 long xsds. – user0 Nov 27 '19 at 15:06

2 Answers2

3

No easy answer, but if the schema documents are sufficiently large then you could invest in some XSLT tooling to reduce the amount of effort.

(a) use xsl:for-each-group to identify top-level components of the same kind and name across both files, e.g. two complexTypes with the same name.

(b) if there's only one element in the group, output it.

(c) if there are two elements in the group, use the deep-equals() function to compare them. If they are deep-equal, then just output the first. Otherwise, output both, together with a TODO comment that flags them for human intervention.

(d) reconcile the conflicts by hand.

If necessary, you could do some "normalization" before the deep-equals() comparison, e.g. stripping whitespace text nodes and xs:annotation elements.

Michael Kay
  • 156,231
  • 11
  • 92
  • 164
1

Try to avoid, or minimize, the problem upstream during XSD generation. Maximo is configurable:

If you set the mxe.int.resolveschema global property to true in the System Properties application, all include files are resolved.

Source: IBM Maximo Asset Management Multitenancy : Schema generation

I do not know for certain, but if all included files are resolved means that the including XSD is flattened, then perhaps this could help you.

kjhughes
  • 106,133
  • 27
  • 181
  • 240