java 6 jaxb,Java 6中的JAXB在编组的XML文件中未为正确的名称空间前缀加上前缀

I have a schema with following attributes in schema element:

I could compile it and get java classes. Using these classes, I filled in data in an object and marshalled it to get an XML file.

But the XML elements in this marshalled file is not having the prefix "abc".

I tweaked a little using XMLStreamWriter.setPrefix while marshalling, and I could get the XML file with all elements prefixed as "abc".

Now when I try to unmarshall the same XML file, it throws error saying :

[org.xml.sax.SAXParseException: The prefix "abc" for element "abc:Name" is not bound.]

Please help me in how to let JAXB know that abc is correct prefix.

Thank You

Pradeep

解决方案

The name of the prefix is meaningless. All it does is make a connection between a namespace and the tags that belong to that namespace. Whether the prefix is abc or namespace01 or there is no prefix because the default namespace is used doesn't matter. As far as I know you can't force the usage of a prefix or the specific name of a prefix in JAXB.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值