title: Getting 'WrappedRuntimeException' when using XSL-FO in an Xpage
body: <p>I am trying to create a PDF from the contents of an xpage.  I am following the format that Paul Calhoun used in Notes in 9 #102.   I am able to create PDF's for views, but having trouble creating one for a document.  I do not think the error is in Paul's code so I am not including it here, although I can if need be.</p>
  
  <p>To generate the XML to display I use the generateXML() method of the document class in java.  I get a handle to the backend document and then return the XML.  The XML appears well formed, the top level tab is <code>&lt;document&gt;</code>.  I pass this XML to the transformer which is using Apache FOP.  All of my code is contained in the beforeRenderResponse of an xAgent.</p>
  
  <p>The XSL stylesheet that I am using is a stripped down version to just get a proof of concept to work.  I am going to include it, because the problem likely resides with this code.  I am totally new to XSL. </p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  
  &lt;xsl:stylesheet
      version="1.1"
      xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
      xmlns:fo="http://www.w3.org/1999/XSL/Format"
      exclude-result-prefixes="fo"&gt;
      &lt;xsl:output
          method="xml"
          version="1.0"
          omit-xml-declaration="no"
          indent="yes" /&gt;
      &lt;xsl:param
          name="versionParam"
          select="'1.0'" /&gt;
  
      &lt;xsl:template match="document"&gt;
          &lt;fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format"&gt;
              &lt;fo:layout-master-set&gt;
                  &lt;fo:simple-page-master
                      master-name="outpage"
                      page-height="11in"
                      page-width="8.5in"
                      margin-top="1in"
                      margin-bottom="1in"
                      margin-left="1in"
                      margin-right="1in"&gt;
                      &lt;fo:region-body /&gt;
                  &lt;/fo:simple-page-master&gt;
              &lt;/fo:layout-master-set&gt;
              &lt;fo:page-sequence master-reference="A4"&gt;
                  &lt;fo:block
                          font-size="16pt"
                          font-weight="bold"
                          space-after="5mm"&gt;
                          Apache FOP Proof of Concept.
                      &lt;/fo:block&gt;
              &lt;/fo:page-sequence&gt;
              &lt;/fo:root&gt;
      &lt;/xsl:template&gt;
  &lt;/xsl:stylesheet&gt;
  </code></pre>
  
  <p>In the log file I get the message:  </p>
  
  <pre><code>FATAL ERROR:  'com.ibm.xtq.common.utils.WrappedRuntimeException: D:\Program Files\IBM\Domino\&lt;document form='PO'&gt;
  </code></pre>
  
  <p>The error echos the entire XML in the log that it is trying to transform and ends with:</p>
  
  <pre><code> (The filename, directory name, or volume label syntax is incorrect.)'
  </code></pre>
  
  <p>Notice that Domino is trying to include the XML in a path.  I know this is wrong, but don't know what to do to fix it.</p>
  
  <p>EDIT: This is the Java class that runs the transformation.  This code is from Paul Calhoun's demo.</p>
  
  <pre><code>import java.io.OutputStream;
  import javax.xml.transform.Result;
  import javax.xml.transform.Source;
  import javax.xml.transform.Transformer;
  import javax.xml.transform.TransformerFactory;
  import javax.xml.transform.sax.SAXResult;
  import javax.xml.transform.stream.StreamSource;
  
  import org.apache.fop.apps.FOUserAgent;
  import org.apache.fop.apps.Fop;
  import org.apache.fop.apps.FopFactory;
  
  public class DominoXMLFO2PDF {
      public static void getPDF(OutputStream pdfout,String xml,String xslt, Boolean authReq, String usernamepass) {
          try {
              //System.out.println("Transforming...");
              Source xmlSource,xsltSource;  //Source xmlSource = new StreamSource("http://localhost/APCC.nsf/Main?ReadViewEntries&amp;count=999&amp;ResortAscending=2");
              xmlSource = new StreamSource(xml);  //Source xsltSource = new StreamSource("http://localhost/APCC.nsf/viewdata.xsl");
              xsltSource = new StreamSource(xslt);// configure fopFactory as desired              
  
              final FopFactory fopFactory = FopFactory.newInstance();
  
              FOUserAgent foUserAgent = fopFactory.newFOUserAgent();
              // configure foUserAgent as desired
  
              // Setup output
              // OutputStream out = pdfout;
              // out = new java.io.BufferedOutputStream(out);
  
              try {
                  // Construct fop with desired output format
                  Fop fop = fopFactory.newFop(org.apache.xmlgraphics.util.MimeConstants.MIME_PDF,foUserAgent, pdfout);
                  // Setup XSLT
                  TransformerFactory factory = TransformerFactory.newInstance();
                  Transformer transformer = factory.newTransformer(xsltSource);
                  //transformer.setParameter("versionParam", "Company List"); // Set the value of a &lt;param&gt; in the stylesheet
                  Source src = xmlSource; // Setup input for XSLT transformation
                  Result res = new SAXResult(fop.getDefaultHandler()); // Resulting SAX events (the generated FO) must be piped through to FOP
                  transformer.transform(src, res); // Start XSLT transformation and FOP processing
  
              } catch (Exception e) {
  
              } finally {
              }
          } catch (Exception e) {
              e.printStackTrace(System.err);
          }
      }
  }
  </code></pre>
  
  <p>This code is called in the xAgent using this line:</p>
  
  <pre><code>var retOutput = jce.getPDF(pageOutput, xmlsource, xsltsource, authReq, usernamepass);
  </code></pre>
  
  <p>The xmlsource is set with this line where the method returns XML using Document.generateXML():</p>
  
  <pre><code>var xmlsource = statusBean.generateXML(POdata, sessionScope.unidPDF);
  </code></pre>