aboutsummaryrefslogtreecommitdiffstats
path: root/src/documentation/content/xdocs/dev/extensions.xml
blob: 0226ae564ef46baf46ec10c121a95dd7c243c82e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
<?xml version="1.0" encoding="UTF-8"?>
<!--
  Copyright 1999-2005 The Apache Software Foundation

  Licensed under the Apache License, Version 2.0 (the "License");
  you may not use this file except in compliance with the License.
  You may obtain a copy of the License at

       http://www.apache.org/licenses/LICENSE-2.0

  Unless required by applicable law or agreed to in writing, software
  distributed under the License is distributed on an "AS IS" BASIS,
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  See the License for the specific language governing permissions and
  limitations under the License.
-->
<!-- $Id$ -->
<!DOCTYPE document PUBLIC "-//APACHE//DTD Documentation V1.1//EN"
    "http://cvs.apache.org/viewcvs.cgi/*checkout*/xml-forrest/src/core/context/resources/schema/dtd/document-v12.dtd">

<document>
  <header>
    <title>FOP Development: Adding an Extension</title>
    <version>$Revision$</version>
  </header>
  <body>
    <section id="overview">
      <title>Overview</title>
      <p>For documentation of standard FOP extensions, see the <link href="../trunk/extensions.html">User FOP Extensions</link> document.</p>
      <p>
If the default funtionality of FOP needs to be extended for
some reason then you can write an extension.
            </p>
            <p>There are three types of extensions possible:</p>
            <ul>
              <li>An output document extension such as the PDF bookmarks</li>
              <li>an instream-foreign-object extensions such as SVG</li>
              <li>an fo extension that creates an area in the area tree where normal xsl:fo is not possible</li>
            </ul>
          </section>
          <section id="adding">
            <title>Adding Your Own</title>
            <p>
To add your own extension you need to do the following things.
</p>
        <ol>
          <li>Write code that implements your extension functionality. The easiest place to
start is by looking at the code in org.apache.fop.extension, and by looking at the examples in the <code>examples</code> directory.</li>
          <li>Create a class that implements the org.apache.fop.fo.ElementMapping interface. ElementMapping is a hashmap of all of the elements in a particular namespace, which makes it easier for FOP to create a different object for each element.
ElementMapping objects are static to save on memory.
They are loaded by FOP when parsing starts to validate input.</li>
          <li>Create the following file: "/META-INF/services/org.apache.fop.fo.ElementMapping", which should contain the fully qualified classname of your ElementMapping implementation class.</li>
          <li>Create a jar file containing all of the above files.</li>
          <li>Create your XSL-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.
The pdf documents on the FOP site use this extension.
See also <link href="../examples.html">Examples</link> for more examples.</li>
          <li>Put your jar file in the classpath</li>
          <li>Run FOP using your XSL-FO file as input.</li> 
        </ol>
    </section>
  </body>
</document>