如何更改Castor映射以从XML输出中的元素中删除“xmlns:xsi”和“xsi:type”属性?
如何更改Castor映射
抑制XML输出元素中的xmlns:xsi
和xsi:type
属性? 例如,而不是输出XML
Tester 1 2 US
我更喜欢
Tester 1 2 US
这样元素名称暗示xsi:type
。
将Castor Marshaller属性suppressXSIType
为false:
Marshaller marshaller = new Marshaller(w); marshaller.setSuppressXSIType(true);
请参阅Castor 1.3.1参考文档中的配置Marshaller 。 (请注意, 表1.10 Marshaller属性仅列出属性suppressNamespaces
,但方法setSuppressNamespaces()
和setSuppressXSIType()
都存在于Marshaller
类中。)