我使用的是Java6、Eclipse2和SpringSource工具套件(和JaxB一样)。我编写了几个Java类,在这些类中我使用JaxB生成了一个XML schema。但是,我注意到,为了使用JaxB从Java对象生成XML文档的能力,我需要一个ObjectFactory。
final Marshaller marshaller = jaxbContext.createMarshaller();
// Here is where I don't have an ObjectFactory defined
final JAXBElement<WebLeads> webLe
我在将xjb继承绑定应用于simpleType时遇到了一些问题。将其应用于complexType似乎很好。
我得到的错误是:
compiler was unable to honor this implements customization. It is attached to a wrong place, or its inconsistent with other bindings.
我的绑定看起来是这样的:
<jaxb:bindings version="1.0"
xmlns:jaxb="http://java.sun.com/xm
假设我有以下两个类,我希望使用jaxb来执行
@XmlRootElement(name = "VirtualizationData")
public class VirtualizationData
{
@XmlElement(name = "VirtualOrganization")
public List<VirtualOrganization> Organizations = new ArrayList<VirtualOrganization>();
}
和
public class VirtualOrganizat
我在解压缩一些XML时遇到了问题。部分堆栈转储如下所示:
javax.xml.bind.UnmarshalException: unexpected element (uri:"", local:"properties"). Expected elements are (none)
at com.sun.xml.internal.bind.v2.runtime.unmarshaller.UnmarshallingContext.handleEvent(UnmarshallingContext.java:726)
at com.sun.xml.in
当调用类AdapterDataObj时,我使用类DataObj将类DataObj转换为AdaptedDataObj。
package test;
import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
@XmlJavaTypeAdapter(AdapterDataObj.class)
public class DataObj {
public String bla = "I'm DataObj";
public String name;
public DataObj(St
我正在使用来理解JAXB。
当编写器创建文档的根目录时,编写器开始如下所示:
//This statement means that class "Bookstore.java" is the root-element of our example
@XmlRootElement(namespace = "de.vogella.xml.jaxb.model")
public class Bookstore {
...
}
尽管我将手动生成我的类,而不是让Eclipse来生成,但是我将为我的jar文件(不是打包在里面,而是放在包含jar文件的文件
我有在JBoss7.1下运行的REST (Resteasy)客户机。从服务器返回的响应要求我使用自己的JAXB ObjectFactory,因为相同的JAXB类型被映射到多个XML元素:
@XmlRegistry
public class ObjectFactory {
private final static QName RESPONSE_QNAME = new QName("response");
private final static QName ORDER_QNAME = new QName("order");
@XmlEl
我有以下bean类
@XmlRootElement(name = "book")
//Optional
@XmlType(propOrder = {"name" })
public class Book {
private String name;
private int num;
@XmlTransient
public int getNum() {
return num;
}
public void setNum(int num) {
this.num = num;
}
// name for your XML-Output:
@Xm