To add your own extension you need to do the following things.
Write code that implements your extension functionality.
The easiest place to start is by looking at the code in org.apache.fop.extension.
Create a jar file with your classes, it must also include the following file "/META-INF/services/org.apache.fop.fo.ElementMapping". In this file you need to put the fully qualified classname of your element mappings class. This class must implement the "org.apache.fop.fo.ElementMapping" interface.
Create your fo file with the extra xml data embedded in the file with the correct name space. The examples for svg and pdfoutline.fo show how this can be done.
Put your jar file in the classpath and then run fop over the fo file.