【发布时间】:2017-05-07 23:00:05
【问题描述】:
这是一个与此类似的问题:xmlbeans - set content of a complex type,但不完全相同。我要做的是在 atom 提要中设置 contentEntry 的内容。
这里是 contentType 的 atom xsd 定义,即在 atom 提要中条目的内容标签。
<xs:complexType name="contentType" mixed="true">
<xs:annotation>
<xs:documentation>
The Atom content construct is defined in section 4.1.3 of the format spec.
</xs:documentation>
</xs:annotation>
<xs:sequence>
<xs:any namespace="##other" minOccurs="0" maxOccurs="unbounded" />
</xs:sequence>
<xs:attribute name="type" type="xs:string"/>
<xs:attribute name="src" type="xs:anyURI"/>
<xs:attributeGroup ref="atom:commonAttributes"/>
</xs:complexType>
通过 xmlbean'scomp 编译后,我得到了一个不错的 jar 文件,它使我能够执行以下操作。
EntryType curEntry;
curEntry = atomFeed.addNewEntry();
ContentType curContent = curEntry.addNewContent();
curContent.setBase("base");
curContent.setLang("en-EN");
curContent.setSrc("none");
curContent.setType("none");
这是输出为
<content xml:base="base" xml:lang="en-EN" src="none" type="none"/>
我真的不想与 atom 的官方(我能找到的官方)xsd 混淆,但我缺少一种能够设置 curContent 的实际文本表示的方法。只有其他的 set 函数是 set(XmlObject object) 和 setNil()。
我怎样才能改变它以便我可以得到:
<content xml:base="base" xml:lang="en-EN" src="none" type="none">Content of this entry</content>
谢谢
【问题讨论】:
标签: java xsd atom-feed xmlbeans