XSL FO Repeat contents of split spanned cell - xslt

I am using apache FOP 0.95 (and docbook on top of it) and I would like to repeat the content of a table cell spanning multiple rows whenever a page break happens. At the moment the cell content is only displayed on the first page while an empty cell is displayed in all other pages.
I know this is part of the XSL FO 2.0 requirements, I believe not yet final.
I am a beginner with xsl transformations and I was wondering if there is a way to define a template to achieve this.
Thanks,
Pierpaolo

I am a beginner with xsl transformations and I was wondering if there is a way to define a template to achieve this.
The answer is almost certainly no. You are referring to a suggested new feature that might be included in a future XSL (XSL-FO) specification. Conformant XSL-FO processors will implement the feature if it is considered valuable enough.
XSLT and XSL-FO are related in the sense that the former is the most common way to generate the latter. But in general, you can't enhance the functionality of an XSL-FO processor by writing a clever XSLT stylesheet.

Related

Is there a way to count tags on a physical (PDF) page using XSL-FO?

Here is the scenario. I have an XML document which contains tags. I want to create a transform that does this
<tag>content A</tag> 1. content A
<tag>content B</tag> ----> 2. content B
<tag>content C</tag> 3. content C
but only if the tag contents appear on the same physical page. The numbering should restart on each new page. Is there any way to do this using XSL-FO? I know with latex the only way to accomplish something like this is to run latex twice, with the interim document used to determine content page placement.
As far as I can tell (and as confirmed by the Antenna House tech support team), there is no way to do this using standard XSL-FO. Antenna House offers <axf:footnote*/> extensions which include the ability to set an axf:footnote-number-reset="page" attribute, and as suggested in the comments, RenderX offers a generic mechanism which might be used for this purpose, but both of these involve vendor-specific extensions to the language.
This points to a number of shortcomings in XSL-FO that really should have been addressed a long time ago with a 2.0 version of the specification. A w3c committee to develop an XSL-FO 2.0 spec was formed and then disbanded quite some time ago; I have no idea why, as I find the tool indispensable for a large class of document to PDF conversions.

xslfo with FOP: Check if content overflows and call different template?

I have a question with XSLFO, generator is FOP. What I wanna do:
In the PDF I wanna generate an item list, each item is in a box with a specific width and height. In case the content does not fit this box, the content should be displayed in a bigger box (with also specific dimensions).
I do not see any way to reach that in XSLFO, especially with FOP.
Has someone an idea to solve that?
Thanks for every idea!!
There are two separate, independent processing steps involved here:
Generation of XSL-FO markup (using a stylesheet and an XSLT processor).
Rendering of XSL-FO markup as PDF (using a FO processor, such as FOP).
The second step cannot influence the first. It is not possible to test for overflow conditions during rendering and somehow decide what template to invoke. There is no feedback loop. What you are asking for is not possible.
It is possible to do crude text fitting by estimating the length of text strings in XSLT. That is the idea behind "Saxon Extension for Guessing Composed Text String Length".
I have not used this extension, and it may not even be available anymore (the announcement about it is from 2004). In any case, this is very far from an actual layout feedback mechanism.

Which is more prefered to be called, "XSL file" or "XSLT file"?

What should I call my file containing XSL code (XSLT code?),
which one sounds more sensible/meaningful.
I know the abbreviation of both of them. But don't know which one to use and where ..
I just now came across these words in w3schools.com
It started with XSL and ended up with
XSLT, XPath, and XSL-FO.
and also saw written "XSL Source code", So what about .. Alejandro's comments .. ?
Now my question reduces to yet more simple version..
Can we call XSLT code as XSL code too? or is it deprecated?
To be nitpicker, I believe XSL is the language and XSLT is a transformation (a piece of code that is written in XSL to transform one XML to another).
So when you're talking of particular pieces of code I think XSLT is more appropriate (just XSLT not XSLT codes), like apha XSLT or so. But when you are talking about language, it should be XSL e.g. XSL skills, XSL code.
This is not only a matter of opinion: just look and see how many questions are in the xslt tag (2299) and how many are in xsl (753) -- the result is clear, isn't it? :)
Related to this in 2010 I proposed that the xsl tag be considered a synonim for the xslt tag. This proposal was voted and approved.
From http://www.w3.org/TR/xslt#section-Introduction
A transformation expressed in XSLT is
called a stylesheet
From http://www.w3.org/TR/xslt20/#what-is-xslt
[Definition: A transformation in the
XSLT language is expressed in the form
of a stylesheet, whose syntax is
well-formed XML [XML 1.0] conforming
to the Namespaces in XML
Recommendation [Namespaces in XML
1.0].]
Leaving aside the formality of the specification, you can call it what you will. With respect to the components of the stylesheet (or transformation): for XSLT 1.0 they are instructions and its contents are templates, for XSLT 2.0 they are declarations and instructions and its contents are sequence constructors
There is no appreciable difference. I use them interchangeably, and so do most people.
Really, does it matter? I'm all for correct terminology, because it usually matters in IT, but in this case you really won't confuse anyone whichever one you use.

Using XSL-FO and HTML?

I'm trying to transform some XML-data to HTML with XSLT for my bachelor thesis.
My professor wants me to consider XSL-FO too, or at least to write some word about it. But I'm very noob to this.
So my questions are:
Can I combine FO with HTML? Can I use FO istead of HTML and CSS? If yes, how will my browser render this? Are there any examples/tutorials on how to transform xml into web pages with FO?
Generating XSL-FO and XHTML from XSLT is not necessarily an either-or choice.
XSL-FO is generally used to generate PDF. For that you will need an XSL-FO engine, such as FOP, RenderX, Antenna House, IBex, etc. However, you can convert XSL-FO into XHTML and then render in the browser.
Generally, it wouldn't be worth the hassle to have your XSLT create XSL-FO and then convert into XHTML (just generate XHTML directly), unless you want to create both output formats (PDF and XHTML) with reduced effort.
It is possible to create both **XSL-FO and XHTML at the same time without maintaining two complete sets of stylesheets to create similar output in different vocabularies**.
Rather than choosing between one format or the other, or having to maintain two distinctly diffirent(but similar) stylesheet libraries, you can create your main stylesheet library to generate either XSL-FO or XHTML and then use a second transform to convert from XSL-FO to XHTML and vice-versa. There are existing XSLT stylesheets that you can leverage to do this.
In the past I have developed XSL-FO stylesheets and then used the Render-X FO2HTML stylesheet to convert the XSL-FO to XHTML output. It converts <block> elements into <div>, <inline> into <span>, etc.
I haven't used them before, but you could also try using HTML2FO stylesheets to convert XHTML outut into XSL-FO.
Out of the box, you can get amazingly similar output in both formats while maintaining one XSLT library dedicated to one particular output format.
If you happen to need to customize the output slightly (e.g. different header content for XHTML) then you just need to import/extend the conversion stylesheets and override the appropriate template(s) for the divergent content. This makes maintenance much easier, so you don't have to worry about updating multiple sets of stylesheets with essentially the same information.
XSL-FO is for PDF display only (this is not strictly true, but you can take it as a guideline). So HTML output and FO output are not related. From your XML source, you can use XSLT to generate XHTML or XSL-FO, but not both at the same time.
See for example DocBook. It comes with several XSLT stylesheets ready to use, one is for HTML output and one for PDF (via Apache Fop). If you are satisfied with the result could be a different question.

what is the best way to write xslt -fo out of xsl+xml

i have complex xslt that formats xml to html
now i need to be able to create xsl fo out of it
what is the best way to do it ?
Here is some ineresting article for you
http://www-128.ibm.com/developerworks/library/x-xslfo2app/
Also you can try next library (I dont't remember, probably it can creat fo files from xslt+xml):
http://www.codeproject.com/KB/dotnet/nfop.aspx
I had a similar requirement, and I did some research, but didn't find a reliable XHTML to FO transformer. There may be one, but there comes a point in some web searches when you have to give up and roll your own.
Instead I took the XML to HTML transformer I had already written and changed it to output FO.
This is a much simpler proposition that a full blown XHTML to FO transformer.
Whilst your details will differ, most structures in HTML have analogues in FO, so you can normally decide what FO construct to use in replacing HTML in your transform fairly easily.
I did this incrementally. If you start with the transform producing the outline of an FO document, and most of your XML being ignored in the transform, you can then build up the output in a measured fashion.