marshaller忽略了JAXB XmlSchema.xmlns(在package-info.java中) [英] JAXB XmlSchema.xmlns (in package-info.java) ignored by marshaller

查看:262
本文介绍了marshaller忽略了JAXB XmlSchema.xmlns(在package-info.java中)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要生成一个XML文档,其开头如下:

I need to generate an XML document that starts like:

< Document xmlns =urn:iso:std:iso:20022 :tech:xsd:pain.008.001.02xmlns:xsi =http://www.w3.org/2001/XMLSchema-instance>

因此我修改了package-info.java如下:

As such I have modified the package-info.java to be as followed:

@javax.xml.bind.annotation.XmlSchema( namespace = "urn:iso:std:iso:20022:tech:xsd:pain.008.001.02"
                                , xmlns = { @javax.xml.bind.annotation.XmlNs( prefix="xsi"
                                                                            , namespaceURI="http://www.w3.org/2001/XMLSchema-instance")
                                          }
                                , elementFormDefault = javax.xml.bind.annotation.XmlNsForm.QUALIFIED
                                )
package mypackage;

但输出为:

<Document xmlns="urn:iso:std:iso:20022:tech:xsd:pain.008.001.02">

我不知道从哪里开始看,因为我找到的所有东西都说完了什么我正在做...

I'm not sure where to start looking as everything that everything that I find says to do exactly what I am doing...

更新:
我通过使用MOXy作为JAXB实现来解决这个问题;代码还可以,我正在使用的实现似乎有问题:\

UPDATE: I solved this by using MOXy as the JAXB implementation; code was OK, seems to be a problem with the implementation I was using :\

推荐答案

我有以下示例并且有效正确。
如果您有任何疑问,请尝试帮助。

I have the example below and works correctly. Try and if you have any question, Ill try to help.

elementFormDefault = javax.xml.bind.annotation.XmlNsForm.QUALIFIED, xmlns = {
    @XmlNs(prefix = "xsi", namespaceURI = "http://www.w3.org/2001/XMLSchema-instance")
})

问候

这篇关于marshaller忽略了JAXB XmlSchema.xmlns(在package-info.java中)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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