`
adapterofcoms
  • 浏览: 72414 次
  • 性别: Icon_minigender_1
  • 来自: 苏州
社区版块
存档分类
最新评论

JAXB JAXP Miscellaneous

阅读更多


schemegen
xjc
C:\jdk1.8.0_25\bin\java -Dfile.encoding=UTF-8 -cp C:\jdk1.8.0_25\lib\tools.jar com.sun.tools.internal.xjc.Driver -d . -p com.*.smodel *.xsd


C:\jdk1.8.0_25\bin\xjc -encoding UTF-8 -d . -p com.*.smodel *.xsd



marshaller.setProperty(Marshaller.JAXB_ENCODING, "UTF-8");// //编码格式
marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);// 是否格式化生成的xml串 ,这是不可靠的!!!
marshaller.setProperty(Marshaller.JAXB_FRAGMENT, false);// 是否省略xm头声明信息

http://blog.sina.com.cn/s/blog_6fda308501013w2a.html
http://iteye.blog.163.com/blog/static/186308096201211137371297/
http://dacoolbaby.iteye.com/blog/1667283

JAXBContext:
To avoid the overhead involved in creating a JAXBContext instance, a JAXB
application is encouraged to reuse a JAXBContext instance. An implementation
of abstract class JAXBContext is required to be thread-safe, thus, multiple
threads in an application can share the same JAXBContext instance.

contextPath:  packages "com.acme.foo:com.acme.bar"  all exists the ObjectFactory ?
classes: [...]

A package consists of:
...
A public class ObjectFactory
...

@XmlRootElement

@XmlElement
@XmlAttribute


List<JAXBElement<T>> getContent()

@XmlAnyElement(lax = true)
List<java.lang.Object> any;   how?
1.ObjectFactory +:
@XmlElementDecl(name="entity",namespace="", scope = Entity.class)
public JAXBElement<Entity> createEntity(Entity e)
OR
public Entity createEntity() {return new Entity();}
2.Entity +: @XmlRootElement
http://www.myexception.cn/xml-soap/1780642.html


formatted via JAXP Transformer, DONT depends on the JAXB_FORMATTED_OUTPUT.

@XmlElement(required = true, type=X.class)   marshalling dont generate the Attributes [xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xs="http://www.w3.org/2001/XMLSchema" xsi:type="xs:X.class.Name"]
java.lang.Object member;

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics