xmlgraphics-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From build...@apache.org
Subject svn commit: r840735 [9/19] - in /websites/staging/xmlgraphics/trunk/content: ./ batik/ batik/dev/ batik/tools/ batik/using/ batik/using/scripting/ commons/ fop/ fop/0.95/ fop/1.0/ fop/1.1/ fop/trunk/
Date Tue, 04 Dec 2012 15:59:44 GMT
Modified: websites/staging/xmlgraphics/trunk/content/fop/0.95/servlets.html
==============================================================================
--- websites/staging/xmlgraphics/trunk/content/fop/0.95/servlets.html (original)
+++ websites/staging/xmlgraphics/trunk/content/fop/0.95/servlets.html Tue Dec  4 15:59:34 2012
@@ -362,67 +362,68 @@ This example servlet should not be used 
 <p>This section assumes you are familiar with <a href="embedding.html">embedding FOP</a> .</p>
 <h3 id="a-minimal-servlet-wzxhzdk15wzxhzdk16">A minimal Servlet <a id="minimal-servlet"></a></h3>
 <p>Here is a minimal code snippet to demonstrate the basics:</p>
-<div class="codehilite"><pre><span class="n">private</span> <span class="n">FopFactory</span> <span class="n">fopFactory</span> <span class="o">=</span> <span class="n">FopFactory</span><span class="o">.</span><span class="n">newInstance</span><span class="p">();</span>
-<span class="n">private</span> <span class="n">TransformerFactory</span> <span class="n">tFactory</span> <span class="o">=</span> <span class="n">TransformerFactory</span><span class="o">.</span><span class="n">newInstance</span><span class="p">();</span>
+<div class="codehilite"><pre><span class="kd">private</span> <span class="n">FopFactory</span> <span class="n">fopFactory</span> <span class="o">=</span> <span class="n">FopFactory</span><span class="o">.</span><span class="na">newInstance</span><span class="o">();</span>
+<span class="kd">private</span> <span class="n">TransformerFactory</span> <span class="n">tFactory</span> <span class="o">=</span> <span class="n">TransformerFactory</span><span class="o">.</span><span class="na">newInstance</span><span class="o">();</span>
 
-<span class="n">public</span> <span class="n">void</span> <span class="n">doGet</span><span class="p">(</span><span class="n">HttpServletRequest</span> <span class="n">request</span><span class="p">,</span>
-                   <span class="n">HttpServletResponse</span> <span class="n">response</span><span class="p">)</span> <span class="n">throws</span> <span class="n">ServletException</span> <span class="p">{</span>
-    <span class="n">try</span> <span class="p">{</span>
-        <span class="n">response</span><span class="o">.</span><span class="n">setContentType</span><span class="p">(</span><span class="s">&quot;application/pdf&quot;</span><span class="p">);</span>
-        <span class="n">Fop</span> <span class="n">fop</span> <span class="o">=</span> <span class="n">fopFactory</span><span class="o">.</span><span class="n">newFop</span><span class="p">(</span><span class="n">MimeConstants</span><span class="o">.</span><span class="n">MIME_PDF</span><span class="p">,</span> <span class="n">response</span><span class="o">.</span><span class="n">getOutputStream</span><span class="p">());</span>
-        <span class="n">Transformer</span> <span class="n">transformer</span> <span class="o">=</span> <span class="n">tFactory</span><span class="o">.</span><span class="n">newTransformer</span><span class="p">();</span>
-        <span class="n">Source</span> <span class="n">src</span> <span class="o">=</span> <span class="k">new</span> <span class="n">StreamSource</span><span class="p">(</span><span class="s">&quot;foo.fo&quot;</span><span class="p">);</span>
-        <span class="n">Result</span> <span class="n">res</span> <span class="o">=</span> <span class="k">new</span> <span class="n">SAXResult</span><span class="p">(</span><span class="n">fop</span><span class="o">.</span><span class="n">getDefaultHandler</span><span class="p">());</span>
-        <span class="n">transformer</span><span class="o">.</span><span class="n">transform</span><span class="p">(</span><span class="n">src</span><span class="p">,</span> <span class="n">res</span><span class="p">);</span>
-    <span class="p">}</span> <span class="n">catch</span> <span class="p">(</span><span class="n">Exception</span> <span class="n">ex</span><span class="p">)</span> <span class="p">{</span>
-        <span class="n">throw</span> <span class="k">new</span> <span class="n">ServletException</span><span class="p">(</span><span class="n">ex</span><span class="p">);</span>
-    <span class="p">}</span>
-<span class="p">}</span>
+<span class="kd">public</span> <span class="kt">void</span> <span class="nf">doGet</span><span class="o">(</span><span class="n">HttpServletRequest</span> <span class="n">request</span><span class="o">,</span>
+                   <span class="n">HttpServletResponse</span> <span class="n">response</span><span class="o">)</span> <span class="kd">throws</span> <span class="n">ServletException</span> <span class="o">{</span>
+    <span class="k">try</span> <span class="o">{</span>
+        <span class="n">response</span><span class="o">.</span><span class="na">setContentType</span><span class="o">(</span><span class="s">&quot;application/pdf&quot;</span><span class="o">);</span>
+        <span class="n">Fop</span> <span class="n">fop</span> <span class="o">=</span> <span class="n">fopFactory</span><span class="o">.</span><span class="na">newFop</span><span class="o">(</span><span class="n">MimeConstants</span><span class="o">.</span><span class="na">MIME_PDF</span><span class="o">,</span> <span class="n">response</span><span class="o">.</span><span class="na">getOutputStream</span><span class="o">());</span>
+        <span class="n">Transformer</span> <span class="n">transformer</span> <span class="o">=</span> <span class="n">tFactory</span><span class="o">.</span><span class="na">newTransformer</span><span class="o">();</span>
+        <span class="n">Source</span> <span class="n">src</span> <span class="o">=</span> <span class="k">new</span> <span class="n">StreamSource</span><span class="o">(</span><span class="s">&quot;foo.fo&quot;</span><span class="o">);</span>
+        <span class="n">Result</span> <span class="n">res</span> <span class="o">=</span> <span class="k">new</span> <span class="n">SAXResult</span><span class="o">(</span><span class="n">fop</span><span class="o">.</span><span class="na">getDefaultHandler</span><span class="o">());</span>
+        <span class="n">transformer</span><span class="o">.</span><span class="na">transform</span><span class="o">(</span><span class="n">src</span><span class="o">,</span> <span class="n">res</span><span class="o">);</span>
+    <span class="o">}</span> <span class="k">catch</span> <span class="o">(</span><span class="n">Exception</span> <span class="n">ex</span><span class="o">)</span> <span class="o">{</span>
+        <span class="k">throw</span> <span class="k">new</span> <span class="nf">ServletException</span><span class="o">(</span><span class="n">ex</span><span class="o">);</span>
+    <span class="o">}</span>
+<span class="o">}</span>
 </pre></div>
 
 
 <p>There are numerous problems with the code snippet above. Its purpose is only to demonstrate the basic concepts. See below for details.</p>
 <h3 id="adding-xsl-tranformation-xslt-wzxhzdk17wzxhzdk18">Adding XSL tranformation (XSLT) <a id="xslt"></a></h3>
 <p>A common requirement is to transform an XML source to XSL-FO using an XSL transformation. It is recommended to use JAXP for this task. The following snippet shows the basic code:</p>
-<div class="codehilite"><pre><span class="n">private</span> <span class="n">FopFactory</span> <span class="n">fopFactory</span> <span class="o">=</span> <span class="n">FopFactory</span><span class="o">.</span><span class="n">newInstance</span><span class="p">();</span>
-<span class="n">private</span> <span class="n">TransformerFactory</span> <span class="n">tFactory</span> <span class="o">=</span> <span class="n">TransformerFactory</span><span class="o">.</span><span class="n">newInstance</span><span class="p">();</span>
+<div class="codehilite"><pre><span class="kd">private</span> <span class="n">FopFactory</span> <span class="n">fopFactory</span> <span class="o">=</span> <span class="n">FopFactory</span><span class="o">.</span><span class="na">newInstance</span><span class="o">();</span>
+<span class="kd">private</span> <span class="n">TransformerFactory</span> <span class="n">tFactory</span> <span class="o">=</span> <span class="n">TransformerFactory</span><span class="o">.</span><span class="na">newInstance</span><span class="o">();</span>
 
-<span class="n">public</span> <span class="n">void</span> <span class="n">init</span><span class="p">()</span> <span class="n">throws</span> <span class="n">ServletException</span> <span class="p">{</span>
-    <span class="sr">//</span><span class="n">Optionally</span> <span class="n">customize</span> <span class="n">the</span> <span class="n">FopFactory</span> <span class="ow">and</span> <span class="n">TransformerFactory</span> <span class="n">here</span>
-<span class="p">}</span>
+<span class="kd">public</span> <span class="kt">void</span> <span class="nf">init</span><span class="o">()</span> <span class="kd">throws</span> <span class="n">ServletException</span> <span class="o">{</span>
+    <span class="c1">//Optionally customize the FopFactory and TransformerFactory here</span>
+<span class="o">}</span>
 
-<span class="p">[</span><span class="o">..</span><span class="p">]</span>
+<span class="o">[..]</span>
 
-<span class="sr">//</span><span class="n">Setup</span> <span class="n">a</span> <span class="n">buffer</span> <span class="n">to</span> <span class="n">obtain</span> <span class="n">the</span> <span class="n">content</span> <span class="nb">length</span>
-<span class="n">ByteArrayOutputStream</span> <span class="n">out</span> <span class="o">=</span> <span class="k">new</span> <span class="n">ByteArrayOutputStream</span><span class="p">();</span>
+<span class="c1">//Setup a buffer to obtain the content length</span>
+<span class="n">ByteArrayOutputStream</span> <span class="n">out</span> <span class="o">=</span> <span class="k">new</span> <span class="n">ByteArrayOutputStream</span><span class="o">();</span>
 
-<span class="sr">//</span><span class="n">Setup</span> <span class="n">FOP</span>
-<span class="n">Fop</span> <span class="n">fop</span> <span class="o">=</span> <span class="n">fopFactory</span><span class="o">.</span><span class="n">newFop</span><span class="p">(</span><span class="n">MimeConstants</span><span class="o">.</span><span class="n">MIME_PDF</span><span class="p">,</span> <span class="n">out</span><span class="p">);</span>
+<span class="c1">//Setup FOP</span>
+<span class="n">Fop</span> <span class="n">fop</span> <span class="o">=</span> <span class="n">fopFactory</span><span class="o">.</span><span class="na">newFop</span><span class="o">(</span><span class="n">MimeConstants</span><span class="o">.</span><span class="na">MIME_PDF</span><span class="o">,</span> <span class="n">out</span><span class="o">);</span>
 
-<span class="sr">//</span><span class="n">Setup</span> <span class="n">Transformer</span>
-<span class="n">Source</span> <span class="n">xsltSrc</span> <span class="o">=</span> <span class="k">new</span> <span class="n">StreamSource</span><span class="p">(</span><span class="k">new</span> <span class="n">File</span><span class="p">(</span><span class="s">&quot;foo-xml2fo.xsl&quot;</span><span class="p">));</span>
-<span class="n">Transformer</span> <span class="n">transformer</span> <span class="o">=</span> <span class="n">tFactory</span><span class="o">.</span><span class="n">newTransformer</span><span class="p">(</span><span class="n">xsltSrc</span><span class="p">);</span>
+<span class="c1">//Setup Transformer</span>
+<span class="n">Source</span> <span class="n">xsltSrc</span> <span class="o">=</span> <span class="k">new</span> <span class="n">StreamSource</span><span class="o">(</span><span class="k">new</span> <span class="n">File</span><span class="o">(</span><span class="s">&quot;foo-xml2fo.xsl&quot;</span><span class="o">));</span>
+<span class="n">Transformer</span> <span class="n">transformer</span> <span class="o">=</span> <span class="n">tFactory</span><span class="o">.</span><span class="na">newTransformer</span><span class="o">(</span><span class="n">xsltSrc</span><span class="o">);</span>
 
-<span class="sr">//</span><span class="n">Make</span> <span class="n">sure</span> <span class="n">the</span> <span class="n">XSL</span> <span class="n">transformation</span><span class="err">&#39;</span><span class="n">s</span> <span class="n">result</span> <span class="n">is</span> <span class="n">piped</span> <span class="n">through</span> <span class="n">to</span> <span class="n">FOP</span>
-<span class="n">Result</span> <span class="n">res</span> <span class="o">=</span> <span class="k">new</span> <span class="n">SAXResult</span><span class="p">(</span><span class="n">fop</span><span class="o">.</span><span class="n">getDefaultHandler</span><span class="p">());</span>
+<span class="c1">//Make sure the XSL transformation&#39;s result is piped through to FOP</span>
+<span class="n">Result</span> <span class="n">res</span> <span class="o">=</span> <span class="k">new</span> <span class="n">SAXResult</span><span class="o">(</span><span class="n">fop</span><span class="o">.</span><span class="na">getDefaultHandler</span><span class="o">());</span>
 
-<span class="sr">//</span><span class="n">Setup</span> <span class="n">input</span>
-<span class="n">Source</span> <span class="n">src</span> <span class="o">=</span> <span class="k">new</span> <span class="n">StreamSource</span><span class="p">(</span><span class="k">new</span> <span class="n">File</span><span class="p">(</span><span class="s">&quot;foo.xml&quot;</span><span class="p">));</span>
+<span class="c1">//Setup input</span>
+<span class="n">Source</span> <span class="n">src</span> <span class="o">=</span> <span class="k">new</span> <span class="n">StreamSource</span><span class="o">(</span><span class="k">new</span> <span class="n">File</span><span class="o">(</span><span class="s">&quot;foo.xml&quot;</span><span class="o">));</span>
 
-<span class="sr">//</span><span class="n">Start</span> <span class="n">the</span> <span class="n">transformation</span> <span class="ow">and</span> <span class="n">rendering</span> <span class="n">process</span>
-<span class="n">transformer</span><span class="o">.</span><span class="n">transform</span><span class="p">(</span><span class="n">src</span><span class="p">,</span> <span class="n">res</span><span class="p">);</span>
+<span class="c1">//Start the transformation and rendering process</span>
+<span class="n">transformer</span><span class="o">.</span><span class="na">transform</span><span class="o">(</span><span class="n">src</span><span class="o">,</span> <span class="n">res</span><span class="o">);</span>
 
-<span class="sr">//</span><span class="n">Prepare</span> <span class="n">response</span>
-<span class="n">response</span><span class="o">.</span><span class="n">setContentType</span><span class="p">(</span><span class="s">&quot;application/pdf&quot;</span><span class="p">);</span>
-<span class="n">response</span><span class="o">.</span><span class="n">setContentLength</span><span class="p">(</span><span class="n">out</span><span class="o">.</span><span class="n">size</span><span class="p">());</span>
+<span class="c1">//Prepare response</span>
+<span class="n">response</span><span class="o">.</span><span class="na">setContentType</span><span class="o">(</span><span class="s">&quot;application/pdf&quot;</span><span class="o">);</span>
+<span class="n">response</span><span class="o">.</span><span class="na">setContentLength</span><span class="o">(</span><span class="n">out</span><span class="o">.</span><span class="na">size</span><span class="o">());</span>
 
-<span class="sr">//</span><span class="n">Send</span> <span class="n">content</span> <span class="n">to</span> <span class="n">Browser</span>
-<span class="n">response</span><span class="o">.</span><span class="n">getOutputStream</span><span class="p">()</span><span class="o">.</span><span class="nb">write</span><span class="p">(</span><span class="n">out</span><span class="o">.</span><span class="n">toByteArray</span><span class="p">());</span>
-<span class="n">response</span><span class="o">.</span><span class="n">getOutputStream</span><span class="p">()</span><span class="o">.</span><span class="n">flush</span><span class="p">();</span><span class="n">Buffering</span> <span class="n">the</span> <span class="n">generated</span> <span class="n">PDF</span> <span class="n">in</span> <span class="n">a</span> <span class="n">ByteArrayOutputStream</span> <span class="n">is</span> <span class="n">done</span> <span class="n">to</span> <span class="n">avoid</span> <span class="n">potential</span> <span class="n">problems</span> <span class="n">with</span> <span class="n">the</span> <span class="n">Acrobat</span> <span class="n">Reader</span> <span class="n">Plug</span><span class="o">-</span><span class="n">in</span> <span class="n">in</span> <span class="n">Microsoft</span> <span class="n">Internet</span> <span class="n">Explorer</span><span class="o">.</span>
+<span class="c1">//Send content to Browser</span>
+<span class="n">response</span><span class="o">.</span><span class="na">getOutputStream</span><span class="o">().</span><span class="na">write</span><span class="o">(</span><span class="n">out</span><span class="o">.</span><span class="na">toByteArray</span><span class="o">());</span>
+<span class="n">response</span><span class="o">.</span><span class="na">getOutputStream</span><span class="o">().</span><span class="na">flush</span><span class="o">();</span>
 </pre></div>
 
 
-<p>The <code>Source</code> instance used above is simply an example. If you have to read the XML from a string, supply a <code>new StreamSource(new
+<p>Buffering the generated PDF in a ByteArrayOutputStream is done to avoid potential problems with the Acrobat Reader Plug-in in Microsoft Internet Explorer.
+The <code>Source</code> instance used above is simply an example. If you have to read the XML from a string, supply a <code>new StreamSource(new
           StringReader(xmlstring))</code> . Constructing and reparsing an XML string is generally less desirable than using a SAXSource if you generate your XML. You can alternatively supply a DOMSource as well. You may also use dynamically generated XSL if you like.</p>
 <p>Because you have an explicit <code>Transformer</code> object, you can also use it to explicitely set parameters for the transformation run.</p>
 <h3 id="custom-configuration-wzxhzdk19wzxhzdk20">Custom configuration <a id="cfg"></a></h3>
@@ -431,7 +432,7 @@ This example servlet should not be used 
 <p>There are several options to consider:</p>
 <ul>
 <li>
-<p>Instead of java.io.ByteArrayOutputStream consider using the ByteArrayOutputStream implementation from the <a href="http://commons.apache.org/io/">Jakarta Commons IO project</a> which allocates less memory. The full class name is: <code>org.apache.commons.io.output.ByteArrayOutputStream</code> </p>
+<p>Instead of java.io.ByteArrayOutputStream consider using the ByteArrayOutputStream implementation from the <a href="http://commons.apache.org/io/">Jakarta Commons IO project</a> which allocates less memory. The full class name is: <code>org.apache.commons.io.output.ByteArrayOutputStream</code></p>
 </li>
 <li>
 <p>In certain cases it can help to write the generated PDF to a temporary file so you can quickly reuse the file. This is especially useful, if Internet Explorer calls the servlet multiple times with the same request or if you often generate equal PDFs.</p>
@@ -441,13 +442,13 @@ This example servlet should not be used 
 <h3 id="accessing-resources-in-your-web-application-wzxhzdk23wzxhzdk24">Accessing resources in your web application <a id="uriresolver"></a></h3>
 <p>Often, you will want to use resources (stylesheets, images etc.) which are bundled with your web application. FOP provides a URIResolver implementation that lets you access files via the Servlet's ServletContext. The class is called <code>org.apache.fop.servlet.ServletContextURIResolver</code> .</p>
 <p>Here's how to set it up in your servlet. Instantiate a new instance in the servlet's init() method:</p>
-<div class="codehilite"><pre><span class="sr">/** URIResolver for use by this servlet */</span>
-<span class="n">protected</span> <span class="n">URIResolver</span> <span class="n">uriResolver</span><span class="p">;</span>
+<div class="codehilite"><pre><span class="cm">/** URIResolver for use by this servlet */</span>
+<span class="kd">protected</span> <span class="n">URIResolver</span> <span class="n">uriResolver</span><span class="o">;</span>
 
-<span class="n">public</span> <span class="n">void</span> <span class="n">init</span><span class="p">()</span> <span class="n">throws</span> <span class="n">ServletException</span> <span class="p">{</span>
-    <span class="n">this</span><span class="o">.</span><span class="n">uriResolver</span> <span class="o">=</span> <span class="k">new</span> <span class="n">ServletContextURIResolver</span><span class="p">(</span><span class="n">getServletContext</span><span class="p">());</span>
-    <span class="p">[</span><span class="o">..</span><span class="p">]</span>
-<span class="p">}</span>
+<span class="kd">public</span> <span class="kt">void</span> <span class="nf">init</span><span class="o">()</span> <span class="kd">throws</span> <span class="n">ServletException</span> <span class="o">{</span>
+    <span class="k">this</span><span class="o">.</span><span class="na">uriResolver</span> <span class="o">=</span> <span class="k">new</span> <span class="n">ServletContextURIResolver</span><span class="o">(</span><span class="n">getServletContext</span><span class="o">());</span>
+    <span class="o">[..]</span>
+<span class="o">}</span>
 </pre></div>
 
 
@@ -465,23 +466,23 @@ This example servlet should not be used 
 </li>
 </ul>
 <p>Here are some example snippets:</p>
-<div class="codehilite"><pre><span class="sr">//</span><span class="n">Setting</span> <span class="n">up</span> <span class="n">the</span> <span class="n">JAXP</span> <span class="n">TransformerFactory</span>
-<span class="n">this</span><span class="o">.</span><span class="n">transFactory</span> <span class="o">=</span> <span class="n">TransformerFactory</span><span class="o">.</span><span class="n">newInstance</span><span class="p">();</span>
-<span class="n">this</span><span class="o">.</span><span class="n">transFactory</span><span class="o">.</span><span class="n">setURIResolver</span><span class="p">(</span><span class="n">this</span><span class="o">.</span><span class="n">uriResolver</span><span class="p">);</span>
-
-<span class="p">[</span><span class="o">..</span><span class="p">]</span>
-
-<span class="sr">//</span><span class="n">Setting</span> <span class="n">up</span> <span class="n">the</span> <span class="n">FOP</span> <span class="n">factory</span>
-<span class="n">this</span><span class="o">.</span><span class="n">fopFactory</span> <span class="o">=</span> <span class="n">FopFactory</span><span class="o">.</span><span class="n">newInstance</span><span class="p">();</span>
-<span class="n">this</span><span class="o">.</span><span class="n">fopFactory</span><span class="o">.</span><span class="n">setURIResolver</span><span class="p">(</span><span class="n">this</span><span class="o">.</span><span class="n">uriResolver</span><span class="p">);</span>
-
-<span class="p">[</span><span class="o">..</span><span class="p">]</span>
-
-<span class="sr">//</span><span class="n">The</span> <span class="n">stylesheet</span> <span class="k">for</span> <span class="n">the</span> <span class="n">JAXP</span> <span class="n">Transfomer</span>
-<span class="n">Source</span> <span class="n">xsltSrc</span> <span class="o">=</span> <span class="n">this</span><span class="o">.</span><span class="n">uriResolver</span><span class="o">.</span><span class="n">resolve</span><span class="p">(</span>
-    <span class="s">&quot;servlet-context:/xslt/mystylesheet.xsl&quot;</span><span class="p">,</span> <span class="n">null</span><span class="p">);</span>
-<span class="n">Transformer</span> <span class="n">transformer</span> <span class="o">=</span> <span class="n">this</span><span class="o">.</span><span class="n">transFactory</span><span class="o">.</span><span class="n">newTransformer</span><span class="p">(</span><span class="n">xsltSrc</span><span class="p">);</span>
-<span class="n">transformer</span><span class="o">.</span><span class="n">setURIResolver</span><span class="p">(</span><span class="n">this</span><span class="o">.</span><span class="n">uriResolver</span><span class="p">);</span>
+<div class="codehilite"><pre><span class="c1">//Setting up the JAXP TransformerFactory</span>
+<span class="k">this</span><span class="o">.</span><span class="na">transFactory</span> <span class="o">=</span> <span class="n">TransformerFactory</span><span class="o">.</span><span class="na">newInstance</span><span class="o">();</span>
+<span class="k">this</span><span class="o">.</span><span class="na">transFactory</span><span class="o">.</span><span class="na">setURIResolver</span><span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="na">uriResolver</span><span class="o">);</span>
+
+<span class="o">[..]</span>
+
+<span class="c1">//Setting up the FOP factory</span>
+<span class="k">this</span><span class="o">.</span><span class="na">fopFactory</span> <span class="o">=</span> <span class="n">FopFactory</span><span class="o">.</span><span class="na">newInstance</span><span class="o">();</span>
+<span class="k">this</span><span class="o">.</span><span class="na">fopFactory</span><span class="o">.</span><span class="na">setURIResolver</span><span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="na">uriResolver</span><span class="o">);</span>
+
+<span class="o">[..]</span>
+
+<span class="c1">//The stylesheet for the JAXP Transfomer</span>
+<span class="n">Source</span> <span class="n">xsltSrc</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="na">uriResolver</span><span class="o">.</span><span class="na">resolve</span><span class="o">(</span>
+    <span class="s">&quot;servlet-context:/xslt/mystylesheet.xsl&quot;</span><span class="o">,</span> <span class="kc">null</span><span class="o">);</span>
+<span class="n">Transformer</span> <span class="n">transformer</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="na">transFactory</span><span class="o">.</span><span class="na">newTransformer</span><span class="o">(</span><span class="n">xsltSrc</span><span class="o">);</span>
+<span class="n">transformer</span><span class="o">.</span><span class="na">setURIResolver</span><span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="na">uriResolver</span><span class="o">);</span>
 </pre></div>
 
 

Modified: websites/staging/xmlgraphics/trunk/content/fop/1.0/anttask.html
==============================================================================
--- websites/staging/xmlgraphics/trunk/content/fop/1.0/anttask.html (original)
+++ websites/staging/xmlgraphics/trunk/content/fop/1.0/anttask.html Tue Dec  4 15:59:34 2012
@@ -346,16 +346,16 @@ $(document).ready(function () {
 <h2 id="description-wzxhzdk7wzxhzdk8">Description <a id="basics"></a></h2>
 <p>The FOP Ant task will convert XSL-FO documents to PDF, PS, PCL etc. output (see <a href="output.html">Output formats</a> for available formats).</p>
 <p>To call FOP tasks within Ant, first add a FOP task definition to your Ant build file. One method of defining the task is as follows:</p>
-<div class="codehilite"><pre><span class="nt">&lt;property</span> <span class="na">name=</span><span class="s">&quot;fop.home&quot;</span> <span class="na">value=</span><span class="s">&quot;....path to your FOP HOME directory...&quot;/</span><span class="nt">&gt;</span>
+<div class="codehilite"><pre><span class="nt">&lt;property</span> <span class="na">name=</span><span class="s">&quot;fop.home&quot;</span> <span class="na">value=</span><span class="s">&quot;....path to your FOP HOME directory...&quot;</span><span class="nt">/&gt;</span>
 
-<span class="nt">&lt;taskdef</span> <span class="na">name=</span><span class="s">&quot;fop&quot;</span> 
+<span class="nt">&lt;taskdef</span> <span class="na">name=</span><span class="s">&quot;fop&quot;</span>
          <span class="na">classname=</span><span class="s">&quot;org.apache.fop.tools.anttasks.Fop&quot;</span><span class="nt">&gt;</span>
   <span class="nt">&lt;classpath&gt;</span>
-    <span class="nt">&lt;fileset</span> <span class="na">dir=</span><span class="s">&quot;</span><span class="cp">${</span><span class="n">fop</span><span class="o">.</span><span class="n">home</span><span class="cp">}</span><span class="s">/lib&quot;</span><span class="nt">&gt;</span>
-      <span class="nt">&lt;include</span> <span class="na">name=</span><span class="s">&quot;*.jar&quot;/</span><span class="nt">&gt;</span>
+    <span class="nt">&lt;fileset</span> <span class="na">dir=</span><span class="s">&quot;${fop.home}/lib&quot;</span><span class="nt">&gt;</span>
+      <span class="nt">&lt;include</span> <span class="na">name=</span><span class="s">&quot;*.jar&quot;</span><span class="nt">/&gt;</span>
     <span class="nt">&lt;/fileset&gt;</span>
-    <span class="nt">&lt;fileset</span> <span class="na">dir=</span><span class="s">&quot;</span><span class="cp">${</span><span class="n">fop</span><span class="o">.</span><span class="n">home</span><span class="cp">}</span><span class="s">/build&quot;</span><span class="nt">&gt;</span>
-      <span class="nt">&lt;include</span> <span class="na">name=</span><span class="s">&quot;fop.jar&quot;/</span><span class="nt">&gt;</span>
+    <span class="nt">&lt;fileset</span> <span class="na">dir=</span><span class="s">&quot;${fop.home}/build&quot;</span><span class="nt">&gt;</span>
+      <span class="nt">&lt;include</span> <span class="na">name=</span><span class="s">&quot;fop.jar&quot;</span><span class="nt">/&gt;</span>
       <span class="nt">&lt;include</span> <span class="na">name=</span><span class="s">&quot;fop-hyph.jar&quot;</span> <span class="nt">/&gt;</span>
     <span class="nt">&lt;/fileset&gt;</span>
   <span class="nt">&lt;/classpath&gt;</span>
@@ -466,7 +466,7 @@ $(document).ready(function () {
 <h2 id="examples-wzxhzdk14wzxhzdk15">Examples <a id="examples"></a></h2>
 <p>The following example converts a single XSL-FO file to a PDF document:</p>
 <div class="codehilite"><pre><span class="nt">&lt;target</span> <span class="na">name=</span><span class="s">&quot;generate-pdf&quot;</span> <span class="na">description=</span><span class="s">&quot;Generates a single PDF file&quot;</span><span class="nt">&gt;</span>
-   <span class="nt">&lt;fop</span> <span class="na">format=</span><span class="s">&quot;application/pdf&quot;</span> 
+   <span class="nt">&lt;fop</span> <span class="na">format=</span><span class="s">&quot;application/pdf&quot;</span>
         <span class="na">fofile=</span><span class="s">&quot;c:\working\foDirectory\foDocument.fo&quot;</span>
         <span class="na">outfile=</span><span class="s">&quot;c:\working\pdfDirectory\pdfDocument.pdf&quot;</span> <span class="nt">/&gt;</span>
 <span class="nt">&lt;/target&gt;</span>
@@ -474,12 +474,12 @@ $(document).ready(function () {
 
 
 <p>This example converts all XSL-FO files within an entire directory to PostScript:</p>
-<div class="codehilite"><pre><span class="nt">&lt;target</span> <span class="na">name=</span><span class="s">&quot;generate-multiple-ps&quot;</span> 
+<div class="codehilite"><pre><span class="nt">&lt;target</span> <span class="na">name=</span><span class="s">&quot;generate-multiple-ps&quot;</span>
         <span class="na">description=</span><span class="s">&quot;Generates multiple PostScript files&quot;</span><span class="nt">&gt;</span>
-   <span class="nt">&lt;fop</span> <span class="na">format=</span><span class="s">&quot;application/postscript&quot;</span> 
-        <span class="na">outdir=</span><span class="s">&quot;</span><span class="cp">${</span><span class="n">build</span><span class="o">.</span><span class="n">dir</span><span class="cp">}</span><span class="s">&quot;</span> <span class="na">messagelevel=</span><span class="s">&quot;debug&quot;</span><span class="nt">&gt;</span>
-        <span class="nt">&lt;fileset</span> <span class="na">dir=</span><span class="s">&quot;</span><span class="cp">${</span><span class="n">fo</span><span class="o">.</span><span class="n">examples</span><span class="o">.</span><span class="n">dir</span><span class="cp">}</span><span class="s">&quot;</span><span class="nt">&gt;</span>
-           <span class="nt">&lt;include</span> <span class="na">name=</span><span class="s">&quot;*.fo&quot;/</span><span class="nt">&gt;</span>
+   <span class="nt">&lt;fop</span> <span class="na">format=</span><span class="s">&quot;application/postscript&quot;</span>
+        <span class="na">outdir=</span><span class="s">&quot;${build.dir}&quot;</span> <span class="na">messagelevel=</span><span class="s">&quot;debug&quot;</span><span class="nt">&gt;</span>
+        <span class="nt">&lt;fileset</span> <span class="na">dir=</span><span class="s">&quot;${fo.examples.dir}&quot;</span><span class="nt">&gt;</span>
+           <span class="nt">&lt;include</span> <span class="na">name=</span><span class="s">&quot;*.fo&quot;</span><span class="nt">/&gt;</span>
         <span class="nt">&lt;/fileset&gt;</span>
    <span class="nt">&lt;/fop&gt;</span>
 <span class="nt">&lt;/target&gt;</span>
@@ -488,7 +488,7 @@ $(document).ready(function () {
 
 <p>The following example transforms and converts a single XML and XSLT file to an AFP document:</p>
 <div class="codehilite"><pre><span class="nt">&lt;target</span> <span class="na">name=</span><span class="s">&quot;generate-afp-from-transform&quot;</span> <span class="na">description=</span><span class="s">&quot;Generates a single AFP file from an XSLT stylesheet&quot;</span><span class="nt">&gt;</span>
-   <span class="nt">&lt;fop</span> <span class="na">format=</span><span class="s">&quot;application/x-afp&quot;</span> 
+   <span class="nt">&lt;fop</span> <span class="na">format=</span><span class="s">&quot;application/x-afp&quot;</span>
         <span class="na">xmlfile=</span><span class="s">&quot;c:\working\foDirectory\Document.xml&quot;</span>
         <span class="na">xsltfile=</span><span class="s">&quot;c:\working\foDirectory\Document.xslt&quot;</span>
         <span class="na">outfile=</span><span class="s">&quot;c:\working\afpDirectory\Document.afp&quot;</span> <span class="nt">/&gt;</span>
@@ -498,11 +498,11 @@ $(document).ready(function () {
 
 <p>This example transforms and converts all XML files within an entire directory to PostScript:</p>
 <div class="codehilite"><pre><span class="nt">&lt;target</span> <span class="na">name=</span><span class="s">&quot;generate-multiple-ps-from-transform&quot;</span> <span class="na">description=</span><span class="s">&quot;Generates multiple PostScript files using an XSLT stylesheet&quot;</span><span class="nt">&gt;</span>
-   <span class="nt">&lt;fop</span> <span class="na">format=</span><span class="s">&quot;application/postscript&quot;</span> 
+   <span class="nt">&lt;fop</span> <span class="na">format=</span><span class="s">&quot;application/postscript&quot;</span>
         <span class="na">xsltfile=</span><span class="s">&quot;c:\working\foDirectory\Document.xslt&quot;</span>
-        <span class="na">outdir=</span><span class="s">&quot;</span><span class="cp">${</span><span class="n">build</span><span class="o">.</span><span class="n">dir</span><span class="cp">}</span><span class="s">&quot;</span> <span class="na">messagelevel=</span><span class="s">&quot;debug&quot;</span><span class="nt">&gt;</span>
-        <span class="nt">&lt;fileset</span> <span class="na">dir=</span><span class="s">&quot;</span><span class="cp">${</span><span class="n">test</span><span class="o">.</span><span class="n">dir</span><span class="cp">}</span><span class="s">&quot;</span><span class="nt">&gt;</span>
-           <span class="nt">&lt;include</span> <span class="na">name=</span><span class="s">&quot;*.xml&quot;/</span><span class="nt">&gt;</span>
+        <span class="na">outdir=</span><span class="s">&quot;${build.dir}&quot;</span> <span class="na">messagelevel=</span><span class="s">&quot;debug&quot;</span><span class="nt">&gt;</span>
+        <span class="nt">&lt;fileset</span> <span class="na">dir=</span><span class="s">&quot;${test.dir}&quot;</span><span class="nt">&gt;</span>
+           <span class="nt">&lt;include</span> <span class="na">name=</span><span class="s">&quot;*.xml&quot;</span><span class="nt">/&gt;</span>
         <span class="nt">&lt;/fileset&gt;</span>
    <span class="nt">&lt;/fop&gt;</span>
 <span class="nt">&lt;/target&gt;</span>

Modified: websites/staging/xmlgraphics/trunk/content/fop/1.0/configuration.html
==============================================================================
--- websites/staging/xmlgraphics/trunk/content/fop/1.0/configuration.html (original)
+++ websites/staging/xmlgraphics/trunk/content/fop/1.0/configuration.html Tue Dec  4 15:59:34 2012
@@ -497,26 +497,26 @@ $(document).ready(function () {
 <h2 id="renderer-configuration-wzxhzdk19wzxhzdk20">Renderer configuration <a id="renderers"></a></h2>
 <p>Each Renderer has its own configuration section which is identified by the MIME type the Renderer is written for, ex. "application/pdf" for the PDF Renderer.</p>
 <p>The configuration for the PDF Renderer could look like this:</p>
-<div class="codehilite"><pre>  <span class="nt">&lt;renderers&gt;</span>
-    <span class="nt">&lt;renderer</span> <span class="na">mime=</span><span class="s">&quot;application/pdf&quot;</span><span class="nt">&gt;</span>
-      <span class="nt">&lt;filterList&gt;</span>
-        <span class="c">&lt;!-- provides compression using zlib flate (default is on) --&gt;</span>
-        <span class="nt">&lt;value&gt;</span>flate<span class="nt">&lt;/value&gt;</span>
-      <span class="nt">&lt;/filterList&gt;</span>
-      <span class="nt">&lt;fonts&gt;</span>
-        <span class="nt">&lt;font</span> <span class="na">metrics-url=</span><span class="s">&quot;arial.xml&quot;</span> <span class="na">kerning=</span><span class="s">&quot;yes&quot;</span> <span class="na">embed-url=</span><span class="s">&quot;arial.ttf&quot;</span><span class="nt">&gt;</span>
-          <span class="nt">&lt;font-triplet</span> <span class="na">name=</span><span class="s">&quot;Arial&quot;</span> <span class="na">style=</span><span class="s">&quot;normal&quot;</span> <span class="na">weight=</span><span class="s">&quot;normal&quot;</span><span class="nt">/&gt;</span>
-          <span class="nt">&lt;font-triplet</span> <span class="na">name=</span><span class="s">&quot;ArialMT&quot;</span> <span class="na">style=</span><span class="s">&quot;normal&quot;</span> <span class="na">weight=</span><span class="s">&quot;normal&quot;</span><span class="nt">/&gt;</span>
-        <span class="nt">&lt;/font&gt;</span>
-        <span class="nt">&lt;font</span> <span class="na">metrics-url=</span><span class="s">&quot;arialb.xml&quot;</span> <span class="na">kerning=</span><span class="s">&quot;yes&quot;</span> <span class="na">embed-url=</span><span class="s">&quot;arialb.ttf&quot;</span><span class="nt">&gt;</span>
-          <span class="nt">&lt;font-triplet</span> <span class="na">name=</span><span class="s">&quot;Arial&quot;</span> <span class="na">style=</span><span class="s">&quot;normal&quot;</span> <span class="na">weight=</span><span class="s">&quot;bold&quot;</span><span class="nt">/&gt;</span>
-          <span class="nt">&lt;font-triplet</span> <span class="na">name=</span><span class="s">&quot;ArialMT&quot;</span> <span class="na">style=</span><span class="s">&quot;normal&quot;</span> <span class="na">weight=</span><span class="s">&quot;bold&quot;</span><span class="nt">/&gt;</span>
-        <span class="nt">&lt;/font&gt;</span>
-      <span class="nt">&lt;/fonts&gt;</span>
-    <span class="nt">&lt;/renderer&gt;</span>
+<div class="codehilite"><pre><span class="nt">&lt;renderers&gt;</span>
+  <span class="nt">&lt;renderer</span> <span class="na">mime=</span><span class="s">&quot;application/pdf&quot;</span><span class="nt">&gt;</span>
+    <span class="nt">&lt;filterList&gt;</span>
+      <span class="c">&lt;!-- provides compression using zlib flate (default is on) --&gt;</span>
+      <span class="nt">&lt;value&gt;</span>flate<span class="nt">&lt;/value&gt;</span>
+    <span class="nt">&lt;/filterList&gt;</span>
+    <span class="nt">&lt;fonts&gt;</span>
+      <span class="nt">&lt;font</span> <span class="na">metrics-url=</span><span class="s">&quot;arial.xml&quot;</span> <span class="na">kerning=</span><span class="s">&quot;yes&quot;</span> <span class="na">embed-url=</span><span class="s">&quot;arial.ttf&quot;</span><span class="nt">&gt;</span>
+        <span class="nt">&lt;font-triplet</span> <span class="na">name=</span><span class="s">&quot;Arial&quot;</span> <span class="na">style=</span><span class="s">&quot;normal&quot;</span> <span class="na">weight=</span><span class="s">&quot;normal&quot;</span><span class="nt">/&gt;</span>
+        <span class="nt">&lt;font-triplet</span> <span class="na">name=</span><span class="s">&quot;ArialMT&quot;</span> <span class="na">style=</span><span class="s">&quot;normal&quot;</span> <span class="na">weight=</span><span class="s">&quot;normal&quot;</span><span class="nt">/&gt;</span>
+      <span class="nt">&lt;/font&gt;</span>
+      <span class="nt">&lt;font</span> <span class="na">metrics-url=</span><span class="s">&quot;arialb.xml&quot;</span> <span class="na">kerning=</span><span class="s">&quot;yes&quot;</span> <span class="na">embed-url=</span><span class="s">&quot;arialb.ttf&quot;</span><span class="nt">&gt;</span>
+        <span class="nt">&lt;font-triplet</span> <span class="na">name=</span><span class="s">&quot;Arial&quot;</span> <span class="na">style=</span><span class="s">&quot;normal&quot;</span> <span class="na">weight=</span><span class="s">&quot;bold&quot;</span><span class="nt">/&gt;</span>
+        <span class="nt">&lt;font-triplet</span> <span class="na">name=</span><span class="s">&quot;ArialMT&quot;</span> <span class="na">style=</span><span class="s">&quot;normal&quot;</span> <span class="na">weight=</span><span class="s">&quot;bold&quot;</span><span class="nt">/&gt;</span>
+      <span class="nt">&lt;/font&gt;</span>
+    <span class="nt">&lt;/fonts&gt;</span>
+  <span class="nt">&lt;/renderer&gt;</span>
 
-    <span class="nt">&lt;renderer</span> <span class="na">mime=</span><span class="s">&quot;application/postscript&quot;</span><span class="nt">&gt;</span>
-    <span class="c">&lt;!-- etc. etc..... --&gt;</span>
+  <span class="nt">&lt;renderer</span> <span class="na">mime=</span><span class="s">&quot;application/postscript&quot;</span><span class="nt">&gt;</span>
+  <span class="c">&lt;!-- etc. etc..... --&gt;</span>
 </pre></div>
 
 
@@ -628,7 +628,8 @@ $(document).ready(function () {
 </li>
 <li>
 <p>The FOP distribution contains a schema for configuration files, at src/foschema/fop-configuration.xsd. Did you validate your configuration file against it? Add the following schema location to the <code>schema</code> element:</p>
-<p><fop
+<p>:::xml
+<fop
     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
     xsi:noNamespaceSchemaLocation=
     "http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/foschema/fop-configuration.xsd?view=co"></p>

Modified: websites/staging/xmlgraphics/trunk/content/fop/1.0/embedding.html
==============================================================================
--- websites/staging/xmlgraphics/trunk/content/fop/1.0/embedding.html (original)
+++ websites/staging/xmlgraphics/trunk/content/fop/1.0/embedding.html Tue Dec  4 15:59:34 2012
@@ -350,42 +350,42 @@ We recently changed FOP's outer API to w
 <h2 id="basic-usage-pattern-wzxhzdk28wzxhzdk29">Basic Usage Pattern <a id="basics"></a></h2>
 <p>Apache FOP relies heavily on JAXP. It uses SAX events exclusively to receive the XSL-FO input document. It is therefore a good idea that you know a few things about JAXP (which is a good skill anyway). Let's look at the basic usage pattern for FOP...</p>
 <p>Here is the basic pattern to render an XSL-FO file to PDF:</p>
-<div class="codehilite"><pre><span class="nb">import</span> <span class="n">org</span><span class="o">.</span><span class="n">apache</span><span class="o">.</span><span class="n">fop</span><span class="o">.</span><span class="n">apps</span><span class="o">.</span><span class="n">FopFactory</span><span class="p">;</span>
-<span class="nb">import</span> <span class="n">org</span><span class="o">.</span><span class="n">apache</span><span class="o">.</span><span class="n">fop</span><span class="o">.</span><span class="n">apps</span><span class="o">.</span><span class="n">Fop</span><span class="p">;</span>
-<span class="nb">import</span> <span class="n">org</span><span class="o">.</span><span class="n">apache</span><span class="o">.</span><span class="n">fop</span><span class="o">.</span><span class="n">apps</span><span class="o">.</span><span class="n">MimeConstants</span><span class="p">;</span>
-
-<span class="sr">/*..*/</span>
-
-<span class="sr">//</span> <span class="n">Step</span> <span class="mi">1</span><span class="p">:</span> <span class="n">Construct</span> <span class="n">a</span> <span class="n">FopFactory</span>
-<span class="sr">//</span> <span class="p">(</span><span class="n">reuse</span> <span class="k">if</span> <span class="n">you</span> <span class="n">plan</span> <span class="n">to</span> <span class="n">render</span> <span class="n">multiple</span> <span class="n">documents</span><span class="o">!</span><span class="p">)</span>
-<span class="n">FopFactory</span> <span class="n">fopFactory</span> <span class="o">=</span> <span class="n">FopFactory</span><span class="o">.</span><span class="n">newInstance</span><span class="p">();</span>
-
-<span class="sr">//</span> <span class="n">Step</span> <span class="mi">2</span><span class="p">:</span> <span class="n">Set</span> <span class="n">up</span> <span class="n">output</span> <span class="n">stream</span><span class="o">.</span>
-<span class="sr">//</span> <span class="n">Note:</span> <span class="n">Using</span> <span class="n">BufferedOutputStream</span> <span class="k">for</span> <span class="n">performance</span> <span class="n">reasons</span> <span class="p">(</span><span class="n">helpful</span> <span class="n">with</span> <span class="n">FileOutputStreams</span><span class="p">)</span><span class="o">.</span>
-<span class="n">OutputStream</span> <span class="n">out</span> <span class="o">=</span> <span class="k">new</span> <span class="n">BufferedOutputStream</span><span class="p">(</span><span class="k">new</span> <span class="n">FileOutputStream</span><span class="p">(</span><span class="k">new</span> <span class="n">File</span><span class="p">(</span><span class="s">&quot;C:/Temp/myfile.pdf&quot;</span><span class="p">)));</span>
-
-<span class="n">try</span> <span class="p">{</span>
-  <span class="sr">//</span> <span class="n">Step</span> <span class="mi">3</span><span class="p">:</span> <span class="n">Construct</span> <span class="n">fop</span> <span class="n">with</span> <span class="n">desired</span> <span class="n">output</span> <span class="nb">format</span>
-  <span class="n">Fop</span> <span class="n">fop</span> <span class="o">=</span> <span class="n">fopFactory</span><span class="o">.</span><span class="n">newFop</span><span class="p">(</span><span class="n">MimeConstants</span><span class="o">.</span><span class="n">MIME_PDF</span><span class="p">,</span> <span class="n">out</span><span class="p">);</span>
-
-  <span class="sr">//</span> <span class="n">Step</span> <span class="mi">4</span><span class="p">:</span> <span class="n">Setup</span> <span class="n">JAXP</span> <span class="n">using</span> <span class="n">identity</span> <span class="n">transformer</span>
-  <span class="n">TransformerFactory</span> <span class="n">factory</span> <span class="o">=</span> <span class="n">TransformerFactory</span><span class="o">.</span><span class="n">newInstance</span><span class="p">();</span>
-  <span class="n">Transformer</span> <span class="n">transformer</span> <span class="o">=</span> <span class="n">factory</span><span class="o">.</span><span class="n">newTransformer</span><span class="p">();</span> <span class="sr">//</span> <span class="n">identity</span> <span class="n">transformer</span>
-
-  <span class="sr">//</span> <span class="n">Step</span> <span class="mi">5</span><span class="p">:</span> <span class="n">Setup</span> <span class="n">input</span> <span class="ow">and</span> <span class="n">output</span> <span class="k">for</span> <span class="n">XSLT</span> <span class="n">transformation</span>
-  <span class="sr">//</span> <span class="n">Setup</span> <span class="n">input</span> <span class="n">stream</span>
-  <span class="n">Source</span> <span class="n">src</span> <span class="o">=</span> <span class="k">new</span> <span class="n">StreamSource</span><span class="p">(</span><span class="k">new</span> <span class="n">File</span><span class="p">(</span><span class="s">&quot;C:/Temp/myfile.fo&quot;</span><span class="p">));</span>
-
-  <span class="sr">//</span> <span class="n">Resulting</span> <span class="n">SAX</span> <span class="n">events</span> <span class="p">(</span><span class="n">the</span> <span class="n">generated</span> <span class="n">FO</span><span class="p">)</span> <span class="n">must</span> <span class="n">be</span> <span class="n">piped</span> <span class="n">through</span> <span class="n">to</span> <span class="n">FOP</span>
-  <span class="n">Result</span> <span class="n">res</span> <span class="o">=</span> <span class="k">new</span> <span class="n">SAXResult</span><span class="p">(</span><span class="n">fop</span><span class="o">.</span><span class="n">getDefaultHandler</span><span class="p">());</span>
-
-  <span class="sr">//</span> <span class="n">Step</span> <span class="mi">6</span><span class="p">:</span> <span class="n">Start</span> <span class="n">XSLT</span> <span class="n">transformation</span> <span class="ow">and</span> <span class="n">FOP</span> <span class="n">processing</span>
-  <span class="n">transformer</span><span class="o">.</span><span class="n">transform</span><span class="p">(</span><span class="n">src</span><span class="p">,</span> <span class="n">res</span><span class="p">);</span>
-
-<span class="p">}</span> <span class="n">finally</span> <span class="p">{</span>
-  <span class="sr">//</span><span class="n">Clean</span><span class="o">-</span><span class="n">up</span>
-  <span class="n">out</span><span class="o">.</span><span class="nb">close</span><span class="p">();</span>
-<span class="p">}</span>
+<div class="codehilite"><pre><span class="kn">import</span> <span class="nn">org.apache.fop.apps.FopFactory</span><span class="o">;</span>
+<span class="kn">import</span> <span class="nn">org.apache.fop.apps.Fop</span><span class="o">;</span>
+<span class="kn">import</span> <span class="nn">org.apache.fop.apps.MimeConstants</span><span class="o">;</span>
+
+<span class="cm">/*..*/</span>
+
+<span class="c1">// Step 1: Construct a FopFactory</span>
+<span class="c1">// (reuse if you plan to render multiple documents!)</span>
+<span class="n">FopFactory</span> <span class="n">fopFactory</span> <span class="o">=</span> <span class="n">FopFactory</span><span class="o">.</span><span class="na">newInstance</span><span class="o">();</span>
+
+<span class="c1">// Step 2: Set up output stream.</span>
+<span class="c1">// Note: Using BufferedOutputStream for performance reasons (helpful with FileOutputStreams).</span>
+<span class="n">OutputStream</span> <span class="n">out</span> <span class="o">=</span> <span class="k">new</span> <span class="n">BufferedOutputStream</span><span class="o">(</span><span class="k">new</span> <span class="n">FileOutputStream</span><span class="o">(</span><span class="k">new</span> <span class="n">File</span><span class="o">(</span><span class="s">&quot;C:/Temp/myfile.pdf&quot;</span><span class="o">)));</span>
+
+<span class="k">try</span> <span class="o">{</span>
+  <span class="c1">// Step 3: Construct fop with desired output format</span>
+  <span class="n">Fop</span> <span class="n">fop</span> <span class="o">=</span> <span class="n">fopFactory</span><span class="o">.</span><span class="na">newFop</span><span class="o">(</span><span class="n">MimeConstants</span><span class="o">.</span><span class="na">MIME_PDF</span><span class="o">,</span> <span class="n">out</span><span class="o">);</span>
+
+  <span class="c1">// Step 4: Setup JAXP using identity transformer</span>
+  <span class="n">TransformerFactory</span> <span class="n">factory</span> <span class="o">=</span> <span class="n">TransformerFactory</span><span class="o">.</span><span class="na">newInstance</span><span class="o">();</span>
+  <span class="n">Transformer</span> <span class="n">transformer</span> <span class="o">=</span> <span class="n">factory</span><span class="o">.</span><span class="na">newTransformer</span><span class="o">();</span> <span class="c1">// identity transformer</span>
+
+  <span class="c1">// Step 5: Setup input and output for XSLT transformation</span>
+  <span class="c1">// Setup input stream</span>
+  <span class="n">Source</span> <span class="n">src</span> <span class="o">=</span> <span class="k">new</span> <span class="n">StreamSource</span><span class="o">(</span><span class="k">new</span> <span class="n">File</span><span class="o">(</span><span class="s">&quot;C:/Temp/myfile.fo&quot;</span><span class="o">));</span>
+
+  <span class="c1">// Resulting SAX events (the generated FO) must be piped through to FOP</span>
+  <span class="n">Result</span> <span class="n">res</span> <span class="o">=</span> <span class="k">new</span> <span class="n">SAXResult</span><span class="o">(</span><span class="n">fop</span><span class="o">.</span><span class="na">getDefaultHandler</span><span class="o">());</span>
+
+  <span class="c1">// Step 6: Start XSLT transformation and FOP processing</span>
+  <span class="n">transformer</span><span class="o">.</span><span class="na">transform</span><span class="o">(</span><span class="n">src</span><span class="o">,</span> <span class="n">res</span><span class="o">);</span>
+
+<span class="o">}</span> <span class="k">finally</span> <span class="o">{</span>
+  <span class="c1">//Clean-up</span>
+  <span class="n">out</span><span class="o">.</span><span class="na">close</span><span class="o">();</span>
+<span class="o">}</span>
 </pre></div>
 
 
@@ -511,11 +511,11 @@ Set a <strong>URIResolver</strong> for c
 <p>Both the FopFactory and the FOUserAgent have a method to set a URIResolver. The URIResolver on the FopFactory is primarily used to resolve URIs on factory-level (hyphenation patterns, for example) and it is always used if no other URIResolver (for example on the FOUserAgent) resolved the URI first.</p>
 <h3 id="customizing-the-user-agent-wzxhzdk42wzxhzdk43">Customizing the User Agent <a id="user-agent"></a></h3>
 <p>The user agent is the entity that allows you to interact with a single rendering run, i.e. the processing of a single document. If you wish to customize the user agent's behaviour, the first step is to create your own instance of FOUserAgent using the appropriate factory method on FopFactory and pass that to the factory method that will create a new Fop instance:</p>
-<div class="codehilite"><pre><span class="n">FopFactory</span> <span class="n">fopFactory</span> <span class="o">=</span> <span class="n">FopFactory</span><span class="o">.</span><span class="n">newInstance</span><span class="p">();</span> <span class="sr">//</span> <span class="n">Reuse</span> <span class="n">the</span> <span class="n">FopFactory</span> <span class="k">if</span> <span class="n">possible</span><span class="o">!</span>
-<span class="sr">//</span> <span class="k">do</span> <span class="n">the</span> <span class="n">following</span> <span class="k">for</span> <span class="nb">each</span> <span class="k">new</span> <span class="n">rendering</span> <span class="n">run</span>
-<span class="n">FOUserAgent</span> <span class="n">userAgent</span> <span class="o">=</span> <span class="n">fopFactory</span><span class="o">.</span><span class="n">newFOUserAgent</span><span class="p">();</span>
-<span class="sr">//</span> <span class="n">customize</span> <span class="n">userAgent</span>
-<span class="n">Fop</span> <span class="n">fop</span> <span class="o">=</span> <span class="n">fopFactory</span><span class="o">.</span><span class="n">newFop</span><span class="p">(</span><span class="n">MimeConstants</span><span class="o">.</span><span class="n">MIME_POSTSCRIPT</span><span class="p">,</span> <span class="n">userAgent</span><span class="p">,</span> <span class="n">out</span><span class="p">);</span>
+<div class="codehilite"><pre><span class="n">FopFactory</span> <span class="n">fopFactory</span> <span class="o">=</span> <span class="n">FopFactory</span><span class="o">.</span><span class="na">newInstance</span><span class="o">();</span> <span class="c1">// Reuse the FopFactory if possible!</span>
+<span class="c1">// do the following for each new rendering run</span>
+<span class="n">FOUserAgent</span> <span class="n">userAgent</span> <span class="o">=</span> <span class="n">fopFactory</span><span class="o">.</span><span class="na">newFOUserAgent</span><span class="o">();</span>
+<span class="c1">// customize userAgent</span>
+<span class="n">Fop</span> <span class="n">fop</span> <span class="o">=</span> <span class="n">fopFactory</span><span class="o">.</span><span class="na">newFop</span><span class="o">(</span><span class="n">MimeConstants</span><span class="o">.</span><span class="na">MIME_POSTSCRIPT</span><span class="o">,</span> <span class="n">userAgent</span><span class="o">,</span> <span class="n">out</span><span class="o">);</span>
 </pre></div>
 
 
@@ -589,18 +589,18 @@ Set a <strong>URIResolver</strong> for c
 <p>Both the FopFactory and the FOUserAgent have a method to set a URIResolver. The URIResolver on the FOUserAgent is used for resolving URIs which are document-related. If it's not set or cannot resolve a URI, the URIResolver from the FopFactory is used. You should not reuse an FOUserAgent instance between FOP rendering runs although you can. Especially in multi-threaded environment, this is a bad idea.</p>
 <h2 id="using-a-configuration-file-wzxhzdk44wzxhzdk45">Using a Configuration File <a id="config-external"></a></h2>
 <p>Instead of setting the parameters manually in code as shown above you can also set many values from an XML configuration file:</p>
-<div class="codehilite"><pre><span class="nb">import</span> <span class="n">org</span><span class="o">.</span><span class="n">apache</span><span class="o">.</span><span class="n">avalon</span><span class="o">.</span><span class="n">framework</span><span class="o">.</span><span class="n">configuration</span><span class="o">.</span><span class="n">Configuration</span><span class="p">;</span>
-<span class="nb">import</span> <span class="n">org</span><span class="o">.</span><span class="n">apache</span><span class="o">.</span><span class="n">avalon</span><span class="o">.</span><span class="n">framework</span><span class="o">.</span><span class="n">configuration</span><span class="o">.</span><span class="n">DefaultConfigurationBuilder</span><span class="p">;</span>
+<div class="codehilite"><pre><span class="kn">import</span> <span class="nn">org.apache.avalon.framework.configuration.Configuration</span><span class="o">;</span>
+<span class="kn">import</span> <span class="nn">org.apache.avalon.framework.configuration.DefaultConfigurationBuilder</span><span class="o">;</span>
 
-<span class="sr">/*..*/</span>
+<span class="cm">/*..*/</span>
 
-<span class="n">DefaultConfigurationBuilder</span> <span class="n">cfgBuilder</span> <span class="o">=</span> <span class="k">new</span> <span class="n">DefaultConfigurationBuilder</span><span class="p">();</span>
-<span class="n">Configuration</span> <span class="n">cfg</span> <span class="o">=</span> <span class="n">cfgBuilder</span><span class="o">.</span><span class="n">buildFromFile</span><span class="p">(</span><span class="k">new</span> <span class="n">File</span><span class="p">(</span><span class="s">&quot;C:/Temp/mycfg.xml&quot;</span><span class="p">));</span>
-<span class="n">fopFactory</span><span class="o">.</span><span class="n">setUserConfig</span><span class="p">(</span><span class="n">cfg</span><span class="p">);</span>
+<span class="n">DefaultConfigurationBuilder</span> <span class="n">cfgBuilder</span> <span class="o">=</span> <span class="k">new</span> <span class="n">DefaultConfigurationBuilder</span><span class="o">();</span>
+<span class="n">Configuration</span> <span class="n">cfg</span> <span class="o">=</span> <span class="n">cfgBuilder</span><span class="o">.</span><span class="na">buildFromFile</span><span class="o">(</span><span class="k">new</span> <span class="n">File</span><span class="o">(</span><span class="s">&quot;C:/Temp/mycfg.xml&quot;</span><span class="o">));</span>
+<span class="n">fopFactory</span><span class="o">.</span><span class="na">setUserConfig</span><span class="o">(</span><span class="n">cfg</span><span class="o">);</span>
 
-<span class="sr">/* ..or.. */</span>
+<span class="cm">/* ..or.. */</span>
 
-<span class="n">fopFactory</span><span class="o">.</span><span class="n">setUserConfig</span><span class="p">(</span><span class="k">new</span> <span class="n">File</span><span class="p">(</span><span class="s">&quot;C:/Temp/mycfg.xml&quot;</span><span class="p">));</span>
+<span class="n">fopFactory</span><span class="o">.</span><span class="na">setUserConfig</span><span class="o">(</span><span class="k">new</span> <span class="n">File</span><span class="o">(</span><span class="s">&quot;C:/Temp/mycfg.xml&quot;</span><span class="o">));</span>
 </pre></div>
 
 



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: commits-help@xmlgraphics.apache.org


Mime
View raw message