You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Benedikt Eric Heinen <be...@icemark.ch> on 2000/11/05 18:41:16 UTC

fop-problems...

First things first, I'd sure like to join in the chorus of those
that go "Cocoon rocks!"  :)

Still, I have some problems, maybe you can help me figure out what
goes wrong here.

I tried rebuilding my regular homepage using cocoon; I had the
following goals in mind:

  - turn the whole page into a single document, of which only parts
    (the original individual html pages) get displayed
	-> succeeded
  - my homepage is bilingual, it should be possible to select the 
    language from within the browser
	-> succeeded
  - I would like to be able to generate a "printer friendly"
    version from it, meaning the whole page complex in the XML
    input written to a single PDF file.
	-> PART success... :(


I'd be grateful if someone could help out with my problems:

 - I am using fop 0.13 at the moment (though I noticed that there
   is a newer version), but I can't get it to incorporate an image
   into the PDF.

   HTML-xsl:
	  <xsl:template match="thumbnail">
	   <a>
	     <xsl:attribute name="href"><xsl:value-of select="@big" /></xsl:attribute>
	     <img>
	       <xsl:attribute name="src"><xsl:value-of select="@small" /></xsl:attribute>
	       <xsl:attribute name="alt"><xsl:value-of select="@alt" /></xsl:attribute>
	       <xsl:if test="@border">
	         <xsl:attribute name="border">
	           <xsl:value-of select="@border" />
	         </xsl:attribute>
	       </xsl:if>
	     </img>
	     <br />
	     <xsl:choose>
	       <xsl:when test="$plang='de'"><smaller><i>Click f&ue;r gr&oe;sseres Bild</i></smaller></xsl:when>
	       <xsl:when test="$plang='en'"><smaller><i>Click on thumbnail to enlarge</i></smaller></xsl:when>
	       <xsl:otherwise><smaller><i>Click on thumbnail to enlarge</i></smaller></xsl:otherwise>
	     </xsl:choose>
	   </a>
	  </xsl:template>

   PDF-xsl:

	  <xsl:template match="thumbnail">
	    <fo:external-graphic src="{@big}" />
	  </xsl:template>


   XML input:

	  <center lang="de">
	    <thumbnail small="../images/me1.jpg" big="../images/me2.jpg" border="0" alt="[Ja - das bin wohl ich!]" />
	  </center>
	  <center lang="en">
	    <thumbnail small="../images/me1.jpg" big="../images/me2.jpg" border="0" alt="[Me!]" />
	  </center>


   The html-output works like a charm, no trouble there. In the PDF
   output, the picture is just missing. I also tried supplying an
   absolute filename for the picture, to make sure it's not just an
   access problem. Still - no luck. The picture is just missing and
   that's it.


 - As I pointed out, I know, that there is a fop-0.14 now, so I
   tried that one, but then I won't even get as far as generating 
   a pdf:

                   Error found handling the request.

    java.lang.NullPointerException
       at org.apache.fop.fo.FOTreeBuilder.startElement(Compiled Code)
       at org.apache.fop.apps.Driver.buildFOTree(Compiled Code)
       at org.apache.cocoon.formatter.FO2PDFFormatter.format(Compiled Code)
       at org.apache.cocoon.Engine.handle(Compiled Code)
       at org.apache.cocoon.Cocoon.service(Compiled Code)
       at javax.servlet.http.HttpServlet.service(Compiled Code)
       at org.apache.jserv.JServConnection.processRequest(Compiled Code)
       at org.apache.jserv.JServConnection.run(Compiled Code)
       at java.lang.Thread.run(Compiled Code) 

   Any clue as to who is causing this?


 - Another problem I have is the PDF representation of the
   links. In the PDF form, I intend to have links displayed along
   with the URL, so in the HTML output, I generate the "normal"
   <A HREF="...">

   HTML-xsl:
	  <xsl:template match="link">
	   <a>
	     <xsl:attribute name="href"><xsl:value-of select="dest" /></xsl:attribute>
	     <xsl:value-of select="text" />
	   </a>
	  </xsl:template>

   PDF-xsl:
	  <xsl:template match="link">
	     <xsl:value-of select="text" /> (<xsl:value-of select="dest" />)
	  </xsl:template>

   HTML output works fine, PDF output works sort of fine; meaning
   in general it works, but if there is a line break in the middle,
   the "(" is lost:

	This is a fine link (http://what.a.fine.link/).

   as opposed to output like this:

	this is a not quite so finely rendered link
	http://this.link.is.lacking.the.opening.parenthesis/).


Finally, but that's only a minor problem, a while ago, I asked
whether it's possible to access the document's URL from within XSL
in an XML document. Still, I didn't get an answer on that one, but
it's not really important.


Any idea, how to fix these problems?



  Benedikt



              "Study as if you were going to live forever;
               live as if you were going to die tomorrow."
                                         -- Maria Mitchell