JAXB从FOP模式生成了TableCell类 - 无法添加Block

时间:2014-10-26 22:07:40

标签: java xml jaxb apache-fop

我使用XJC将非官方FOP架构转换为Java对象

http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/foschema/fop.xsd?view=co

在编写符合架构的XML文档时,我可以在<fo:block/>元素中添加<fo:table-cell/>元素;但我无法使用生成的TableCell类以编程方式向TableCell添加块。我错过了实现这一目标的方法吗?

http://pastebin.com/raw.php?i=Xs6gjE3T

1 个答案:

答案 0 :(得分:0)

检查markerOrBlockOrBlockContainer属性。

@XmlElements({
    @XmlElement(name = "block-container", required = true, type = BlockContainer.class),
    @XmlElement(name = "retrieve-marker", required = true, type = RetrieveMarker.class),
    @XmlElement(name = "list-block", required = true, type = ListBlock.class),
    @XmlElement(name = "table", required = true, type = Table.class),
    @XmlElement(name = "float", required = true, type = Float.class),
    @XmlElement(name = "multi-properties", required = true, type = MultiProperties.class),
    @XmlElement(name = "table-and-caption", required = true, type = TableAndCaption.class),
    @XmlElement(name = "footnote", required = true, type = Footnote.class),
    @XmlElement(name = "marker", required = true, type = Marker.class),
    @XmlElement(name = "multi-switch", required = true, type = MultiSwitch.class),
    @XmlElement(name = "block", required = true, type = Block.class),
    @XmlElement(name = "wrapper", required = true, type = Wrapper.class)
})
protected List<Object> markerOrBlockOrBlockContainer;

可能会:

myTableCell.getMarkerOrBlockOrBlockContainer().add(myBlock);

你得到了这个&#34;异构&#34;属性,因为可重复的choice构造:

  <choice maxOccurs = "unbounded">
    <group ref = "fo:marker_List"/>
    <group ref = "fo:block_List"/>
    <group ref = "fo:neutral_List"/>
    <group ref = "fo:float_List"/>
    <group ref = "fo:footnote_List"/>
  </choice>