<link rel="stylesheet" type="text/css" href="http://maomaode.bokeland.com/plugins/plogeshi/styles/plogeshi.css">假设我们有这样的Schema:
<complexType name="Meta">
<sequence>
<element name="name" type="string"/"">
<element name="description" type="string"/"">
</sequence>
</complexType>
<complexType name="Store">
<complexContent>
<extension base="Meta">
<sequence>
<element name="books" type="Book" maxoccurs="unbounded"/"">
</sequence>
</extension>
</complexContent>
</complexType>
<element name="store" type="Store"/"">
<element name="meta" type="Meta"/"">
注意到Store 继承了Meta, 如果我们有一个Store的对象,但是我们只想Marshal出继承Meta部分的内容,即希望得到下面这样XML
<meta>
<name>my book store </name>
<description> abc </description>
</meta>
应该怎么写呢?答案其实就在于你怎么构建JAXBContext
JAXBElement jaxbElement =
(JAXBElement)m.invoke(objFactory.newInstance(), store);
JAXBContext jc = JAXBContext.newInstance(Meta.class);
Marshaller marshaller = jc.createMarshaller();
marshaller.marshal(jaxbElement, os);
分享到:
相关推荐
无需安装,解压后即可。jaxb-api.jar,jaxb-xjc.jar,jaxb-impl.jar,activation.jar等相关jar包在lib文件夹下。
JAXB的使用JAXB的使用JAXB的使用JAXB的使用
在使用webservice,mule esb等需要jaxb的项目里经常会出现 JAXB 2.0 API is being loaded from the bootstrap classloader这个错误,按照打出的信息Use the endorsed directory mechanism to place jaxb-api.jar in ...
jaxb 将xml里面的对象转化为一个个类,大大地简化了xml的相关操作。unmarshal marshal
JAXB的安装包及插件
jaxb-api jaxb-impl jar
有关Maven项目中缺少jaxb-api的异常报错解决,jaxb-api-2.3.0.jar
1. 什么是JAXB? Java Architecture for XML Binding (JAXB) 是一个业界的标准,是一项可以根据XML
赠送jar包:jackson-module-jaxb-annotations-2.2.3.jar; 赠送原API文档:jackson-module-jaxb-annotations-2.2.3-javadoc.jar; 赠送源代码:jackson-module-jaxb-annotations-2.2.3-sources.jar; 赠送Maven依赖...
java -jar JAXB2_20060607.jar On Windows, you can just double-click the jar file to execute. Release Notes Browse the release notes online, including what's new. Technical Support Please subscribe to...
JAXB的 eclipse插件 JAXB的 eclipse插件 JAXB的 eclipse插件 JAXB的 eclipse插件 JAXB的 eclipse插件
赠送jar包:jackson-module-jaxb-annotations-2.7.8.jar; 赠送原API文档:jackson-module-jaxb-annotations-2.7.8-javadoc.jar; 赠送源代码:jackson-module-jaxb-annotations-2.7.8-sources.jar; 赠送Maven依赖...
jaxb-api jaxb-impl jaxb-xjc jaxws-rt 这四个文件对应的jar包
现在很多maven仓库均没有此jar jaxb-api-2.3.0.jar jaxb-core-2.3.0.jar
Jaxb annotation 使用 Jaxb annotation初步使用
使用jaxb生成XML例子,含有例子和注解解析
JAXB注解相关技术JAXB注解相关技术JAXB注解相关技术JAXB注解相关技术JAXB注解相关技术JAXB注解相关技术
有关Maven项目中缺少jaxb-api的异常报错解决,jaxb-core-2.3.0.jar
我刚写好的 一个简单的小程序 动行里面的read文件 是在idea 中用jaxb 读xml中数据
一个JAXB2的基础教程,教你快速运用JAXB通过XSD绑定XML和读写XML