RE: More problems and questions

Subject: RE: More problems and questions
From: Kay Michael <Michael.Kay@xxxxxxx>
Date: Tue, 12 Sep 2000 17:27:02 +0100
> 1. Given that there exist FO renderer(s) written in Java, such as
> FOP, and given that some XSLT processors, such as Saxon, allow
> calling extension functions written in Java, is it possible to
> access FO renderer from within XSLT through this mechanism, with the
> goal of being able to ask the renderer some questions and give it
> some tests and then modify the transformation algorithm based on the
> results returned? 

In general I'm not sure this is feasible. The Renderer might have some
free-standing algorithms available that can be used at transformation time
(e.g. how many lines of 12pt text can you fit on an A4 page?) but it won't
be able to answer anything about the specific document until it sees it and
that won't be until the transformation is complete.

I quite agree that the approach "transform first, then render" has its
problems, e.g. putting a total or balance at the bottom of each page; I
suspect the answer to this is some kind of multiphase approach where
rendition happens in several stages and further XSLT transformations can be
done between one phase and the next.

> 2. I transform XML to HTML, and I want the stylesheet to
> automatically insert width and height attributes in the img
> elements. My idea is that it is possible to implement this by
> calling extension functions implemented in Java which would open the
> image file by its URI and return its dimentions (and perhaps some
> other information, just in case). Has anyone tried this?
> Is there any free code available?

I once used a free package called ImageMagick. There may be better things
around by now.
> 
> 3. In my custom TeX macro packages (they're intended for typesetting
> mostly text with little code or math), I use \catcodes to enable
> "smart" character macros. For instance, a hyphen in the input
> expands into ~---, .... As there are no
> "character macros" in XSL, obviously what I need is some kind of an
> input filter ... Indeed, Saxon documentation says I can write
> such a filter in Java. The problem, as with the previous question,
> is that I'm not a Java programmer.

You could take a look at com.icl.saxon.tree.Stripper, a SAX filter that does
the whitespace stripping in Saxon, and use that as an example. Your code can
probably be simpler than this. It's worth biting the bullet and learning
Java.

Mike Kay


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread