哪个 JAXB 实现实现了 Marshaller.getNode()?
我正在尝试添加评论< /a> 到 JAXB 生成的 XML @GET 结果,这似乎不是一个直接的任务。我正在使用 Spring,并且 我无法直接访问编组和DOM。
通过添加 public void beforeMarshal(Marshaller m) 到我的 @XmlElement,我应该能够使用 Marshaller#getNode(Object),从而能够添加注释。
问题是 AbstractMarshallerImpl#getNode(Object):
默认情况下,getNode方法是 不受支持并抛出一个 java.lang.UnsupportedOperationException。 选择支持的实现 该方法必须重写该方法。
getNode(Object) 是否由任何 JAXB 实现实现?
I am trying to add a comment to a JAXB generated XML @GET result, which doesn't seem to be a straight forward task. I'm using Spring, and I don't have direct access to the marshalling and DOM.
By adding public void beforeMarshal(Marshaller m) to my @XmlElement, I should be able to access the DOM with Marshaller#getNode(Object), and thus be able to add a comment.
The problem is AbstractMarshallerImpl#getNode(Object):
By default, the getNode method is
unsupported and throw an
java.lang.UnsupportedOperationException.
Implementations that choose to support
this method must override this method.
Is getNode(Object) implemented by any JAXB implementations out there?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
注意: 我领导 EclipseLink JAXB (MOXy) 并且是JAXB 2 (JSR-222) 专家组成员。
MOXy 目前不支持可选的
getNode
方法参见(增强请求https:// bugs.eclipse.org/332762)。但是,JAXB 的Binder
可能对以下用例有所帮助:演示
客户
电话号码
Note: I lead EclipseLink JAXB (MOXy) and am a member of the JAXB 2 (JSR-222) expert group.
MOXy does not currently support the optional
getNode
method see (enhancement request https://bugs.eclipse.org/332762). However, JAXB'sBinder
may be helpful with this use case:Demo
Customer
PhoneNumber