Re: [xsl] XSL-FO / XSLT Transformations & Line Breaks in XML

Subject: Re: [xsl] XSL-FO / XSLT Transformations & Line Breaks in XML
From: JBryant@xxxxxxxxx
Date: Wed, 4 May 2005 09:20:39 -0500
<xsl:template match="publications/header">

<fo:block
space-before="30pt"
space-after="30pt">
<xsl:value-of select="heading"/>
</fo:block>

<fo:block
space-before="30pt"
space-after="30pt">
<xsl:apply-templates select="para"/>
</fo:block>

</xsl:template>

<xsl:template match="linebreakhere">
  <fo:block/>
</xsl:template>

In your FO file, you'll end up with a stucture like this:

<fo:block space-before="30pt" space-after="30pt">
  Text of some heading
</fo:block>
<fo:block space-before="30pt" space-after="30pt">
  The part of the para before the linebreakhere element <fo:block/> 
followed by the rest of the para.
</fo:block>

You can assign properties to the empty block as needed.

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






"craig webber" <craigwebber@xxxxxxxxxxx> 
05/04/2005 07:18 AM
Please respond to
xsl-list@xxxxxxxxxxxxxxxxxxxxxx


To
xsl-list@xxxxxxxxxxxxxxxxxxxxxx
cc

Subject
Re: [xsl] XSL-FO / XSLT Transformations & Line Breaks in XML






For arbitrary breaks, the XSLT processor needs to be able to recognize
something, so you need an element in the middle of the text, thus:

<para1>Banana Strawberry<break/>Grape Cherry</para1>

Then you can do:

<xsl:template match="para1">
   <p><xsl:apply-templates/></p>
</xsl:match>

<xsl:template match="break">
   <br/>
</xsl:match>


*** ***

This is working fine in my XSLT transfrom. But not in my XSL-FO transfrom 
(both use the same XML file).

I've used the following code in my XSL-FO file:

<xsl:template match="publications/header">

<fo:block
space-before="30"
space-after="30">
<xsl:value-of select="heading"/>
</fo:block>

<fo:block
space-before="30"
space-after="30">
<xsl:value-of select="para"/>
</fo:block>

</xsl:template>

<xsl:template match="publications/header/para/linebreakhere">

<fo:block
space-before="30"
space-after="30">
<xsl:value-of select="."/>
</fo:block>

</xsl:template>

And the line break appears in my XML file as follows:

<publications>
<header>

<heading>
Consultations Database
</heading>

<para>
The Department of Trade and Industry values the views of business, 
consumer 
groups and the public. We know that we will get it right delivering policy 

if we have consulted effectively.

<linebreakhere/>

The DTI seeks views on a range of proposals and existing policies, both 
through formal written consultations and through informal contact and 
discussion. We use a variety of consultation methods to ensure 
participation 
from a diversity of individuals and organisations/business.
</para>

</header>
</publications>

Any help would be great.

Thanks,

Craig.

_________________________________________________________________
Get news headlines and download FREE stuff - visit MSN South Africa! 
http://www.msn.co.za/

Current Thread