这是一个与此类似的问题: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>
谢谢