You are viewing a plain text version of this content. The canonical link for it is here.
Posted to fop-users@xmlgraphics.apache.org by "Browning, Jamie" <Ja...@catlin.com> on 2008/06/06 16:42:53 UTC

Line breaking in FOP (XSL)

All
I am currently undertaking an upgrade of FOP from version 0.20.5 to 0.94 and need some confirmation of an issue that is causing me a slight headache.
I am working with a set of existing style sheets. Unfortunately the author of the style sheets is no longer with the company so I have to attempt to decode his intentions. Even worse he appears to have used a number of non-standard idioms and styles ☹
Given a source XML document the author has attempted to insert html style line breaks into text. E.g.
<text>
  Line 1
  <br/>
  Line 2
  <br/>
  Line 3
</text>

Then in the XSL style sheet he has used the following template which makes use of the Unicode line-break entity:

<xsl:template match="br>
  <xsl:text>&#x2028;</xsl:text>
</xsl:template>

My question is this: am I right in assuming that this idiom worked in FOP 0.20 but does not in 0.94?
My own testing suggests this is so but I would like to confirm before I go through the pain of refactoring. (I work for a large financial services company and this line-breaking method is used extensively - grrrr....)
Thanks in advance
Jamie Browning


This e-mail is confidential and intended solely for the use of the individual(s) to whom it is addressed. If you are not the intended recipient, be advised that you have received this e-mail in error and that any use, dissemination, forwarding, printing, copying of, or any action taken in reliance upon it, is strictly prohibited and may be illegal.

Catlin Underwriting Agencies Limited, Catlin Insurance Company (UK) Ltd and Catlin (Wellington) Underwriting Agencies Limited are authorised and regulated by the Financial Services Authority.
The registered office of Catlin Underwriting Agencies Limited (incorporated and registered in England and Wales with company number 1815126) and Catlin Insurance Company (UK) Ltd (incorporated and registered in England and Wales with company number 5328622) is 6th Floor, 3 Minster Court, Mincing Lane, London EC3R 7DD. 
Catlin Risk Solutions Limited is an Appointed Representative of Catlin Underwriting Agencies Limited.


---------------------------------------------------------------------
To unsubscribe, e-mail: fop-users-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: fop-users-help@xmlgraphics.apache.org


Re: Line breaking in FOP (XSL)

Posted by Andreas Delmelle <an...@telenet.be>.
On Jun 6, 2008, at 16:42, Browning, Jamie wrote:

> Given a source XML document the author has attempted to insert html  
> style line breaks into text. E.g.
> <text>
>   Line 1
>   <br/>
>   Line 2
>   <br/>
>   Line 3
> </text>

<xsl:template match="text">
   <fo:block linefeed-treatment="preserve">
     <xsl:apply-templates />
   </fo:block>
</xsl:template>

<xsl:template match="br">
   <xsl:text>&#x0A;</xsl:text>
</xsl:template>

<xsl:template match="text()">
   <xsl:value-of select="normalize-space(.)" />
</xsl:template>


will yield:

<fo:block linefeed-treatment="preserve">Line 1
Line 2
Line 3</fo:block>

For an input of:

> <text>
>   Line 1
>   <br/>
>   <br/>
>   Line 2
> </text>

You will get:

<fo:block linefeed-treatment="preserve">Line 1

Line 2</fo:block>

Which will produce one empty line in the output.

HTH!

Cheers

Andreas

---------------------------------------------------------------------
To unsubscribe, e-mail: fop-users-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: fop-users-help@xmlgraphics.apache.org


AW: Line breaking in FOP (XSL)

Posted by Ingo Maas <in...@ebp.de>.
 

> -----Ursprüngliche Nachricht-----
> Von: Browning, Jamie [mailto:Jamie.Browning@catlin.com] 
> Gesendet: Freitag, 6. Juni 2008 16:43
> An: fop-users@xmlgraphics.apache.org
> Betreff: Line breaking in FOP (XSL)
> 
> Given a source XML document the author has attempted to 
> insert html style line breaks into text. E.g.
> <text>
>   Line 1
>   <br/>
>   Line 2
>   <br/>
>   Line 3
> </text>
> 
> Then in the XSL style sheet he has used the following 
> template which makes use of the Unicode line-break entity:
> 
> <xsl:template match="br>
>   <xsl:text>&#x2028;</xsl:text>
> </xsl:template>
> 
> My question is this: am I right in assuming that this idiom 
> worked in FOP 0.20 but does not in 0.94?

Why do you think it is not legal (except the missing quote after br in
'match="br')? 
This simply says that for each 'br' element in the input document a single
Unicode character with value x2028 'll be put into the output document.

Ingo


---------------------------------------------------------------------
To unsubscribe, e-mail: fop-users-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: fop-users-help@xmlgraphics.apache.org


RE: Line breaking in FOP (XSL)

Posted by "Browning, Jamie" <Ja...@catlin.com>.
Ingo/Jeremias
Thank you both for the prompt response.
> Why do you think it is not legal (except the missing quote 
> after br in 'match="br')? 
Ooops ... a typo
> This simply says that for each 'br' element in the input document a 
> single Unicode character with value x2028 'll be put into the output 
> document.
Exactly. But the 0.94 implementation actually outputs a '#' character into the final document rather than the Unicode character
> My suggestion to you is to change the "br" template to this:
> <xsl:template match="br>
>  <fo:block/>
> </xsl:template>
Yes I agree that this is the standard way of achieving this. Unfortunately we also have cases where the source document includes multiple line breaks e.g
<text>
  Line 1
  <br/>
  <br/>
  Line 2
</text>
In this case I will need to use the space-after attribute to increase the size of the break as an empty <block/> element has no height. Therefore multiple empty <block/> elements do not add additional line spacing i.e.
  <block/>
Is equivalent to
  <block/>
  <block/>
  <block/>
So to provide a generic method of doing this I will need to know the font-size of the text e.g.
  <block space-after="@font-size * $no-of-lines"/>
Once again thanks for the help/suggestions
Jamie Browning

-----Original Message-----
From: Jeremias Maerki [mailto:dev@jeremias-maerki.ch] 
Sent: 06 June 2008 15:58
To: fop-users@xmlgraphics.apache.org
Subject: Re: Line breaking in FOP (XSL)

It could very well be that &#x2028; support hasn't been reimplemented if
this worked in 0.20.5. I haven't checked but can also not remember that
this character has been mentioned lately. At any rate I don't think this
approach is widely used.

My suggestion to you is to change the "br" template to this:
<xsl:template match="br>
  <fo:block/>
</xsl:template>

This is known to work in 0.9x and is also tested by our test suite. I
guess we'll have to look into supporting &#x2028;. HTH

On 06.06.2008 16:42:53 Browning, Jamie wrote:
> All
> I am currently undertaking an upgrade of FOP from version 0.20.5 to 0.94
> and need some confirmation of an issue that is causing me a slight
> headache.
> I am working with a set of existing style sheets. Unfortunately the
> author of the style sheets is no longer with the company so I have to
> attempt to decode his intentions. Even worse he appears to have used a
> number of non-standard idioms and styles ☹
> Given a source XML document the author has attempted to insert html
> style line breaks into text. E.g.
> <text>
>   Line 1
>   <br/>
>   Line 2
>   <br/>
>   Line 3
> </text>
> 
> Then in the XSL style sheet he has used the following template which
> makes use of the Unicode line-break entity:
> 
> <xsl:template match="br>
>   <xsl:text>&#x2028;</xsl:text>
> </xsl:template>
> 
> My question is this: am I right in assuming that this idiom worked in
> FOP 0.20 but does not in 0.94?
> My own testing suggests this is so but I would like to confirm before I
> go through the pain of refactoring. (I work for a large financial
> services company and this line-breaking method is used extensively -
> grrrr....)
> Thanks in advance
> Jamie Browning
> 



Jeremias Maerki


---------------------------------------------------------------------
To unsubscribe, e-mail: fop-users-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: fop-users-help@xmlgraphics.apache.org



This e-mail is confidential and intended solely for the use of the individual(s) to whom it is addressed. If you are not the intended recipient, be advised that you have received this e-mail in error and that any use, dissemination, forwarding, printing, copying of, or any action taken in reliance upon it, is strictly prohibited and may be illegal.

Catlin Underwriting Agencies Limited, Catlin Insurance Company (UK) Ltd and Catlin (Wellington) Underwriting Agencies Limited are authorised and regulated by the Financial Services Authority.
The registered office of Catlin Underwriting Agencies Limited (incorporated and registered in England and Wales with company number 1815126) and Catlin Insurance Company (UK) Ltd (incorporated and registered in England and Wales with company number 5328622) is 6th Floor, 3 Minster Court, Mincing Lane, London EC3R 7DD. 
Catlin Risk Solutions Limited is an Appointed Representative of Catlin Underwriting Agencies Limited.


---------------------------------------------------------------------
To unsubscribe, e-mail: fop-users-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: fop-users-help@xmlgraphics.apache.org


Re: Line breaking in FOP (XSL)

Posted by Andreas Delmelle <an...@telenet.be>.
On Jun 6, 2008, at 17:58, Andreas Delmelle wrote:

> On Jun 6, 2008, at 17:50, Browning, Jamie wrote:
>
>>> I guess we'll have to look into supporting &#x2028;
>> Is there any benefit in me producing a test case and raising a bug/ 
>> RFE?
>
> Please do! Thanks.

On second thought...
Not necessary anymore, since a fix has now been committed to the trunk.
FOP now behaves the same for preserved linefeeds and Unicode  
mandatory breaks: U+0085, U+2028 and U+2029.

see: http://svn.apache.org/viewvc?rev=664347&view=rev

Note that the treatment of preserved linefeeds is known to cause  
issues in combination with hyphenation (Bugzilla #38264: the cause  
has been identified, but the solution does not seem so easy). Also  
IIRC, someone recently reported a problem with widows/orphans not  
being respected.


Andreas

---------------------------------------------------------------------
To unsubscribe, e-mail: fop-users-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: fop-users-help@xmlgraphics.apache.org


RE: Line breaking in FOP (XSL)

Posted by "Browning, Jamie" <Ja...@catlin.com>.
Merci beaucoup Andreas

-----Original Message-----
From: Andreas Delmelle [mailto:andreas.delmelle@telenet.be] 
Sent: 06 June 2008 16:58
To: fop-users@xmlgraphics.apache.org
Subject: Re: Line breaking in FOP (XSL)

On Jun 6, 2008, at 17:50, Browning, Jamie wrote:

>> I guess we'll have to look into supporting &#x2028;
> Is there any benefit in me producing a test case and raising a bug/ 
> RFE?

Please do! Thanks.

I'll look into it. It should normally only be a matter of extending  
the behavior of preserved linefeed-characters to that codepoint.


Cheers

Andreas

---------------------------------------------------------------------
To unsubscribe, e-mail: fop-users-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: fop-users-help@xmlgraphics.apache.org



This e-mail is confidential and intended solely for the use of the individual(s) to whom it is addressed. If you are not the intended recipient, be advised that you have received this e-mail in error and that any use, dissemination, forwarding, printing, copying of, or any action taken in reliance upon it, is strictly prohibited and may be illegal.

Catlin Underwriting Agencies Limited, Catlin Insurance Company (UK) Ltd and Catlin (Wellington) Underwriting Agencies Limited are authorised and regulated by the Financial Services Authority.
The registered office of Catlin Underwriting Agencies Limited (incorporated and registered in England and Wales with company number 1815126) and Catlin Insurance Company (UK) Ltd (incorporated and registered in England and Wales with company number 5328622) is 6th Floor, 3 Minster Court, Mincing Lane, London EC3R 7DD. 
Catlin Risk Solutions Limited is an Appointed Representative of Catlin Underwriting Agencies Limited.


---------------------------------------------------------------------
To unsubscribe, e-mail: fop-users-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: fop-users-help@xmlgraphics.apache.org


Re: Line breaking in FOP (XSL)

Posted by Andreas Delmelle <an...@telenet.be>.
On Jun 6, 2008, at 17:50, Browning, Jamie wrote:

>> I guess we'll have to look into supporting &#x2028;
> Is there any benefit in me producing a test case and raising a bug/ 
> RFE?

Please do! Thanks.

I'll look into it. It should normally only be a matter of extending  
the behavior of preserved linefeed-characters to that codepoint.


Cheers

Andreas

---------------------------------------------------------------------
To unsubscribe, e-mail: fop-users-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: fop-users-help@xmlgraphics.apache.org


RE: Line breaking in FOP (XSL)

Posted by "Browning, Jamie" <Ja...@catlin.com>.
> I guess we'll have to look into supporting &#x2028;
Is there any benefit in me producing a test case and raising a bug/RFE?

-----Original Message-----
From: Jeremias Maerki [mailto:dev@jeremias-maerki.ch] 
Sent: 06 June 2008 15:58
To: fop-users@xmlgraphics.apache.org
Subject: Re: Line breaking in FOP (XSL)

It could very well be that &#x2028; support hasn't been reimplemented if
this worked in 0.20.5. I haven't checked but can also not remember that
this character has been mentioned lately. At any rate I don't think this
approach is widely used.

My suggestion to you is to change the "br" template to this:
<xsl:template match="br>
  <fo:block/>
</xsl:template>

This is known to work in 0.9x and is also tested by our test suite. I
guess we'll have to look into supporting &#x2028;. HTH

On 06.06.2008 16:42:53 Browning, Jamie wrote:
> All
> I am currently undertaking an upgrade of FOP from version 0.20.5 to 0.94
> and need some confirmation of an issue that is causing me a slight
> headache.
> I am working with a set of existing style sheets. Unfortunately the
> author of the style sheets is no longer with the company so I have to
> attempt to decode his intentions. Even worse he appears to have used a
> number of non-standard idioms and styles ☹
> Given a source XML document the author has attempted to insert html
> style line breaks into text. E.g.
> <text>
>   Line 1
>   <br/>
>   Line 2
>   <br/>
>   Line 3
> </text>
> 
> Then in the XSL style sheet he has used the following template which
> makes use of the Unicode line-break entity:
> 
> <xsl:template match="br>
>   <xsl:text>&#x2028;</xsl:text>
> </xsl:template>
> 
> My question is this: am I right in assuming that this idiom worked in
> FOP 0.20 but does not in 0.94?
> My own testing suggests this is so but I would like to confirm before I
> go through the pain of refactoring. (I work for a large financial
> services company and this line-breaking method is used extensively -
> grrrr....)
> Thanks in advance
> Jamie Browning
> 



Jeremias Maerki


---------------------------------------------------------------------
To unsubscribe, e-mail: fop-users-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: fop-users-help@xmlgraphics.apache.org



This e-mail is confidential and intended solely for the use of the individual(s) to whom it is addressed. If you are not the intended recipient, be advised that you have received this e-mail in error and that any use, dissemination, forwarding, printing, copying of, or any action taken in reliance upon it, is strictly prohibited and may be illegal.

Catlin Underwriting Agencies Limited, Catlin Insurance Company (UK) Ltd and Catlin (Wellington) Underwriting Agencies Limited are authorised and regulated by the Financial Services Authority.
The registered office of Catlin Underwriting Agencies Limited (incorporated and registered in England and Wales with company number 1815126) and Catlin Insurance Company (UK) Ltd (incorporated and registered in England and Wales with company number 5328622) is 6th Floor, 3 Minster Court, Mincing Lane, London EC3R 7DD. 
Catlin Risk Solutions Limited is an Appointed Representative of Catlin Underwriting Agencies Limited.


---------------------------------------------------------------------
To unsubscribe, e-mail: fop-users-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: fop-users-help@xmlgraphics.apache.org


Re: Line breaking in FOP (XSL)

Posted by Jeremias Maerki <de...@jeremias-maerki.ch>.
It could very well be that &#x2028; support hasn't been reimplemented if
this worked in 0.20.5. I haven't checked but can also not remember that
this character has been mentioned lately. At any rate I don't think this
approach is widely used.

My suggestion to you is to change the "br" template to this:
<xsl:template match="br>
  <fo:block/>
</xsl:template>

This is known to work in 0.9x and is also tested by our test suite. I
guess we'll have to look into supporting &#x2028;. HTH

On 06.06.2008 16:42:53 Browning, Jamie wrote:
> All
> I am currently undertaking an upgrade of FOP from version 0.20.5 to 0.94
> and need some confirmation of an issue that is causing me a slight
> headache.
> I am working with a set of existing style sheets. Unfortunately the
> author of the style sheets is no longer with the company so I have to
> attempt to decode his intentions. Even worse he appears to have used a
> number of non-standard idioms and styles ☹
> Given a source XML document the author has attempted to insert html
> style line breaks into text. E.g.
> <text>
>   Line 1
>   <br/>
>   Line 2
>   <br/>
>   Line 3
> </text>
> 
> Then in the XSL style sheet he has used the following template which
> makes use of the Unicode line-break entity:
> 
> <xsl:template match="br>
>   <xsl:text>&#x2028;</xsl:text>
> </xsl:template>
> 
> My question is this: am I right in assuming that this idiom worked in
> FOP 0.20 but does not in 0.94?
> My own testing suggests this is so but I would like to confirm before I
> go through the pain of refactoring. (I work for a large financial
> services company and this line-breaking method is used extensively -
> grrrr....)
> Thanks in advance
> Jamie Browning
> 



Jeremias Maerki


---------------------------------------------------------------------
To unsubscribe, e-mail: fop-users-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: fop-users-help@xmlgraphics.apache.org