仅对文件节点的属性进行排序
我对XSL不太了解。
我必须比较2个非常大的XML,这些XML实际上是相同的,只有它们的节点中的属性是故障的,这就是为什么Winmerge将其标记为与众不同的
XSL将如何使所有内容保持相同,并且只能订购属性。在每个节点中?
目前,我在Internet上找到了此代码,但是它订购了整个文档,我需要它与IT完全相同,并且仅按字母顺序订购属性
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xsl:output omit-xml-declaration="yes" indent="yes"/>
<xsl:strip-space elements="*"/>
<xsl:template match="node()|@*">
<xsl:copy>
<xsl:apply-templates select="@*">
<xsl:sort select="name()" />
</xsl:apply-templates>
<xsl:apply-templates select="node()">
<xsl:sort select="name()" />
</xsl:apply-templates>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>
<variable name="Invoke_Event_PCM_OP_AR_EVENT_ADJUSTMENT_OutputVariable" messageType="brm:PCM_OP_AR_EVENT_ADJUSTMENT_outmsg" xml:id="id_20" />
<variable messageType="brm:PCM_OP_AR_EVENT_ADJUSTMENT_outmsg" name="Invoke_Event_PCM_OP_AR_EVENT_ADJUSTMENT_OutputVariable" xml:id="id_20" />
节点称为相同,只有它们具有不同顺序的属性,
我只想按字母顺序排序属性,以便Winmerge检测线是否相等
I don't know much about xsl.
I have to compare 2 very large xmls which are practically the same, only that the attributes in their nodes are out of order and that is why the winmerge marks it as different
How would an xsl be that leaves everything the same and only orders the attributes in each node?
Currently I found this code on the internet, but it orders the entire document and I need it to be exactly the same as it is and only order the attributes alphabetically
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xsl:output omit-xml-declaration="yes" indent="yes"/>
<xsl:strip-space elements="*"/>
<xsl:template match="node()|@*">
<xsl:copy>
<xsl:apply-templates select="@*">
<xsl:sort select="name()" />
</xsl:apply-templates>
<xsl:apply-templates select="node()">
<xsl:sort select="name()" />
</xsl:apply-templates>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>
<variable name="Invoke_Event_PCM_OP_AR_EVENT_ADJUSTMENT_OutputVariable" messageType="brm:PCM_OP_AR_EVENT_ADJUSTMENT_outmsg" xml:id="id_20" />
<variable messageType="brm:PCM_OP_AR_EVENT_ADJUSTMENT_outmsg" name="Invoke_Event_PCM_OP_AR_EVENT_ADJUSTMENT_OutputVariable" xml:id="id_20" />
For example, in the image winmerge detects differences, but the node is called the same, only that they have the attributes in a different order
I want to order only the attributes in alphabetical order so that winmerge detects that the lines are equal
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论