Loading ...
Sorry, an error occurred while loading the content.

4917Re: [XSL-FO] Applying a XML transformation before creating the PDF (FOP)

Expand Messages
  • J.Pietschmann
    Feb 10, 2004
    • 0 Attachment
      armin.keyvanloo@... wrote:
      > I need to apply a transformation to the source XML to strip out some of the
      > elements from it before feeding it into FOP to create the PDF.
      > I don't know how to chain the XSL's for fop. I tried using Saxon's
      > next-in-chain attribute like this(transformer.xsl) by having 2 XSL's one is
      > transform and one to create the PDF. I called the transformer XSL 1st (in
      > the source XSL on FOP) and then use the next-in-chain to trigger the PDF
      > generation:

      First, check whether FOP really uses Saxon. If you use JDK 1.4,
      it is more likely you are actually using the Xalan included in
      the JDK, which wont recognize the extension.

      If you really use Saxon, it is quite possible that the method
      how the PDF renderer is docked onto the XSLT transformer also
      ignores the required second transformation. Some possible
      approaches:
      1. Do both transformations in the same style sheet. Save the
      result from the first transformation into a variable, and
      apply the second. Use modes for the tempaltes:
      <xsl:stylesheet ...>
      <xsl:template match="/">
      <!-- start here -->
      <xsl:variable name="pass-1-result">
      <xsl:apply-templates select="." mode="pass1"/>
      </xsl:variable>
      <xsl:apply-templates select="saxon:node-set($pass-1-result)"
      mode="pass2"/>
      </xsl:template>
      <xsl:template match="/" mode="pass1">
      .... pass 1 stuff ...
      </xsl:template>
      <xsl:template match="/" mode="pass2">
      <fo:root...
      ...
      </xsl:template>
      You'll have to declare the saxon namespace in order to get the
      node-set() extension function working.
      2. Use Saxon's FOP chaining in the second XSLT. Check the Saxon
      documentation and perhaps the Saxon user list for details.
      3. Write a Java wrapper for both the transformations and FOP.
      Start here:
      http://xml.apache.org/fop/embedding.html#ExampleXML2PDF
      and use the link to the source code.
      Adding another transformation is a bit tricky, you'll have to
      check the documentation for SAXTransformerHandler and
      SAXTransformerFactory because one of the transformations has to
      be created as SAX filter.
      4. Use Cocoon:
      http://cocoon.apache.org

      J.Pietschmann
    • Show all 5 messages in this topic