diff options
author | Jeremias Maerki <jeremias@apache.org> | 2006-01-17 11:07:10 +0000 |
---|---|---|
committer | Jeremias Maerki <jeremias@apache.org> | 2006-01-17 11:07:10 +0000 |
commit | c7d04323247a0d75f773c6fbe00cc1d68844a2e5 (patch) | |
tree | 7f1a575839a1e3fa35417ee97652350e0ff3bd4e /src/java/org/apache/fop/util | |
parent | f56c315df5921953702f6ab9c2a331ff7c0caa0f (diff) | |
download | xmlgraphics-fop-c7d04323247a0d75f773c6fbe00cc1d68844a2e5.tar.gz xmlgraphics-fop-c7d04323247a0d75f773c6fbe00cc1d68844a2e5.zip |
New feature: "Intermediate format" (IF). The IF is basically the XML dialect written by the area tree renderer (XMLRenderer). A new parser for this format allows reparsing a serialized and possibly modified area tree and rendering it to the final target format. More details on the Wiki at http://wiki.apache.org/xmlgraphics-fop/AreaTreeIntermediateXml. No advanced features have been implemented, yet, only the basic functionality. The whole change should be fully backwards-compatible WRT the outer FOP API except maybe for FOTreeBuilder.addElementMapping(), and the area tree XML which got small changes.
The area tree has been cleaned up. The serializability has been restored. The CachedRenderPagesModel works again and can, in certain situations, decrease the maximum amount of memory held at one point in time. Some adjustments were necessary in the area tree to help the work of the AreaTreeParser.
The AreaTreeParser is new and is responsible for parsing area tree XML files and adding pages to a RenderPagesModel instance. It is SAX-based and should be pretty efficient.
XMLUnit (http://xmlunit.sourceforge.net, BSD license) is a new dependency for the test code. It is used to verify the correctness of the intermediate format code. It doesn't have to be installed for the build to run through, though.
ElementMapping got a new method getDOMImplementation() which provides the DOMImplementation used to handle a subdocument of a particular namespace. For example, SVG uses Batik's SVG DOM. The AreaTreeParser needs that to properly recreate foreign objects because it can't use the mechanism of the FO tree. The default implementation returns null.
The ElementMapping instances are no longer maintained by the FOTreeBuilder, but by the newly created ElementMappingRegistry class. It is expected that the instance of this class is moved from the FOTreeBuilder and the AreaTreeParser's Handler class to the "environment class" once it is created to cut down on the startup time for each processed document.
The XMLRenderer has been slightly modified to improve the serialization/deserialization qualities of the area tree XML format.
The XMLRenderer can now mimic another renderer (see mimicRenderer(Renderer)) in order to use its font setup. That way it is made certain that the reparsed area tree will render to the final target format exactly as expected.
Fixed a bug in the XMLHandlerRegistry which did not always return the right XMLHandler for every situation.
Added a DefaultErrorListener to the util package. I've had problems with Xalan-J swallowing exceptions with its default ErrorListener, so I added a simple one for convenience and use in AreaTreeParser.
Example code for working with the AreaTreeParser can be found in examples/embedding. Documentation will follow.
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@369753 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/java/org/apache/fop/util')
-rw-r--r-- | src/java/org/apache/fop/util/DefaultErrorListener.java | 64 |
1 files changed, 64 insertions, 0 deletions
diff --git a/src/java/org/apache/fop/util/DefaultErrorListener.java b/src/java/org/apache/fop/util/DefaultErrorListener.java new file mode 100644 index 000000000..5e1a9cc37 --- /dev/null +++ b/src/java/org/apache/fop/util/DefaultErrorListener.java @@ -0,0 +1,64 @@ +/* + * Copyright 2006 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$ */ + +package org.apache.fop.util; + +import javax.xml.transform.ErrorListener; +import javax.xml.transform.TransformerException; + +import org.apache.commons.logging.Log; + +/** + * Standard ErrorListener implementation for in-FOP use. Some Xalan-J versions don't properly + * re-throw exceptions. + */ +public class DefaultErrorListener implements ErrorListener { + + private Log log; + + /** + * Main constructor + * @param log the log instance to send log events to + */ + public DefaultErrorListener(Log log) { + this.log = log; + } + + /** + * @see javax.xml.transform.ErrorListener#warning(javax.xml.transform.TransformerException) + */ + public void warning(TransformerException exc) { + log.warn(exc.toString()); + } + + /** + * @see javax.xml.transform.ErrorListener#error(javax.xml.transform.TransformerException) + */ + public void error(TransformerException exc) throws TransformerException { + throw exc; + } + + /** + * @see javax.xml.transform.ErrorListener#fatalError(javax.xml.transform.TransformerException) + */ + public void fatalError(TransformerException exc) + throws TransformerException { + throw exc; + } + +}
\ No newline at end of file |