Formatting omitted from XSL-FO transformation
Here should go questions about transforming XML with XSLT and FOP.
-
- Posts: 107
- Joined: Mon Jul 30, 2007 11:31 pm
- Location: College Park, MD, United States
Formatting omitted from XSL-FO transformation
I'm attempting to learn XSL-FO by starting completely minimalist: just one simple-page-master, and just one page-sequence. The source file is Docbook 5 CR5.
So, my XSL file begins like this:
Stop me here if there any problems with just that little bit.
Then, I'm adding a few basic XSL template to provide the rest. Practically everything is inside an fo:block for now to reduce visual noise when I look at this weird FO code.
So, the transformation happens, but NONE of my formatting attributes are applied. The following template will output the text content, but not the formatting:
Absolutely none of those attributes appear to have any effect on the output PDF whatsoever. The output is pretty much a bunch of fo:blocks of unstyled text stretching a couple of pages, and that's it. I mean, I expected a pretty dull output from my very spartan stylesheet, but I would have expected at least some simple formatting attributes to at least make the titles stand out from the content. This is not the case.
This irritates the hell out of me since I'm extremely comfortable with CSS, and it appeared that these are almost direct maps of CSS properties. In the middle of all this weird FO code, these formatting attributes were the one thing I found something of a familiar face in...and they aren't working!
Grr.
Does anybody know why this is?
So, my XSL file begins like this:
Code: Select all
<xsl:template match="/">
<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">
<!--
defines templates describing high-level page layout only
-->
<fo:layout-master-set>
<fo:simple-page-master master-name="default">
<fo:region-body />
</fo:simple-page-master>
</fo:layout-master-set>
<!--
references page layouts defined in /fo:layout-master-set and
adds specifics
-->
<fo:page-sequence master-reference="default">
<fo:flow flow-name="xsl-region-body">
<xsl:apply-templates />
</fo:flow>
</fo:page-sequence>
</fo:root>
</xsl:template>
Then, I'm adding a few basic XSL template to provide the rest. Practically everything is inside an fo:block for now to reduce visual noise when I look at this weird FO code.

So, the transformation happens, but NONE of my formatting attributes are applied. The following template will output the text content, but not the formatting:
Code: Select all
<xsl:template match="book/title">
<fo:block
space-before="1in"
space-after="1in"
color="#FFAA33"
font-size="1in"
font-family="Skia, 'Myriad Web', Myriad, 'Century Gothic', Arial, sans-serif">
<xsl:apply-templates />
</fo:block>
</xsl:template>
Absolutely none of those attributes appear to have any effect on the output PDF whatsoever. The output is pretty much a bunch of fo:blocks of unstyled text stretching a couple of pages, and that's it. I mean, I expected a pretty dull output from my very spartan stylesheet, but I would have expected at least some simple formatting attributes to at least make the titles stand out from the content. This is not the case.
This irritates the hell out of me since I'm extremely comfortable with CSS, and it appeared that these are almost direct maps of CSS properties. In the middle of all this weird FO code, these formatting attributes were the one thing I found something of a familiar face in...and they aren't working!
Grr.
Does anybody know why this is?
-- Zearin
-
- Posts: 107
- Joined: Mon Jul 30, 2007 11:31 pm
- Location: College Park, MD, United States
Nope.
So, I changed the transformation setup so that instead of outputting a PDF, it outputs an FO file and opens it in the editor so that I can see what's going on.
It appears that no attributes are making it into the resulting FO document whatsoever. Furthermore, everything is in <fo:block> elements.
While I was expecting most of the output to be <fo:block>s, I did write a few other simple templates. I'm not sure why they are not getting called. I was under the impression that a template with match="*" has lower priority than anything more specific (which AFAIK is pretty much everything)....
What's going on?
It appears that no attributes are making it into the resulting FO document whatsoever. Furthermore, everything is in <fo:block> elements.
While I was expecting most of the output to be <fo:block>s, I did write a few other simple templates. I'm not sure why they are not getting called. I was under the impression that a template with match="*" has lower priority than anything more specific (which AFAIK is pretty much everything)....
What's going on?
-- Zearin
-
- Site Admin
- Posts: 2095
- Joined: Thu Jan 09, 2003 2:58 pm
Hi,
It is hard to guess what may happen... Please post a complete cut down example to allow us to reproduce the behavior.
You mention that the input is DocBook 5, that means the elements are all in the DocBook 5 namespace. Note that name tests in XSLT 1.0 will match no namespace elements if they are not qualified with a prefix, that means
bool/title will match book in no namespace and title in no namespace while your input document defines them in the DocBook 5 namespace. You need something like
<xsl:template xmlns:db="http://docbook.org/ns/docbook" match="db:book/db:title">
...
Best Regards,
George
It is hard to guess what may happen... Please post a complete cut down example to allow us to reproduce the behavior.
You mention that the input is DocBook 5, that means the elements are all in the DocBook 5 namespace. Note that name tests in XSLT 1.0 will match no namespace elements if they are not qualified with a prefix, that means
bool/title will match book in no namespace and title in no namespace while your input document defines them in the DocBook 5 namespace. You need something like
<xsl:template xmlns:db="http://docbook.org/ns/docbook" match="db:book/db:title">
...
Best Regards,
George
George Cristian Bina
-
- Posts: 107
- Joined: Mon Jul 30, 2007 11:31 pm
- Location: College Park, MD, United States
-
- Site Admin
- Posts: 2095
- Joined: Thu Jan 09, 2003 2:58 pm
In XSLT/XPath 1.0 name tests without a prefix will always match elements from no namespace. In XSLT/XPath 2.0 you can specify the XPath default namespace, for instance inside a stylesheet you can use the xpath-default-namespace attribute, see
http://www.w3.org/TR/xslt20/#unprefixed-qnames
Best Regards,
George
http://www.w3.org/TR/xslt20/#unprefixed-qnames
Best Regards,
George
George Cristian Bina
-
- Posts: 107
- Joined: Mon Jul 30, 2007 11:31 pm
- Location: College Park, MD, United States
THREE CHEERS!
YOU DID IT!

Thank you SO much. I've been stuck on this item for about two weeks! And best of all it's a ridiculously easy fix.
Thank you so much! May you find happiness in life!
-- Z



Thank you SO much. I've been stuck on this item for about two weeks! And best of all it's a ridiculously easy fix.
Thank you so much! May you find happiness in life!

-- Z
-- Zearin
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