throw new FOPException(e);
}
// The default base URI is taken from the directory in which the fopConf resides
- fopFactoryBuilder = new FopFactoryBuilder(enviro).setConfiguration(cfg);
+ fopFactoryBuilder = new FopFactoryBuilder(enviro).setConfiguration(cfg, false);
configure(baseURI, enviro.getResourceResolver(), cfg);
}
+ public FopConfParser(Configuration cfg, FopFactoryBuilder fopFactoryBuilder) throws SAXException {
+ this.fopFactoryBuilder = fopFactoryBuilder;
+ configure(fopFactoryBuilder.getBaseURI(), ResourceResolverFactory.createDefaultResourceResolver(), cfg);
+ }
+
private void configure(final URI baseURI, final ResourceResolver resourceResolver,
Configuration cfg) throws FOPException {
if (log.isDebugEnabled()) {
import java.util.Map;
import java.util.Set;
+import org.xml.sax.SAXException;
+
import org.apache.xmlgraphics.image.loader.ImageContext;
import org.apache.xmlgraphics.image.loader.ImageManager;
import org.apache.xmlgraphics.image.loader.impl.AbstractImageSessionContext.FallbackResolver;
* @return <code>this</code>
*/
public FopFactoryBuilder setConfiguration(Configuration cfg) {
+ return setConfiguration(cfg, true);
+ }
+
+ protected FopFactoryBuilder setConfiguration(Configuration cfg, boolean parse) {
fopFactoryConfigBuilder.setConfiguration(cfg);
+ if (parse) {
+ try {
+ new FopConfParser(cfg, this);
+ } catch (SAXException e) {
+ throw new RuntimeException(e);
+ }
+ }
return this;
}
package org.apache.fop.apps;
+import java.io.ByteArrayInputStream;
+import java.io.File;
import java.net.URI;
import java.net.URISyntaxException;
import java.util.ArrayList;
import org.apache.fop.apps.io.ResourceResolverFactory;
import org.apache.fop.area.AreaTreeHandler;
import org.apache.fop.area.Block;
+import org.apache.fop.configuration.Configuration;
+import org.apache.fop.configuration.DefaultConfigurationBuilder;
import org.apache.fop.fo.FONode;
import org.apache.fop.fo.extensions.ExternalDocument;
import org.apache.fop.fo.pagination.Flow;
// Expected
}
}
+
+ @Test
+ public void testSetConfiguration() throws Exception {
+ String fopxconf = "<fop version=\"1.0\">\n"
+ + "<source-resolution>288</source-resolution>"
+ + "</fop>";
+ Configuration cfg = new DefaultConfigurationBuilder().build(new ByteArrayInputStream(fopxconf.getBytes()));
+ FopFactory fopFactory = new FopFactoryBuilder(new File(".").toURI()).setConfiguration(cfg).build();
+ assertEquals((int)fopFactory.getSourceResolution(), 288);
+ }
}