2

I need to find differences in two WSDL files. I started by pretty-printing them like here, but I see there are same things (e.g. complexTypes) in the two files defined (for whatever stupid reason) in a different order. I want to canonicalize the files further, so I can later use things like standard diff to find the differences.

No idea if there's a defined canonical form for WSDL, I know there's Canonical XML, but I need to go a bit further and sort all the things whose order doesn't matter.

Community
  • 1
  • 1
maaartinus
  • 44,714
  • 32
  • 161
  • 320

2 Answers2

1

You can download a Java program from http://www.jclark.com/xml/ which converts XML to Canonical XML. This should be applicable to WSDL files too.

Thorbjørn Ravn Andersen
  • 73,784
  • 33
  • 194
  • 347
  • That's not enough. When canonicalizing XML you mustn't reorder the elements, since the element order is significant in XML. In WSDL there are at least some places, where the order is insignificant, e.g., you may swap the definitions of two types. I've got files I need to compare, which differs by the type definitions order (and whatever, I can't tell yet). – maaartinus Jun 24 '11 at 00:28
0

I ran through the tree recursively and sorted all children of nodes matching schema|wsdl:binding|wsdl:portType|wsdl:types|wsdl:definitions. I used this answer for pretty-printing the output. For whatever reason format.setLineWidth(65); doesn't work, so I had to join the lines using replaceAll("\\s*\n\\s*(?=[^\\s<])", " "). It seems to work fine.

Community
  • 1
  • 1
maaartinus
  • 44,714
  • 32
  • 161
  • 320