JAXB编译器和属性顺序 [英] JAXB Compiler and Attribute Order

查看:153
本文介绍了JAXB编译器和属性顺序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想控制JAXB编译器生成的.java文件中的属性顺序。

I would like to control the attribute order in .java files generated by the JAXB compiler.

我知道属性顺序对于xml验证并不重要。该顺序对于在回归测试环境中对编组的xml进行文本比较非常重要。文件中的属性顺序直接影响编组的xml标记中的属性顺序。

I'm aware that attribute order is not important for xml validation. The order is important for textual comparison of marshalled xml in a regression test environment. The order of attributes in a file directly affects the order of the attributes in marshalled xml tags.

每次运行JAXB编译器时,属性组以不同的顺序出现,甚至没有更改架构。编译器上没有明显的选项可以防止这种行为。

Every time the JAXB compiler is run attribute groups appear in a different order, even with no changes to the schema. There is no apparent option available on the compiler to prevent this behavior.

我想避免运行后编译脚本按生成的.java文件按字母顺序重新排序属性因为这会分解属性组,但我不确定还有其他选项。

I would like to avoid running a post-compilation script to alphabetically reorder attributes in the generated .java files since this breaks up the attribute groups, but I'm not sure there is another option.

非常感谢任何建议。

谢谢,
Dave

Thanks, Dave

推荐答案

这个帖子为我的问题提供了很好的解决方案。

This thread provides a great solution to my problem.

使用XSL对属性进行排序

其中一个答案包含一个只重新排序属性的xsl变换。如果有点慢,可以很好地工作。

One of the answers contains a xsl transform that just reorders the attributes. Works perfectly if a little slow.

这篇关于JAXB编译器和属性顺序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆