[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

fo:external-graphic and xml:base

Subject: fo:external-graphic and xml:base
From: Jack Bates <ms419@xxxxxxxxxxxxxx>
Date: Sat, 21 Nov 2009 19:24:40 -0800
 fo:external-graphic and xml:base
I'm writing a stylesheet that includes this template,

  <xsl:template match="html:img">
    <fo:external-graphic src="url('{@src}')"/>
  </xsl:template>

- but when I process it I get errors like,

 $ fop -xml index.html -xsl index.xsl index.pdf
 [...]
 16-Nov-2009 11:06:32 AM org.apache.fop.events.LoggingEventListener
processEvent
 SEVERE: Image not found. URI:
/docs/images/thumb/b/bb/UM-2.1.png/500px-UM-2.1.png. (No context info
available)
 [...]

- and the generated PDF is missing some images : (

I think the problem is that the stylesheet uses the document() function
to get HTML pages from the web,

  <xsl:template match="html:a" mode="foo">
    <fo:block>
      <xsl:apply-templates select="document(@href)//html:body"/>
    </fo:block>
  </xsl:template>

- and these pages, e.g. http://ica-atom.org/docs/index.php?title=UM-2.1

- have some relative images,
e.g. /docs/images/thumb/b/bb/UM-2.1.png/500px-UM-2.1.png

The <img> elements are part of the HTML document, and so relative to
http://ica-atom.org/docs/index.php?title=UM-2.1, but I guess the
<external-graphic> elements aren't?

I tried adding an xml:base="" attribute,

  <xsl:template match="html:a" mode="foo">
    <fo:block xml:base="{@href}">
      <xsl:apply-templates select="document(@href)//html:body"/>
    </fo:block>
  </xsl:template>

Here's a simplified, complete example,

http://www.sfu.ca/~jdbates/tmp/fop/200911160/index.html

http://www.sfu.ca/~jdbates/tmp/fop/200911160/index.xsl

- but now when I process this example I get this error,

 $ fop -xml index.html -xsl index.xsl index.pdf
 16-Nov-2009 11:29:57 AM org.apache.fop.cli.Main startFOP
 SEVERE: Exception
 javax.xml.transform.TransformerException:
org.apache.fop.fo.ValidationException: Invalid property encountered on
"fo:block": xml:base (No context info available)
         at
org.apache.fop.cli.InputHandler.transformTo(InputHandler.java:314)
         at org.apache.fop.cli.InputHandler.renderTo(InputHandler.java:146)
         at org.apache.fop.cli.Main.startFOP(Main.java:174)
         at org.apache.fop.cli.Main.main(Main.java:205)
 [...]

How can I automatically convert these HTML pages to a PDF with XSL-FO?

I originally posted this question to the FOP users list,
http://thread.gmane.org/gmane.text.xml.fop.user/29778

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.