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

Re: XSL-FO & Images

Subject: Re: XSL-FO & Images
From: JBryant@xxxxxxxxx
Date: Mon, 18 Apr 2005 11:34:16 -0500
xsl fo external graphic src
Sorry to reply to my own post but I made an error.

<xsl:template match="image">
  <fo:block><fo:external-graphic src="."/></fo:block>
</xsl:template>

should be 

<xsl:template match="image">
  <fo:block><fo:external-graphic src="{.}"/></fo:block>
</xsl:template>

Sorry about that.

You don't always need the url() function, by the way. If you are creating 
a document from the command line and the image files are in the local file 
structure, you can drop the url function. That's SOP for me, since I use 
FOP in an offline (not over a server) document production environment.

Jay Bryant
Bryant Communication Services
(presently consulting at Synergistic Solution Technologies)




JBryant@xxxxxxxxx 
04/18/2005 11:27 AM
Please respond to
xsl-list@xxxxxxxxxxxxxxxxxxxxxx


To
xsl-list@xxxxxxxxxxxxxxxxxxxxxx
cc

Subject
Re:  XSL-FO & Images






> Are there any ways of using the "<fo:external-graphic>" tag
> in a scalable manner? i.e. run through my XML document,
> match all the "<image>" tags and populate a table?

Sure. The same way you do it for XHTML output. fo:external-graphic fills 
the same role as the XHTML img element.

So, if you have multiple images, you apply the same template to each one.

For example, if your XML structure looks like this:

<Item suburb="Clifton">
  <name>77 Seascape Ave</name>
  <description>On the foot of the infamous Table Mountain. </description>
  <price>4 500 000</price>
  <bedrooms>4</bedrooms>
  <bathrooms>2 on-suite</bathrooms>
  <lounge>2</lounge>
  <dinner>1</dinner>
  <garages>2</garages>
  <image>seascape.jpg</image>
  <image>seascape2.jpg</image>
  <image>seascape3.jpg</image>
</Item>

Then you need two templates that look like this:

<xsl:template match="Item">
  <!-- Do whatever other stuff you need to do -->
  <xsl:apply-templates/>
</xsl:template>

<xsl:template match="image">
  <fo:block><fo:external-graphic src="."/></fo:block>
</xsl:template>

What you'll end up with in your .fo file is this:

  <fo:block><fo:external-graphic src="seascape.jpg"/></fo:block>
  <fo:block><fo:external-graphic src="seascape2.jpg"/></fo:block>
  <fo:block><fo:external-graphic src="seascape3.jpg"/></fo:block>

If you need a table, create the table in the Item template and wrap the 
row and cell elements around the blocks in the image template.

Jay Bryant
Bryant Communication Services
(presently consulting at Synergistic Solution Technologies)

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.