如何在Java中规范化WSDL文件? [英] How to canonicalize WSDL files in Java?
问题描述
我需要找到两个WSDL文件的差异。我开始通过漂亮打印它们像这里,但我看到那里在不同顺序中定义的两个文件(出于任何愚蠢的原因)中是相同的(例如 complexType
s)。我想进一步规范化文件,所以我以后可以使用标准的 diff
来查找差异。
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. complexType
s) 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.
不知道是否有一个定义的WSDL规范形式,我知道有 Canonical XML ,但我需要进一步排序并排序所有顺序无关紧要的事情。
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.
推荐答案
我以递归的方式遍历树并排序匹配 schema | wsdl:binding | wsdl:portType | wsdl:types | wsdl:definitions
的节点的所有子节点。我使用这个答案来漂亮地打印输出。无论出于何种原因 format.setLineWidth(65);
不起作用,所以我不得不使用 replaceAll(\\s加入这些行* \ n \\\\ * *(?= [^ \\s<]),)
。它似乎工作正常。
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.
这篇关于如何在Java中规范化WSDL文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!