[XSL-LIST Mailing List Archive Home]
[By Thread]
[By Date]
More problems and questions 2
Subject: More problems and questions 2
From: "anilia bruho" <musoryanin@xxxxxxxxxxx>
Date: Mon, 18 Sep 2000 19:58:34 GMT
|
Thanks tp everyone for their comments. Here's my update:
> 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.
OK, I'll have to drop this for now. But I really hope this bottleneck will
be solved sometime in the future.
> 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 now have a Java class that implements this and works perfectly with Saxon.
If anyone else needs it, please contact me.
> 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.
I found a simpler solution: I create a template with match="text()", in it I
assign the current node to a variable, perform the necessary
search-and-replaces on it, and then output it using xsl:value-of. Works for
me, so far. Some simple string processing can be done in XPath, and where
its capabilities are not sufficient, I call some simple Java functions.
Now a new problem:
I need to create a table of contents by extracting all <head> elements from
a number of XML files and listing them in the root file. For each file, I
write
<xsl:for-each select="document($filename)//head">
But then, a problem arises. There are two things I need to do before
inserting a table of contents entry:
1. Some heads contain markup, in particular they may have some words in
<em>...</em>. I want this markup to be preserved in the table of contents.
2. I also need to do some text processing on the text of the heading: change
capitalization and remove trailing punctuation ("." or "," which may be part
of a heading in the text but should be dropped in the TOC).
To satisfy the first requirement, the only method that I found is using
<xsl:copy-of> which copies a specified node with all subnodes. However, for
the second requirement, the only way to go is to create a saxon:assignable
variable, do the necessary processing on it and then output the result.
The problem is that these two approaches are not compatible. I can only go
one way or the other. <xsl:copy-of> does not allow any changes to what it
copies; on the other hand, a variable created from the current node converts
it to string, so all non-text subnodes are lost.
Any suggestions?
_________________________________________________________________________
Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com.
Share information about yourself, create your own public profile at
http://profiles.msn.com.
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
|