From 418e78be92bc86ec3582cbd2e8f79c72a9ffa101 Mon Sep 17 00:00:00 2001 From: William Victor Mote Date: Thu, 24 Apr 2003 19:35:17 +0000 Subject: [PATCH] Move some content from fotree.xml to other documents. Reorganize content of fotree.xml. git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@196341 13f79535-47bb-0310-9956-ffa450edef68 --- .../content/xdocs/design/fotree.xml | 181 ++++++++---------- .../content/xdocs/design/layout.xml | 1 + .../content/xdocs/design/parsing.xml | 23 +-- .../content/xdocs/design/properties.xml | 32 ++++ 4 files changed, 115 insertions(+), 122 deletions(-) diff --git a/src/documentation/content/xdocs/design/fotree.xml b/src/documentation/content/xdocs/design/fotree.xml index 1c2456606..f91c6117f 100644 --- a/src/documentation/content/xdocs/design/fotree.xml +++ b/src/documentation/content/xdocs/design/fotree.xml @@ -3,41 +3,75 @@ "http://cvs.apache.org/viewcvs.cgi/*checkout*/xml-forrest/src/resources/schema/dtd/document-v11.dtd">
- FO Tree - Design of FO Tree Structure + FOP Design: FO Tree
-
- Process FO Elements ASAP -

The issue here is that we wish to recycle FO Tree memory as much as possible. There are at least three possible places that FO Tree fragments can be passed to the Layout process, and their memory recycled:

-
    -
  • - fo:block It might be tempting to start laying out pages as soon as the first fo:block object is finished. However, there are many downstream things that can affect the placement of that block on a page, such as graphics and footnotes. So, in order to maintain conformance to the XSL-FO specification, and create high-quality output, we must see more of the document.
  • -
  • - fo:root The other extreme is to wait until the entire document is read in before processing any of it. This essentially means that there is no memory recycling. Processing the document correctly is more important than saving memory, so this option would be used if there were no better alternative.
  • -
  • - fo:page-sequence The page-sequence object provides a nice clean break in the document. Content from one page-sequence will never interfere with nor affect the placement of the content of another. FOP uses this option as the optimum way to maintain compliance with the standard and to minimize memory consumption.
  • -
-
-
- Serialize FO Tree as Necessary -

This issue is implied by the requirement to process documents of arbitrary size. Unless some arbitrary limit is placed on the size of page-sequence objects, FOP must be able to serialize FO tree fragments as necessary.

-
Introduction -

The FO Tree is an internal representation of the input XSL-FO document. -The tree is created by building the elements and attributes from the SAX events. -The process of building the FO Tree corresponds to the Objectify step from the spec. -The Refinement step is part of reading and using the properties which may happen immediately or during the layout process.

-

The FO Tree is used as an intermediatory structure which is converted -into the area tree. The complete FO tree should not be held in memory -since FOP should be able to handle FO documents of any size.

-

The FO Tree is simply a heirarchy of java objects that represent the fo elements from xml. -The traversal is done by the layout or structure process only in the flow elements.

+

The FO Tree is an internal hierarchical representation (java objects and properties) of the input XSL-FO document, and is created from the parsing of that XSL-FO document. +The process of building the FO Tree corresponds to the Objectify step in the XSL-FO spec. +The FO Tree is an intermediate structure which will later be converted into the area tree.

+
+
+ Processing +

The SAX Events that are fired by the parsing process are caught by the FO Tree system. +Events for starting an element, ending an element, and text data are assembled by the FO Tree system into a set of objects that represent the input FO document.

+

For attributes attached to an XSL-FO element, a property list mapping is used to convert the attribute into properties of the object related to the element.

+

Elements from foreign namespaces that are recognized by FOP fall into the following categories:

+
    +
  • Pass-thru: These are placed into a DOM object, which is then passed through FOP directly to the renderer. SVG is an example.
  • +
  • FOP Internal: These are placed into objects that can then be used by FOP. An example of this would be an element that the layout process will use to create an area. Another example would be an element that contains setup information for the renderer.
  • +
+

For unrecognized namespaces, a dummy object or a generic DOM is created.

+

While the tree building is mainly about creating the FO Tree, some FO Tree events trigger processes in other parts of FOP. +The end of a page-sequence element triggers the layout process for that page-sequence (see discussion of Recycling). +Also, the end of the XML document tells the renderer that it can finalize the output document.

+
+
+ Recycling FO Tree Memory +

To minimize the amount of memory used by FOP, we wish to recycle FO Tree memory as much as possible. +There are at least three possible places that FO Tree fragments could be passed to the Layout process, so that their memory can be reused:

+
    +
  • + fo:block It might be tempting to start laying out pages as soon as the first fo:block object is finished. However, there are many downstream things that can affect the placement of that block on a page, such as graphics and footnotes. So, in order to maintain conformance to the XSL-FO specification, and create high-quality output, we must see more of the document.
  • +
  • + fo:root The other extreme is to wait until the entire document is read in before processing any of it. This essentially means that there is no memory recycling. Processing the document correctly is more important than saving memory, so this option would be used if there were no better alternative.
  • +
  • + fo:page-sequence The page-sequence object provides a nice clean break in the document. Content from one page-sequence will never interfere with nor affect the placement of the content of another. FOP uses this option as the optimum way to maintain compliance with the standard and to minimize memory consumption.
  • +
+
+
+ FO Tree Serialization +

This issue is implied by the requirement to process documents of arbitrary size. Unless some arbitrary limit is placed on the size of page-sequence objects, FOP must be able to serialize FO tree fragments as necessary.

+
+ Notes About Specific Elements +
+ page-master +

The first elements in a document are the elements for the page master setup. +This is usually only a small number and will be used throughout the document to create new pages. +These elements are kept as a factory to create the page and appropriate regions whenever a new page is requested by the layout. +The objects in the FO Tree that represent these elements are themselves the factory. +The root element keeps these objects as a factory for the page sequences.

+
+
+ flow +

The elements that are in the flow of the document are a set of elements +that is needed for the layout process. Each element is important in the +creation of areas.

+
+
+ Other Elements +

The remaining FO Objects are things like page-sequence, title and color-profile. +These are handled by their parent element; i.e. the root looks after the declarations and the declarations maintains a list of colour profiles. +The page-sequences are direct descendents of root.

+
+
+
+ Implementation Notes
FONode

The base class for all objects in the tree is FONode. The base class for @@ -51,7 +85,8 @@ may have children.

Each xml element is represented by a java object. For pagination the classes are in org.apache.fop.fo.pagination.*, for elements in the flow they are in org.apache.fop.fo.flow.* and some others are in -org.apache.fop.fo.*.

+org.apache.fop.fo.*. +

Making FO's @@ -70,91 +105,35 @@ element name. This maker is then used to create a new class that represents an FO element. This is then added to the FO tree as a child of the current parent.

-
- Properties -

The XML attributes on each element are passed to the object. The objects -that represent FO objects then convert the attributes into properties.

-

Since properties can be inherited the PropertyList class handles resolving -properties for a particular element. -All properties are specified in an XML file. Classes are created -automatically during the build process.

-

In some cases the element may be moved to have a different parent, for -example markers, or the inheritance could be different, for example -initial property set.

-

Properties (recall that FO's have properties, areas have traits, and XML -nodes have attributes) are also a concern of FOTreeBuilder. It -accomplishes this by using a PropertyListBuilder. There is a -separate PropertyListBuilder for each namespace encountered -while building the FO tree. Each Builder object contains a hash of -property names and their respective makers. It may also -contain element-specific property maker hashes; these are based on the -local name of the flow object, ie. table-row, not -fo:table-row. If an element-specific property mapping exists, -it is preferred to the generic mapping.

-

The base class for all -properties is Property, and all the property makers extend -Property.Maker. A more complete discussion of the property -architecture may be found in Properties.

-
-
- Foreign XML -

FOP supports the handlingof foreign XML. -The XML is converted internally into a DOM, this is then available to -the FO tree to convert the DOM into another format which can be rendered. -In the case of SVG the DOM needs to be created with Batik, so an element -mapping is used to read all elements in the SVG namespace and pass them -into the Batik DOM.

-

The base class for foreign XML is XMLObj. This class handles creating a +

+ Foreign XML +

For SVG, the DOM needs to be created with Batik, so an element mapping is used to read all elements in the SVG namespace and pass them into the Batik DOM.

+

The base class for foreign XML is XMLObj. This class handles creating a DOM Element and the setting of attributes. It also can create a DOM Document if it is a top level element, class XMLElement. This class must be extended for the namespace of the XML elements. For unknown namespaces the class is UnknowXMLObj.

-

If some special processing is needed then the top level element can extend +

If some special processing is needed then the top level element can extend the XMLObj. For example the SVGElement makes the special DOM required for batik and gets the size of the svg.

-

Foreign XML will usually be in an fo:instream-foreign-object, the XML will +

Foreign XML will usually be in an fo:instream-foreign-object, the XML will be passed to the render as a DOM where the render will be able to handle it. Other XML from an unknwon namespace will be ignored.

-

By using element mappings it is possible to read other XML and either

-
    -
  • set information on the area tree
  • -
  • create pseudo FO Objects that create areas in the area tree
  • -
  • create FO Objects
  • -
-
-
- Unknown Elements -

If an element is in a known namespace but the element is unknown then an +

By using element mappings it is possible to read other XML and either

+
    +
  • set information on the area tree
  • +
  • create pseudo FO Objects that create areas in the area tree
  • +
  • create FO Objects
  • +
+
+
+ Unknown Elements +

If an element is in a known namespace but the element is unknown then an Unknown object is created. This is mainly to provide information to the user. This could happen if the fo document contains an element from a different version or the element is misspelt.

-
-
- Extensions -

It is possible to add extensions to FOP so that you can extend the ability of -FOP with respect to render output, document specific information or extended -layout functionality.

-
-
- Page Masters -

The first elements in a document are the elements for the page master setup. -This is usually only a small number and will be used throughout the document to create new pages. -These elements are kept as a factory to create the page and appropriate regions whenever a new page is requested by the layout. -The objects in the FO Tree that represent these elements are themselves the factory. -The root element keeps these objects as a factory for the page sequences.

-
-
- Flow -

The elements that are in the flow of the document are a set of elements -that is needed for the layout process. Each element is important in the -creation of areas.

-
-
- Other Elements -

The remaining FO Objects are things like page-sequence, title and color-profile. -These are handled by their parent element; i.e. the root looks after the declarations and the declarations maintains a list of colour profiles. -The page-sequences are direct descendents of root.

+
diff --git a/src/documentation/content/xdocs/design/layout.xml b/src/documentation/content/xdocs/design/layout.xml index 85105f801..3057e97de 100644 --- a/src/documentation/content/xdocs/design/layout.xml +++ b/src/documentation/content/xdocs/design/layout.xml @@ -27,6 +27,7 @@ Note: it may be possible to start immediately after a block formatting object ha It is also possible to layout all pages in a page sequence after each page sequence has been added from the xml.

The layout process is handled by a set of layout managers. The block level layout managers are used to create the block areas which are added to the region area of a page.

+

The traversal is done by the layout or structure process only in the flow elements.

Keep Layouts Simple

Layout should handle floats, footnotes and keeps in a simple, straightforward way.

diff --git a/src/documentation/content/xdocs/design/parsing.xml b/src/documentation/content/xdocs/design/parsing.xml index 396a1a263..05c5d0ebc 100644 --- a/src/documentation/content/xdocs/design/parsing.xml +++ b/src/documentation/content/xdocs/design/parsing.xml @@ -3,7 +3,7 @@ "http://cvs.apache.org/viewcvs.cgi/*checkout*/xml-forrest/src/resources/schema/dtd/document-v11.dtd">
- XML Parsing + FOP Design: Input Parsing
@@ -24,6 +24,7 @@ Instead, FOP takes SAX events and builds its own tree-like structure. Why?

  • DOM contains an entire document. FOP is able to process individual fo:page-sequence objects discretely, without the need to have the entire document in memory. For documents that have only one fo:page-sequence object, FOP's approach is no advantage, but in other cases it is a huge advantage. A 500-page book that is broken into 100 5-page chapters, each in its own fo:page-sequence, essentially needs only 1% of the document memory that would be required if using DOM as input.
  • See the Input Section of the User Embedding Document for a discussion of input usage patterns and some implementation details.

    +

    FOP's FO Tree Mechanism is responsible for catching the SAX events and processing them.

    Validation @@ -37,25 +38,5 @@ Instead, FOP takes SAX events and builds its own tree-like structure. Why?

    See User Extensions for a discussion of standard extensions shipped with FOP, and their related namespaces.

    See Developer Extensions for a discussion of the mechanisms in place to allow developers to add their own extensions, including how to tell FOP about the foreign namespace.

    -
    - Tree Building -

    The SAX Events will fire all the information for the document with start element, end element, text data etc. -This information is used to build up a representation of the FO document. -To do this for a namespace there is a set of element mappings. -When an element + namepsace mapping is found then it can create an object for that element. -If the element is not found then it creates a dummy object or a generic DOM for unknown namespaces.

    -

    The object is then setup and then given attributes for the element. -For the FO Tree the attributes are converted into properties. -The FO objects use a property list mapping to convert the attributes into a list of properties for the element. -For other XML, for example SVG, a DOM of the XML is constructed. -This DOM can then be passed through to the renderer. -Other element mappings can be used in different ways, for example to create elements that create areas during the layout process or setup information for the renderer etc.

    -

    While the tree building is mainly about creating the FO Tree there are some stages that can propagate to the renderer. -At the end of a page sequence we know that all pages in the page sequence can be laid out without being effected by any further XML. -The significance of this is that the FO Tree for the page sequence may be able to be disposed of. -The end of the XML document also tells us that we can finalise the output document. -(The layout of individual pages is accomplished by the layout managers page at a time; i.e. they do not need to wait for the end of the page sequence. -The page may not yet be complete, however, containing forward page number references, for example.)

    -
    diff --git a/src/documentation/content/xdocs/design/properties.xml b/src/documentation/content/xdocs/design/properties.xml index 6947cc163..8a7797555 100644 --- a/src/documentation/content/xdocs/design/properties.xml +++ b/src/documentation/content/xdocs/design/properties.xml @@ -10,6 +10,38 @@ + + +
    + Properties +

    The XML attributes on each element are passed to the object. The objects +that represent FO objects then convert the attributes into properties.

    +

    Since properties can be inherited the PropertyList class handles resolving +properties for a particular element. +All properties are specified in an XML file. Classes are created +automatically during the build process.

    +

    In some cases the element may be moved to have a different parent, for +example markers, or the inheritance could be different, for example +initial property set.

    +

    Properties (recall that FO's have properties, areas have traits, and XML +nodes have attributes) are also a concern of FOTreeBuilder. It +accomplishes this by using a PropertyListBuilder. There is a +separate PropertyListBuilder for each namespace encountered +while building the FO tree. Each Builder object contains a hash of +property names and their respective makers. It may also +contain element-specific property maker hashes; these are based on the +local name of the flow object, ie. table-row, not +fo:table-row. If an element-specific property mapping exists, +it is preferred to the generic mapping.

    +

    The base class for all +properties is Property, and all the property makers extend +Property.Maker. A more complete discussion of the property +architecture may be found in Properties.

    +
    + + +

    The Refinement step is part of reading and using the properties which may happen immediately or during the layout process.

    +

    During XML Parsing, the FO tree is constructed. For each FO object (some subclass of FObj), the tree builder then passes the list of all attributes specified on the FO element to the handleAttrs method. This -- 2.39.5