From c21d7fce7a9130dddc219ded54b1ac2b20d68685 Mon Sep 17 00:00:00 2001 From: Keiron Liddle Date: Thu, 12 Jul 2001 13:03:39 +0000 Subject: [PATCH] combined property list setting into element setting also always get parser class name from one place git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@194349 13f79535-47bb-0310-9956-ffa450edef68 --- src/org/apache/fop/apps/Driver.java | 147 +++++++++++------- .../fop/configuration/Configuration.java | 3 +- .../configuration/ConfigurationReader.java | 101 +++--------- .../extensions/ExtensionElementMapping.java | 74 +++------ src/org/apache/fop/fo/ElementMapping.java | 59 ++----- .../apache/fop/fo/StandardElementMapping.java | 127 ++++++++------- src/org/apache/fop/image/SVGImage.java | 6 +- .../apache/fop/render/awt/AWTRenderer.java | 6 +- .../apache/fop/render/pdf/PDFRenderer.java | 6 +- src/org/apache/fop/render/ps/PSRenderer.java | 10 +- src/org/apache/fop/svg/SVGElementMapping.java | 16 +- 11 files changed, 245 insertions(+), 310 deletions(-) diff --git a/src/org/apache/fop/apps/Driver.java b/src/org/apache/fop/apps/Driver.java index 1d954f146..b263e2d99 100644 --- a/src/org/apache/fop/apps/Driver.java +++ b/src/org/apache/fop/apps/Driver.java @@ -9,7 +9,6 @@ package org.apache.fop.apps; // FOP import org.apache.fop.fo.FOTreeBuilder; import org.apache.fop.fo.ElementMapping; -import org.apache.fop.fo.PropertyListMapping; import org.apache.fop.layout.AreaTree; import org.apache.fop.layout.FontInfo; import org.apache.fop.render.Renderer; @@ -136,6 +135,18 @@ public class Driver { /** the system resources that FOP will use */ private BufferManager _bufferManager; + public static final String getParserClassName() { + String parserClassName = null; + try { + parserClassName = System.getProperty("org.xml.sax.parser"); + } catch(SecurityException se) { + } + if (parserClassName == null) { + parserClassName = "org.apache.xerces.parsers.SAXParser"; + } + return parserClassName; + } + /** create a new Driver */ public Driver() { _stream = null; @@ -200,30 +211,24 @@ public class Driver { _reader = reader; } - /** * Sets all the element and property list mappings to their default values. * */ public void setupDefaultMappings() { addElementMapping("org.apache.fop.fo.StandardElementMapping"); - addPropertyList ("org.apache.fop.fo.StandardPropertyListMapping"); - addElementMapping("org.apache.fop.svg.SVGElementMapping"); - addPropertyList ("org.apache.fop.svg.SVGPropertyListMapping"); - addElementMapping("org.apache.fop.extensions.ExtensionElementMapping"); - addPropertyList ("org.apache.fop.extensions.ExtensionPropertyListMapping"); - // add mappings from user configuration - Hashtable mappings = Configuration.getHashtableValue("mappings"); - if (mappings != null) { - String prop = (String) mappings.get("property"); - String ele = (String) mappings.get("element"); - try { - addElementMapping(ele); - addPropertyList(prop); - } catch (IllegalArgumentException e) { + // add mappings from available services + Enumeration providers = Service.providers(org.apache.fop.fo.ElementMapping.class); + if (providers != null) { + while(providers.hasMoreElements()) { + String str = (String)providers.nextElement(); + try { + addElementMapping(str); + } catch (IllegalArgumentException e) { + } } } } @@ -271,7 +276,6 @@ public class Driver { } - /** * Set the Renderer to use * @param renderer the renderer instance to use @@ -360,41 +364,6 @@ public class Driver { } } - /** - * Add the PropertyListMapping. - */ - public void addPropertyList(PropertyListMapping mapping) { - mapping.addToBuilder(_treeBuilder); - } - - /** - * Add the PropertyListMapping with the given class name. - */ - public void addPropertyList(String listClassName) - throws IllegalArgumentException { - try { - PropertyListMapping mapping = - (PropertyListMapping) Class.forName( - listClassName).newInstance(); - addPropertyList(mapping); - - } catch (ClassNotFoundException e) { - throw new IllegalArgumentException("Could not find " + - listClassName); - } - catch (InstantiationException e) { - throw new IllegalArgumentException( - "Could not instantiate " + listClassName); - } - catch (IllegalAccessException e) { - throw new IllegalArgumentException("Could not access " + - listClassName); - } - catch (ClassCastException e) { - throw new IllegalArgumentException(listClassName + " is not an ElementMapping"); - } - } - /** * Returns the tree builder (a SAX ContentHandler). * @@ -522,5 +491,79 @@ public class Driver { format(); render(); } +} + +// code stolen from org.apache.batik.util and modified slightly +// does what sun.misc.Service probably does, but it cannot be relied on. +// hopefully will be part of standard jdk sometime. +/** + * This class loads services present in the class path. + */ +class Service { + + static Hashtable providerMap = new Hashtable(); + public static synchronized Enumeration providers(Class cls) { + ClassLoader cl = cls.getClassLoader(); + String serviceFile = "META-INF/services/"+cls.getName(); + + // System.out.println("File: " + serviceFile); + + Vector v = (Vector)providerMap.get(serviceFile); + if (v != null) + return v.elements(); + + v = new Vector(); + providerMap.put(serviceFile, v); + + Enumeration e; + try { + e = cl.getResources(serviceFile); + } catch (IOException ioe) { + return v.elements(); + } + + while (e.hasMoreElements()) { + try { + java.net.URL u = (java.net.URL)e.nextElement(); + // System.out.println("URL: " + u); + + InputStream is = u.openStream(); + Reader r = new InputStreamReader(is, "UTF-8"); + BufferedReader br = new BufferedReader(r); + + String line = br.readLine(); + while (line != null) { + try { + // First strip any comment... + int idx = line.indexOf('#'); + if (idx != -1) + line = line.substring(0, idx); + + // Trim whitespace. + line = line.trim(); + + // If nothing left then loop around... + if (line.length() == 0) { + line = br.readLine(); + continue; + } + // System.out.println("Line: " + line); + + // Try and load the class + //Object obj = cl.loadClass(line).newInstance(); + // stick it into our vector... + v.add(line); + } catch (Exception ex) { + // Just try the next line + } + line = br.readLine(); + } + } catch (Exception ex) { + // Just try the next file... + } + } + return v.elements(); + } } + diff --git a/src/org/apache/fop/configuration/Configuration.java b/src/org/apache/fop/configuration/Configuration.java index 088982841..ec860c8e9 100644 --- a/src/org/apache/fop/configuration/Configuration.java +++ b/src/org/apache/fop/configuration/Configuration.java @@ -1,10 +1,9 @@ /* * Copyright (C) 2001 The Apache Software Foundation. All rights reserved. * For details on use and redistribution please refer to the - * LICENSE file included with these sources." + * LICENSE file included with these sources. */ - package org.apache.fop.configuration; import java.util.Vector; diff --git a/src/org/apache/fop/configuration/ConfigurationReader.java b/src/org/apache/fop/configuration/ConfigurationReader.java index 7a22e40f6..1d92f3afb 100644 --- a/src/org/apache/fop/configuration/ConfigurationReader.java +++ b/src/org/apache/fop/configuration/ConfigurationReader.java @@ -1,52 +1,7 @@ -/* - - ============================================================================ - The Apache Software License, Version 1.1 - ============================================================================ - - Copyright (C) 1999 The Apache Software Foundation. All rights reserved. - - Redistribution and use in source and binary forms, with or without modifica- - tion, are permitted provided that the following conditions are met: - - 1. Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer. - - 2. Redistributions in binary form must reproduce the above copyright notice, - this list of conditions and the following disclaimer in the documentation - and/or other materials provided with the distribution. - - 3. The end-user documentation included with the redistribution, if any, must - include the following acknowledgment: "This product includes software - developed by the Apache Software Foundation (http://www.apache.org/)." - Alternately, this acknowledgment may appear in the software itself, if - and wherever such third-party acknowledgments normally appear. - - 4. The names "Fop" and "Apache Software Foundation" must not be used to - endorse or promote products derived from this software without prior - written permission. For written permission, please contact - apache@apache.org. - - 5. Products derived from this software may not be called "Apache", nor may - "Apache" appear in their name, without prior written permission of the - Apache Software Foundation. - - THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, - INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND - FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, - INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU- - DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS - OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - - This software consists of voluntary contributions made by many individuals - on behalf of the Apache Software Foundation and was originally created by - James Tauber . For more information on the Apache - Software Foundation, please see . - +/* $Id$ + * Copyright (C) 2001 The Apache Software Foundation. All rights reserved. + * For details on use and redistribution please refer to the + * LICENSE file included with these sources. */ package org.apache.fop.configuration; @@ -59,6 +14,7 @@ import java.io.IOException; import org.xml.sax.InputSource; //fop +import org.apache.fop.apps.Driver; import org.apache.fop.messaging.MessageHandler; import org.apache.fop.apps.FOPException; import org.apache.fop.configuration.Configuration; @@ -77,7 +33,6 @@ import org.apache.fop.configuration.Configuration; * Once the configuration has been setup, the information can be accessed with * the methods of StandardConfiguration. */ - public class ConfigurationReader { /** show a full dump on error */ private static boolean errorDump = false; @@ -94,10 +49,9 @@ public class ConfigurationReader { this.filename = filename; } - /** - * intantiates parser and starts parsing of config file - */ + * intantiates parser and starts parsing of config file + */ public void start () throws FOPException { XMLReader parser = createParser(); @@ -106,7 +60,7 @@ public class ConfigurationReader { parser.setFeature("http://xml.org/sax/features/namespace-prefixes", false); } catch (SAXException e) { - throw new FOPException("You need a parser which supports SAX version 2",e); + throw new FOPException("You need a parser which supports SAX version 2",e); } ConfigurationParser configurationParser = new ConfigurationParser(); parser.setContentHandler(configurationParser); @@ -125,20 +79,14 @@ public class ConfigurationReader { } } - /** - * creates a SAX parser, using the value of org.xml.sax.parser - * defaulting to org.apache.xerces.parsers.SAXParser - * - * @return the created SAX parser - */ - public static XMLReader createParser() - throws FOPException - { - String parserClassName = System.getProperty("org.xml.sax.parser"); - if (parserClassName == null) { - parserClassName = "org.apache.xerces.parsers.SAXParser"; - } + * creates a SAX parser, using the value of org.xml.sax.parser + * defaulting to org.apache.xerces.parsers.SAXParser + * + * @return the created SAX parser + */ + public static XMLReader createParser() throws FOPException { + String parserClassName = Driver.getParserClassName(); if (errorDump) { MessageHandler.logln( "configuration reader using SAX parser " + parserClassName); @@ -148,14 +96,15 @@ public class ConfigurationReader { return (XMLReader) Class.forName( parserClassName).newInstance(); } catch (ClassNotFoundException e) { - throw new FOPException("Could not find " + parserClassName,e); + throw new FOPException("Could not find " + parserClassName, e); } catch (InstantiationException e) { throw new FOPException("Could not instantiate " + - parserClassName,e); + parserClassName, e); } catch (IllegalAccessException e) { - throw new FOPException("Could not access " + parserClassName,e); + throw new FOPException("Could not access " + + parserClassName, e); } catch (ClassCastException e) { throw new FOPException(parserClassName + " is not a SAX driver",e); @@ -163,8 +112,8 @@ public class ConfigurationReader { } /** - * Dumps an error - */ + * Dumps an error + */ public void dumpError(Exception e) { if (errorDump) { if (e instanceof SAXException) { @@ -177,14 +126,12 @@ public class ConfigurationReader { } } } - /** - * long or short error messages - * - */ + * long or short error messages + * + */ public void setDumpError(boolean dumpError) { errorDump = dumpError; } - } diff --git a/src/org/apache/fop/extensions/ExtensionElementMapping.java b/src/org/apache/fop/extensions/ExtensionElementMapping.java index c3f1e5f4a..5105694c5 100644 --- a/src/org/apache/fop/extensions/ExtensionElementMapping.java +++ b/src/org/apache/fop/extensions/ExtensionElementMapping.java @@ -1,64 +1,36 @@ -/*-- $Id$ -- - - ============================================================================ - The Apache Software License, Version 1.1 - ============================================================================ - - Copyright (C) 1999 The Apache Software Foundation. All rights reserved. - - Redistribution and use in source and binary forms, with or without modifica- - tion, are permitted provided that the following conditions are met: - - 1. Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer. - - 2. Redistributions in binary form must reproduce the above copyright notice, - this list of conditions and the following disclaimer in the documentation - and/or other materials provided with the distribution. - - 3. The end-user documentation included with the redistribution, if any, must - include the following acknowledgment: "This product includes software - developed by the Apache Software Foundation (http://www.apache.org/)." - Alternately, this acknowledgment may appear in the software itself, if - and wherever such third-party acknowledgments normally appear. - - 4. The names "FOP" and "Apache Software Foundation" must not be used to - endorse or promote products derived from this software without prior - written permission. For written permission, please contact - apache@apache.org. - - 5. Products derived from this software may not be called "Apache", nor may - "Apache" appear in their name, without prior written permission of the - Apache Software Foundation. - - THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, - INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND - FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, - INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU- - DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS - OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - - This software consists of voluntary contributions made by many individuals - on behalf of the Apache Software Foundation and was originally created by - James Tauber . For more information on the Apache - Software Foundation, please see . - +/* $Id$ + * Copyright (C) 2001 The Apache Software Foundation. All rights reserved. + * For details on use and redistribution please refer to the + * LICENSE file included with these sources. */ package org.apache.fop.extensions; import org.apache.fop.fo.*; +import org.apache.fop.fo.properties.ExtensionPropertyMapping; +import org.apache.fop.fo.TreeBuilder; + +import java.util.Enumeration; +import java.util.Hashtable; public class ExtensionElementMapping implements ElementMapping { public static final String URI = "http://xml.apache.org/fop/extensions"; public void addToBuilder(TreeBuilder builder) { - builder.addMapping(URI, "outline", Outline.maker()); - builder.addMapping(URI, "label", Label.maker()); + builder.addMapping(URI, "outline", Outline.maker()); + builder.addMapping(URI, "label", Label.maker()); + + + builder.addPropertyList(ExtensionElementMapping.URI, + ExtensionPropertyMapping.getGenericMappings()); + /* Add any element mappings */ + for (Enumeration e = ExtensionPropertyMapping.getElementMappings(); + e.hasMoreElements();) { + String elem = (String) e.nextElement(); + builder.addElementPropertyList(ExtensionElementMapping.URI, + elem, ExtensionPropertyMapping.getElementMapping( + elem)); + } } } diff --git a/src/org/apache/fop/fo/ElementMapping.java b/src/org/apache/fop/fo/ElementMapping.java index 9ed5cb3d1..baa238033 100644 --- a/src/org/apache/fop/fo/ElementMapping.java +++ b/src/org/apache/fop/fo/ElementMapping.java @@ -1,56 +1,15 @@ -/*-- $Id$ -- - - ============================================================================ - The Apache Software License, Version 1.1 - ============================================================================ - - Copyright (C) 1999 The Apache Software Foundation. All rights reserved. - - Redistribution and use in source and binary forms, with or without modifica- - tion, are permitted provided that the following conditions are met: - - 1. Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer. - - 2. Redistributions in binary form must reproduce the above copyright notice, - this list of conditions and the following disclaimer in the documentation - and/or other materials provided with the distribution. - - 3. The end-user documentation included with the redistribution, if any, must - include the following acknowledgment: "This product includes software - developed by the Apache Software Foundation (http://www.apache.org/)." - Alternately, this acknowledgment may appear in the software itself, if - and wherever such third-party acknowledgments normally appear. - - 4. The names "Fop" and "Apache Software Foundation" must not be used to - endorse or promote products derived from this software without prior - written permission. For written permission, please contact - apache@apache.org. - - 5. Products derived from this software may not be called "Apache", nor may - "Apache" appear in their name, without prior written permission of the - Apache Software Foundation. - - THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, - INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND - FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, - INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU- - DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS - OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - - This software consists of voluntary contributions made by many individuals - on behalf of the Apache Software Foundation and was originally created by - James Tauber . For more information on the Apache - Software Foundation, please see . - +/*-- $Id$ -- + * Copyright (C) 2001 The Apache Software Foundation. All rights reserved. + * For details on use and redistribution please refer to the + * LICENSE file included with these sources. */ + package org.apache.fop.fo; +/** + * Interface for adding supported element and property mappings to + * the given builder. + */ public interface ElementMapping { - public void addToBuilder(TreeBuilder builder); } diff --git a/src/org/apache/fop/fo/StandardElementMapping.java b/src/org/apache/fop/fo/StandardElementMapping.java index 83d7f8256..7dd2cb62f 100644 --- a/src/org/apache/fop/fo/StandardElementMapping.java +++ b/src/org/apache/fop/fo/StandardElementMapping.java @@ -1,12 +1,15 @@ /*-- $Id$ -- - * * Copyright (C) 2001 The Apache Software Foundation. All rights reserved. - * For details on use and redistribution please refer to the - * LICENSE file included with these sources." + * For details on use and redistribution please refer to the + * LICENSE file included with these sources. */ package org.apache.fop.fo; +import java.util.Enumeration; +import java.util.Hashtable; + +import org.apache.fop.fo.properties.FOPropertyMapping; import org.apache.fop.fo.flow.*; import org.apache.fop.fo.pagination.*; @@ -14,60 +17,72 @@ public class StandardElementMapping implements ElementMapping { public void addToBuilder(TreeBuilder builder) { - String uri = "http://www.w3.org/1999/XSL/Format"; + String uri = "http://www.w3.org/1999/XSL/Format"; - builder.addMapping(uri, "root", Root.maker()); - builder.addMapping(uri, "layout-master-set", - LayoutMasterSet.maker()); - builder.addMapping(uri, "simple-page-master", - SimplePageMaster.maker()); - builder.addMapping(uri, "region-body", RegionBody.maker()); - builder.addMapping(uri, "region-before", RegionBefore.maker()); - builder.addMapping(uri, "region-after", RegionAfter.maker()); - builder.addMapping(uri, "region-start", RegionStart.maker()); - builder.addMapping(uri, "region-end", RegionEnd.maker()); - builder.addMapping(uri, "page-sequence", PageSequence.maker()); - builder.addMapping(uri, "page-sequence-master", - PageSequenceMaster.maker()); - builder.addMapping(uri, "single-page-master-reference", - SinglePageMasterReference.maker()); - builder.addMapping(uri, "repeatable-page-master-reference", - RepeatablePageMasterReference.maker()); - builder.addMapping(uri, "conditional-page-master-reference", - ConditionalPageMasterReference.maker()); - builder.addMapping(uri, "repeatable-page-master-alternatives", - RepeatablePageMasterAlternatives.maker()); - builder.addMapping(uri, "flow", Flow.maker()); - builder.addMapping(uri, "static-content", - StaticContent.maker()); - builder.addMapping(uri, "block", Block.maker()); - builder.addMapping(uri, "block-container", BlockContainer.maker()); - builder.addMapping(uri, "list-block", ListBlock.maker()); - builder.addMapping(uri, "list-item", ListItem.maker()); - builder.addMapping(uri, "list-item-label", - ListItemLabel.maker()); - builder.addMapping(uri, "list-item-body", ListItemBody.maker()); - builder.addMapping(uri, "page-number", PageNumber.maker()); - builder.addMapping(uri, "page-number-citation", PageNumberCitation.maker()); - builder.addMapping(uri, "display-sequence", - DisplaySequence.maker()); - builder.addMapping(uri, "inline", - Inline.maker()); - builder.addMapping(uri, "external-graphic", + builder.addMapping(uri, "root", Root.maker()); + builder.addMapping(uri, "layout-master-set", + LayoutMasterSet.maker()); + builder.addMapping(uri, "simple-page-master", + SimplePageMaster.maker()); + builder.addMapping(uri, "region-body", RegionBody.maker()); + builder.addMapping(uri, "region-before", RegionBefore.maker()); + builder.addMapping(uri, "region-after", RegionAfter.maker()); + builder.addMapping(uri, "region-start", RegionStart.maker()); + builder.addMapping(uri, "region-end", RegionEnd.maker()); + builder.addMapping(uri, "page-sequence", PageSequence.maker()); + builder.addMapping(uri, "page-sequence-master", + PageSequenceMaster.maker()); + builder.addMapping(uri, "single-page-master-reference", + SinglePageMasterReference.maker()); + builder.addMapping(uri, "repeatable-page-master-reference", + RepeatablePageMasterReference.maker()); + builder.addMapping(uri, "conditional-page-master-reference", + ConditionalPageMasterReference.maker()); + builder.addMapping(uri, "repeatable-page-master-alternatives", + RepeatablePageMasterAlternatives.maker()); + builder.addMapping(uri, "flow", Flow.maker()); + builder.addMapping(uri, "static-content", StaticContent.maker()); + builder.addMapping(uri, "block", Block.maker()); + builder.addMapping(uri, "block-container", BlockContainer.maker()); + builder.addMapping(uri, "list-block", ListBlock.maker()); + builder.addMapping(uri, "list-item", ListItem.maker()); + builder.addMapping(uri, "list-item-label", ListItemLabel.maker()); + builder.addMapping(uri, "list-item-body", ListItemBody.maker()); + builder.addMapping(uri, "page-number", PageNumber.maker()); + builder.addMapping(uri, "page-number-citation", + PageNumberCitation.maker()); + builder.addMapping(uri, "display-sequence", + DisplaySequence.maker()); + builder.addMapping(uri, "inline", Inline.maker()); + builder.addMapping(uri, "external-graphic", ExternalGraphic.maker()); - builder.addMapping(uri, "table", Table.maker()); - builder.addMapping(uri, "table-column", TableColumn.maker()); - builder.addMapping(uri, "table-header", TableHeader.maker()); - builder.addMapping(uri, "table-body", TableBody.maker()); - builder.addMapping(uri, "table-footer", TableFooter.maker()); - builder.addMapping(uri, "table-row", TableRow.maker()); - builder.addMapping(uri, "table-cell", TableCell.maker()); - builder.addMapping(uri, "basic-link", BasicLink.maker()); - builder.addMapping(uri, "instream-foreign-object", InstreamForeignObject.maker()); - builder.addMapping(uri, "leader", Leader.maker()); - builder.addMapping(uri, "character", org.apache.fop.fo.flow.Character.maker()); - builder.addMapping(uri, "footnote", Footnote.maker()); - builder.addMapping(uri, "footnote-body", FootnoteBody.maker()); - builder.addMapping(uri, "wrapper", Wrapper.maker()); + builder.addMapping(uri, "table", Table.maker()); + builder.addMapping(uri, "table-column", TableColumn.maker()); + builder.addMapping(uri, "table-header", TableHeader.maker()); + builder.addMapping(uri, "table-body", TableBody.maker()); + builder.addMapping(uri, "table-footer", TableFooter.maker()); + builder.addMapping(uri, "table-row", TableRow.maker()); + builder.addMapping(uri, "table-cell", TableCell.maker()); + builder.addMapping(uri, "basic-link", BasicLink.maker()); + builder.addMapping(uri, "instream-foreign-object", + InstreamForeignObject.maker()); + builder.addMapping(uri, "leader", Leader.maker()); + builder.addMapping(uri, "character", + org.apache.fop.fo.flow.Character.maker()); + builder.addMapping(uri, "footnote", Footnote.maker()); + builder.addMapping(uri, "footnote-body", FootnoteBody.maker()); + builder.addMapping(uri, "wrapper", Wrapper.maker()); + + + builder.addPropertyList(uri, + FOPropertyMapping.getGenericMappings()); + /* Add any element mappings */ + for (Enumeration e = FOPropertyMapping.getElementMappings(); + e.hasMoreElements();) { + String elem = (String) e.nextElement(); + builder.addElementPropertyList(uri, elem, + FOPropertyMapping.getElementMapping(elem)); + } + } } diff --git a/src/org/apache/fop/image/SVGImage.java b/src/org/apache/fop/image/SVGImage.java index f39ce2430..691d5acbf 100644 --- a/src/org/apache/fop/image/SVGImage.java +++ b/src/org/apache/fop/image/SVGImage.java @@ -11,6 +11,7 @@ import java.net.URL; import org.w3c.dom.svg.SVGDocument; // FOP +import org.apache.fop.apps.Driver; import org.apache.fop.messaging.*; import org.apache.fop.datatypes.ColorSpace; import org.apache.fop.pdf.PDFColor; @@ -44,10 +45,7 @@ public class SVGImage extends AbstractFopImage { * @return the created SAX parser */ public static String getParserName() { - String parserClassName = System.getProperty("org.xml.sax.parser"); - if (parserClassName == null) { - parserClassName = "org.apache.xerces.parsers.SAXParser"; - } + String parserClassName = Driver.getParserClassName(); return parserClassName; } diff --git a/src/org/apache/fop/render/awt/AWTRenderer.java b/src/org/apache/fop/render/awt/AWTRenderer.java index 82560470f..0a2d57b7e 100644 --- a/src/org/apache/fop/render/awt/AWTRenderer.java +++ b/src/org/apache/fop/render/awt/AWTRenderer.java @@ -917,11 +917,7 @@ public class AWTRenderer implements Renderer, Printable, Pageable { * Returns the class name of the XML parser. */ public String getXMLParserClassName() { - String parserClassName = System.getProperty("org.xml.sax.parser"); - if (parserClassName == null) { - parserClassName = "org.apache.xerces.parsers.SAXParser"; - } - return parserClassName;//application.getXMLParserClassName(); + return Driver.getParserClassName(); } /** diff --git a/src/org/apache/fop/render/pdf/PDFRenderer.java b/src/org/apache/fop/render/pdf/PDFRenderer.java index fbb1faebd..468e82e3c 100644 --- a/src/org/apache/fop/render/pdf/PDFRenderer.java +++ b/src/org/apache/fop/render/pdf/PDFRenderer.java @@ -829,11 +829,7 @@ public class PDFRenderer extends PrintRenderer { * Returns the class name of the XML parser. */ public String getXMLParserClassName() { - String parserClassName = System.getProperty("org.xml.sax.parser"); - if (parserClassName == null) { - parserClassName = "org.apache.xerces.parsers.SAXParser"; - } - return parserClassName;//application.getXMLParserClassName(); + return org.apache.fop.apps.Driver.getParserClassName(); } /** diff --git a/src/org/apache/fop/render/ps/PSRenderer.java b/src/org/apache/fop/render/ps/PSRenderer.java index 442065110..be0f66b03 100644 --- a/src/org/apache/fop/render/ps/PSRenderer.java +++ b/src/org/apache/fop/render/ps/PSRenderer.java @@ -438,7 +438,7 @@ public class PSRenderer implements Renderer { comment("% --- SVG Area"); write("gsave"); if (w != 0 && h != 0) { -/* write("newpath"); + write("newpath"); write(x / 1000f + " " + y / 1000f + " M"); write((x + w) / 1000f + " " + y / 1000f + " rlineto"); write((x + w) / 1000f + " " + (y - h) / 1000f + @@ -446,7 +446,7 @@ public class PSRenderer implements Renderer { write(x / 1000f + " " + (y - h) / 1000f + " rlineto"); write("closepath"); write("clippath"); -*/ } + } // transform so that the coordinates (0,0) is from the top left // and positive is down and to the right. (0,0) is where the // viewBox puts it. @@ -1012,11 +1012,7 @@ public class PSRenderer implements Renderer { * Returns the class name of the XML parser. */ public String getXMLParserClassName() { - String parserClassName = System.getProperty("org.xml.sax.parser"); - if (parserClassName == null) { - parserClassName = "org.apache.xerces.parsers.SAXParser"; - } - return parserClassName;//application.getXMLParserClassName(); + return org.apache.fop.apps.Driver.getParserClassName(); } /** diff --git a/src/org/apache/fop/svg/SVGElementMapping.java b/src/org/apache/fop/svg/SVGElementMapping.java index eb47c0865..3ff03ec5c 100644 --- a/src/org/apache/fop/svg/SVGElementMapping.java +++ b/src/org/apache/fop/svg/SVGElementMapping.java @@ -1,11 +1,14 @@ /* $Id$ * Copyright (C) 2001 The Apache Software Foundation. All rights reserved. * For details on use and redistribution please refer to the - * LICENSE file included with these sources." + * LICENSE file included with these sources. */ package org.apache.fop.svg; +import java.util.Enumeration; + +import org.apache.fop.fo.properties.SVGPropertyMapping; import org.apache.fop.fo.TreeBuilder; import org.apache.fop.fo.FOTreeBuilder; import org.apache.fop.fo.ElementMapping; @@ -67,5 +70,16 @@ public class SVGElementMapping implements ElementMapping { builder.addMapping(uri, "feOffset", FeOffset.maker()); builder.addMapping(uri, "feMerge", FeMerge.maker()); builder.addMapping(uri, "feMergeNode", FeMergeNode.maker()); + + + builder.addPropertyList(uri, + SVGPropertyMapping.getGenericMappings()); + /* Add any element mappings */ + for (Enumeration e = SVGPropertyMapping.getElementMappings(); + e.hasMoreElements();) { + String elem = (String) e.nextElement(); + builder.addElementPropertyList(uri, elem, + SVGPropertyMapping.getElementMapping(elem)); + } } } -- 2.39.5