After the responses to my question about publishing in both print and HTML format I decided to have a go with XML, XSL and FOP.
I now have FOP installed though I am little disapointed that the only Java VM it seems to work with is a non-free one, but it now seems to be working.
I now have a mostly complete stylesheet for print which just needs some tuning to make it look prettier but it also seems that I am forever having to repeat font attributes in various different bits of the stylesheet. What I would like to do if I can is to define some defaults for the font attributes to apply to the whole document and then the style template for the each of the various XML elements can just override the ones it needs to. Does anyone know how to do this?
Steve Fosdick.
On Sat, Sep 08, 2001 at 04:44:04PM +0100, Steve Fosdick wrote:
I now have a mostly complete stylesheet for print which just needs some tuning to make it look prettier but it also seems that I am forever having to repeat font attributes in various different bits of the stylesheet. What I would like to do if I can is to define some defaults for the font attributes to apply to the whole document and then the style template for the each of the various XML elements can just override the ones it needs to. Does anyone know how to do this?
Probably, if I understand you correctly, you wan't to use xsl:attribute-set.
<xsl:attribute-set name="font-attrs"> <xsl:attribute name="color">black</xsl:attribute> </xsl:attribute-set>
<xsl:template match="paragraph"> <xsl:element name="font" use-attribute-sets="font-attrs"> xsl:apply-templates/ </xsl:element> </xsl:template>
See http://nwalsh.com/docs/tutorials/xsl/xsl/foil63.html for more comprehensive examples. Having said that, it would probably be better to use div and span elements with different classes and a CSS stylesheet. Hmm.
Malc
On Sun, 09 Sep 2001 13:26:59 Malcolm Locke wrote:
Probably, if I understand you correctly, you wan't to use xsl:attribute-set.
<xsl:attribute-set name="font-attrs"> <xsl:attribute name="color">black</xsl:attribute> </xsl:attribute-set>
<xsl:template match="paragraph"> <xsl:element name="font" use-attribute-sets="font-attrs"> xsl:apply-templates/ </xsl:element> </xsl:template>
That sounds exactly what I need, though in my case the stylesheet is converting into XSL formatting objects because I want the output as postscript and PDF. In that case would I say:
<xsl:template match="paragraph"> <xsl:element name="fo:block" use-attribute-sets="font-attrs"> xsl:apply-templates/ </xsl:element> </xsl:template>
in much the same way.
See http://nwalsh.com/docs/tutorials/xsl/xsl/foil63.html for more comprehensive examples.
Ah, thanks for the referene. I had already found chapter 18 of the XML bible on-line and there is the stuff at the W3 web site, but the specs make very heavy reading when you're just starting out so tutorials are just what I need right now.
Having said that, it would probably be better to use div and span elements with different classes and a CSS stylesheet.
For HTML output perhaps. Actually I am intending to have HTML output too - I am just concentrating on the printed output first because that seems like it will be the hardest and I don't want to wate time getting HTML ouput working and then find I can't do the print bit.
In fact, I have already found the first issue that was very nearly a show stopper with print output - FOP will not accept EPS format images and when given a GIF image it omits it from the output when generating Postscript. It does include the GIF image in PDF output but if I use pdf2ps to convert the PDF to postscript it doesn't print on my printer.
I ended up solving this by filtering the postscript output through a perl script which looks at the document structure comments and inserts the EPS image at the correct point.
Anyway, back to the HTML output. The HTML output is to be used on a website which already uses a CSS stylesheet so I will be aiming to translate the XML into well formed HTML that works with that stylesheet so in that way I can use class attributes whenever the usual <h1> etc. isn't quite on the mark.
Thanks for your help. Steve.