@Retention(value=RUNTIME) @Target(value={FIELD,METHOD}) public @interface XmlMixed
建立一个多值属性的JavaBean支持混合内容。
使用是受以下约束:
以下可以插入“xmlmixed注释的多值属性
JAXBElement
或实例的实例。Element
。(假定属性标注@ XmlAnyElement)<!混合内容的模式片段>< xs:complexType名称=“letterbody混合=“真实”>< xs:序列>< xs:元名称=“名”type=“XS:字符串”/>< xs:元名称=“量”type=“XS:正整数”/>< xs:元名称=“ProductName”type=“XS:字符串”/><!等- >< / xs:序列>< / xs:名称>< xs:元名称=“letterbody”type=“letterbody”/>/ /模式衍生的java代码:/ /只有有关混合内容的注释如下所示,/ /其他被省略。)进口java.math.biginteger;公共类化{/元素实例工厂jaxbelement < letterbody > createletterbody(letterbody值);jaxbelement <字符串> createletterbodyname(字符串值);jaxbelement < > createletterbodyquantity BigInteger(BigInteger值);jaxbelement <字符串> createletterbodyproductname(字符串值);/ /型号实例工厂letterbody > createletterbody();} 字符串> 字符串>
公共课letterbody {/混合内容可以包含元素类的实例/ /名称、数量和产品名称。文本数据表示为/ / java.util.string文本。@ XmlMixed“xmlelementrefs({@ XmlElementRef(name=“产品名称”,类型为jaxbelement。类),@ XmlElementRef(name=“量”,类型为jaxbelement。类),@ XmlElementRef(name=“名”,类型为jaxbelement。类)})表getcontent() {…}}以下XML实例文档
letterbody > <亲爱的先生,<名称> 罗伯特·史密斯 <名称> 您的订单数量> 1 < < > < >宝贝名称/数量监控/产品名称> <从我们的仓库发货。的…< letterbody>从我们的仓库发货。的…<> 名称> 亲爱的先生,<名称>混合内容,可以使用下面的JAXB API调用。
letterbody LB = createletterbody()化;jaxbelement < letterbody > LBE =化createletterbody(LB);表协鑫=磅getcontent();/ /添加混合内容一般内容属性。GCL。添加(“亲爱的先生”);/ /添加文本信息项作为字符串。/添加子元素信息项GCL。添加(化。createletterbodyname(“罗伯特·史密斯”));GCL。添加(“订单”);/ /添加文本信息项作为字符串/添加儿童元素信息项GCL添加(化。createletterbodyquantity(新BigInteger(“1”)));GCL。添加(化。createletterbodyproductname(“婴儿监视器”));GCL。添加(“运到我们的仓库”);/ /添加文本信息项目
看到“包装规范”的额外的信息共享javax.xml.bind.package javadoc。
Submit a bug or feature
For further API reference and developer documentation, see Java SE Documentation. That documentation contains more detailed, developer-targeted descriptions, with conceptual overviews, definitions of terms, workarounds, and working code examples.
Copyright © 1993, 2014, Oracle and/or its affiliates. All rights reserved.