How to Use Extensions for Text Output?

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

How to Use Extensions for Text Output?

CoryO
This post has NOT been accepted by the mailing list yet.
I'm having difficulties understanding how to implement Apache FOP extensions. Right now I'm just trying to get FOP to replace my custom element with the character "0". All of the samples appear to be for inserting images.

I even tried re-implementing the "fo:page-number" element (below). It seems to do all of the same validation and runs the various methods, but it does not cause the page number to output.

Are the custom extensions not meant for text insertion or filtering?

By the way, I'm only looking into this as a possibility to allow me to format page numbering with and without a leading zero on the same page. The "format" attribute is only accepted on "fo:page-sequence" and not "fo:page-number".

public class TestElementMapping extends ElementMapping {
    public static final String URI = "http://www.test.com/fop";
    public static final String STANDARD_PREFIX = "tst";
    public TestElementMapping() {
        namespaceURI = URI;
    }
    @Override
    protected void initialize() {
        if (foObjs == null) {
            foObjs = new HashMap<String, Maker>();
            foObjs.put("page-number", new PageNumberMaker());
        }
    }
    static class PageNumberMaker extends ElementMapping.Maker {
        public FONode make(FONode parent) {
            return new org.apache.fop.fo.flow.PageNumber(parent) {
                @Override
                public String getNamespaceURI() {
                    return URI;
                }
                @Override
                public String getNormalNamespacePrefix() {
                    return STANDARD_PREFIX;
                }
            };
        }
    }
}