As we have seen, an object of the class JAXBContext must be constructed as a starting point for other operations. One way is to create a context from a colon separated list of packages.

JAXBContext ctxt = JAXBContext.newInstance( "some foo:more.bar" );

Each package must contain its own class ObjectFactory or a file named jaxb.index. An ObjectFactory class is generated by the XML schema compiler, and therefore this form of newInstance is usually used in connection with schema derived classes. For JAXB annotated Java code, you may use the package path form as well, either with a hand-written ObjectFactory class or with a jaxb.index resource file containing a list of the class names to be considered by JAXB. This file simply lists the class names relative to the package where it occurs, e.g.:

# package some.foo
# class some.foo.Foo
Foo
# inner class some.foo.Foo.Boo
Foo.Boo

An alternative form of the newInstance method lists all classes that the new context should recognize.

JAXBContext ctxt = JAXBContext.newInstance( Foo.class, Bar.class );

Usually, the top level classes are sufficient since JAXB will follow, recursively, all static references, such as the types of instance variables. Subclasses, however, are not included.

If packages or classes are associated with namespaces, the packages or classes associated with a JAXB context also determine the namespace declarations written as attributes into the top-level element of the generated XML document.

JAXB - The JAXB Context的更多相关文章

  1. JAXB注解【转】

    http://blog.csdn.net/lw371496536/article/details/6942045 JAXB(Java API for XML Binding),提供了一个快速便捷的方式 ...

  2. JAXB 注解

    JAXB(Java API for XML Binding),它提供了一个便捷的方式高速Java对象XML转变.于JAX-WS(Java的WebService规范之中的一个)中,JDK1.6 自带的版 ...

  3. 在Gradle中使用jaxb的xjc插件

    jaxb,全称为Java Architecture for Xml Binding,是一种将java对象与xml建立起映射的技术.其主要提供两个功能,一是将java对象映射为xml,二是将xml映射为 ...

  4. Java for XML: JAXP、JAXB、JAXM、JAX-RPC、JAX-WS

    在XML领域里,对XML文件的校验有两种方式:DTD校验.Schema校验.在Java中,对于XML的解析,有多种方式:DOM解析.SAX解析.StAX解析.结合XML和Java后,就产生了Bind技 ...

  5. Jaxb笔记

    摘自: http://www.blogjava.net/eagle-daiq/archive/2012/01/30/369016.html 最近项目原因,研究了下jaxb.jaxb是Java api ...

  6. java JAXB + STAX(是一种针对XML的流式拉分析API)读取xml

    JDK1.5需要添加jar包,1.6以后就不需要了<dependency> <groupId>stax</groupId> <artifactId>st ...

  7. JAXB简单样例

    参考网页:http://www.mkyong.com/java/jaxb-hello-world-example/JAXB完整教程:https://jaxb.java.net/tutorial/1.J ...

  8. java对象与XML相互转化

    起因 最近在公司做了一次webservice相关的任务,其中我最敢兴趣的就是webservice接受到XML对应的流以后是如何方便的转化成java对象,而java对象又是如何生成对应的XML的. 目的 ...

  9. Jersey(1.19.1) - XML Support

    As you probably already know, Jersey uses MessageBodyWriters and MessageBodyReaders to parse incomin ...

随机推荐

  1. pip 安装python环境及打包

    0.安装虚拟环境 pip install virtualenv   virtualenv env1   source env1/bin/activate   1. 将包依赖信息保存在requireme ...

  2. [转载]C++命名规则

    在软件开发这一高度抽象而且十分复杂的活动中,命名规则的重要性更显得尤为突出.一套定义良好并且完整的.在整个项目中统一使用的命名规范将大大提升源代码的可读性和软件的可维护性. 在引入细节之前,先说明一下 ...

  3. Java中使用ThreadPoolExecutor并行执行独立的单线程任务

    Java SE 5.0中引入了任务执行框架,这是简化多线程程序设计开发的一大进步.使用这个框架可以方便地管理任务:管理任务的生命周期以及执行策略. 在这篇文章中,我们通过一个简单的例子来展现这个框架所 ...

  4. Property cannot be found on forward class object?

    I have a UIView and I'm trying to set its layer properties. self.colorSwatch = [[UIView alloc] initW ...

  5. js调试工具Console命令详解

    这篇文章主要介绍了js调试工具Console命令详解,需要的朋友可以参考下   一.显示信息的命令 复制代码 代码如下: < !DOCTYPE html> < html> &l ...

  6. hdu 4607 (树形DP)

    当时比赛的时候我们找出来只要求出树的最长的边的节点数ans,如果要访问点的个数n小于ans距离直接就是n-1 如果大于的话就是(n-ans)*2+ans-1,当时求树的直径难倒我们了,都不会树形dp ...

  7. js避免全局污染

    避免声明全局变量,以免发生冲突

  8. onethink 系统函数中 生成随机加密key

    <?php /** * 生成系统AUTH_KEY */ function build_auth_key(){ $chars = 'abcdefghijklmnopqrstuvwxyz012345 ...

  9. javaScript 要点(十五)HTML DOM 导航

    通过 HTML DOM,能够使用节点关系在节点树中导航. 1.HTML DOM 节点列表 getElementsByTagName() 方法返回节点列表.节点列表是一个节点数组. 下面的代码选取文档中 ...

  10. CocoaPods容易出现的问题;

    一.初次安装cocoapods打开项目遇:Pods-resources.sh: Permission denied报错. 此类报错是指编译器在打开Pods-resources.sh文件的时候遭遇权限问 ...