<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE xml>
<Settings version="3" xmlns="urn:Adapter-v3">
<Connections>
<Connection name ="A" description="DEV">
<SaveVersion version="M" siteURL="https://example.com" />
<Save>
<Id>id123</Id>
<Client>hello</Client>
</Save>
</Connection>
<Connection name ="B" description="DEV1">
<SaveVersion version="M" siteURL="https://example.com" />
<Auth>
<UserId>id123</UserId>
<Password>pass</Password>
</Auth>
</Connection>
</Connections>
<Mappings>
<Mapping cont="AA" auction="A1">
<Description>Desc</Description>
<Content
attr1="IO"
attr2="d"
attr3="Information"
attr4="false"
<Element enabled="false" count="200" prefix="DocLib_" itemPrefix="0" />
<Sub enabled="false" count="100" prefix="Folder_" itemPrefix="0" />
<FilenameA auction="N" delay="3" />
</Content>
</Mapping>
<Mapping cont="AB" auction="SharePointOLDev1">
<Description>Desc</Description>
<Content
attr1="IO"
attr2="d"
attr3="Information"
attr4="false"
<Element enabled="false" count="200" prefix="DocLib_" itemPrefix="0" />
<Sub enabled="false" count="100" prefix="1" itemPrefix="0" />
</Content>
</Mapping>
</Mappings>
<TypeMappings>
<TypeMapping Type="rfid" ext="msg" />
</TypeMappings>
</Settings>
尝试将上述xml文件解组为java对象。 使用xjc工具生成Settings.java和ObjectFactory.java文件。这些文件部署在src文件夹中(以及其他java文件。) 当我解组时,我得到Connections,Mappings和TypeMappings的空值。 有没有我缺少的步骤?
public class JAXBImpl{
public static void main(String args[]){
JAXBContext jaxbContext;
Settings que= null;
jaxbContext = JAXBContext.newInstance(Settings.class);
Unmarshaller jaxbUnmarshaller = jaxbContext.createUnmarshaller();
que= (Settings) jaxbUnmarshaller.unmarshal(file);
System.out.println(que.getConnections().getConnection());
}
}