Linebreak question
Here should go questions about transforming XML with XSLT and FOP.
-
- Posts: 44
- Joined: Tue May 25, 2004 2:27 pm
Linebreak question
Here's a tough one.... (I'm a little new at this so bear with me)...
I have some XML that looks something like this:
When I transform to HTML I get this:
which is what I want.
When I convert to PDF (using Docbook as an intermediate step) I either get:
or
All on one line isn't much help, and the extra spacing is also not a solution that works.
Docbook doesn't have any way to handle the BR tag in the way it's handled in HTML (according to their documentation). I could use the <literallayout> tag, but this presents all new problems since the BR tag is used in the XML in places I can't or don't want to use the <literallayout> (because it also respects the spacing in addition to the hard returns).
I've tried using <literallayout> with just a hard return as a subset of the <para> tag (using teh xsl to look for the <br/> tag and insert the <literallayout> wrapping a hard return), but I get the extra "paragraph" spacing I don't want....
So.. does anyone have any suggestions for what I could try or use to insert a linebreak in the Docbook text. If I'm up against a "you can't do this" situation, I'm willing to adjust my XML and make a new tag for the instances I want the BR and map that specifically to the <literallayout> tag in the xsl... but I figure it's worth asking before I do this...
I have some XML that looks something like this:
Code: Select all
<p>text1<br/>
text2<br/>
text3</p>
Code: Select all
text1
text2
text3
When I convert to PDF (using Docbook as an intermediate step) I either get:
Code: Select all
text1 text2 text3
Code: Select all
text1
text2
text3
Docbook doesn't have any way to handle the BR tag in the way it's handled in HTML (according to their documentation). I could use the <literallayout> tag, but this presents all new problems since the BR tag is used in the XML in places I can't or don't want to use the <literallayout> (because it also respects the spacing in addition to the hard returns).
I've tried using <literallayout> with just a hard return as a subset of the <para> tag (using teh xsl to look for the <br/> tag and insert the <literallayout> wrapping a hard return), but I get the extra "paragraph" spacing I don't want....
So.. does anyone have any suggestions for what I could try or use to insert a linebreak in the Docbook text. If I'm up against a "you can't do this" situation, I'm willing to adjust my XML and make a new tag for the instances I want the BR and map that specifically to the <literallayout> tag in the xsl... but I figure it's worth asking before I do this...
-
- Posts: 4141
- Joined: Fri Mar 28, 2003 2:12 pm
Post by sorin_ristache »
Hello,
I think it is a bad idea to include in the XML document formatting information like where the lines should break. Such presentation issues should be handled in a XSLT stylesheet. In the HTML case the document fragment that you describe may be something like:
and the stylesheet should generate HTML code that inserts a <br/> tag between two neighbor <p> elements from the source XML document, like this:
In the PDF case it is a "you can't do this" situation
. You can insert a <literallayout> tag between two neighbor <p> tags with the help of a XSLT stylesheet.
I hope that helps,
Sorin
I think it is a bad idea to include in the XML document formatting information like where the lines should break. Such presentation issues should be handled in a XSLT stylesheet. In the HTML case the document fragment that you describe may be something like:
Code: Select all
<section>
<p>text1</p>
<p>text2</p>
<p>text3</p>
</section>
Code: Select all
<p>text1<br/>
text2<br/>
text3</p>

I hope that helps,
Sorin
-
- Posts: 44
- Joined: Tue May 25, 2004 2:27 pm
Thanks.. that's useful information. I agree.. the <br/> tag shouldn't be used in the XML source... but... it's a historical thing that came over from the translation from HTML to XML. I'm slowly weeding out the HTML fragments that still exist - but I still have to maintian a doc set that can be built on a daily basis... so small changes.. and test.. small changes and test.. and so on.
That's what lead me to this question, and trying to find a neat and tidy way of doing this. I'll tinker with the XSL and see if I can manage to test for adjacent <p> tages and format them neatly
My other option is to create a new tag specifically for these instances where I need this linebreak formatting and use <literallayout>.
That's what lead me to this question, and trying to find a neat and tidy way of doing this. I'll tinker with the XSL and see if I can manage to test for adjacent <p> tages and format them neatly

Jump to
- Oxygen XML Editor/Author/Developer
- ↳ Feature Request
- ↳ Common Problems
- ↳ DITA (Editing and Publishing DITA Content)
- ↳ SDK-API, Frameworks - Document Types
- ↳ DocBook
- ↳ TEI
- ↳ XHTML
- ↳ Other Issues
- Oxygen XML Web Author
- ↳ Feature Request
- ↳ Common Problems
- Oxygen Content Fusion
- ↳ Feature Request
- ↳ Common Problems
- Oxygen JSON Editor
- ↳ Feature Request
- ↳ Common Problems
- Oxygen PDF Chemistry
- ↳ Feature Request
- ↳ Common Problems
- Oxygen Feedback
- ↳ Feature Request
- ↳ Common Problems
- Oxygen XML WebHelp
- ↳ Feature Request
- ↳ Common Problems
- XML
- ↳ General XML Questions
- ↳ XSLT and FOP
- ↳ XML Schemas
- ↳ XQuery
- NVDL
- ↳ General NVDL Issues
- ↳ oNVDL Related Issues
- XML Services Market
- ↳ Offer a Service