xsl-list
[Top] [All Lists]

Re: XSL-FO & Images

2005-04-18 09:27:02
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)


--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--



<Prev in Thread] Current Thread [Next in Thread>