Search code examples
javaxmljaxbapache-fop

JAXB generated TableCell class from FOP schema - no way to add Block


I have used XJC to convert the unofficial FOP schema to Java objects

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

When writing an XML document that adheres to the schema, I can add an <fo:block/> element inside an <fo:table-cell/> element; but I can't see any way to add a Block to a TableCell programmatically using the generated TableCell class. Am I missing the method that achieves this?

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


Solution

  • Check the markerOrBlockOrBlockContainer property.

    @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;
    

    Would be probably:

    myTableCell.getMarkerOrBlockOrBlockContainer().add(myBlock);
    

    You get this "heterogeneous" property because of the repeatable choice construct:

      <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>