473,804 Members | 4,153 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

TEI XSL:FO/HTML

JLP
Hello,

I have a couple of hundred books in TEI based XML. I want to output
html and pdf documents. I started building my own style sheets to do
this and I ran into a problem with footnotes. Many of my documents
have longer footnotes so I did the following:

<p>Text...text. ..text...<note> <p>footnote body.</p><p>The next
paragraph in the footnote</p></note></p>

Now I have the xsl:

<xsl:template name="div">
<xsl:for-each select="./div">
<h1>
<xsl:value-of select="head"/>
</h1>
<xsl:for-each select="p">
<p>
<xsl:value-of select="."/>
</p>
</xsl:for-each>
</xsl:for-each>
</xsl:template>

and I get the text inside the note. How can I process this properly?

I think I'd like to leave the footnotes in my source alone, unless
there is a truly better way to do this.

Thanks in advance!

Jeremy
Jul 20 '05 #1
4 1750
jp********@hotm ail.com (JLP) writes:
Hello,

I have a couple of hundred books in TEI based XML. I want to output
html and pdf documents. I started building my own style sheets to do
this
You know there is already a fairly extensive set of TEI stylesheets for
HTML and for FO?

http://www.tei-c.org/Stylesheets/teixsl.html

However there's no reason not to build your own as well, so:
and I ran into a problem with footnotes. Many of my documents
have longer footnotes so I did the following:

<p>Text...text. ..text...<note> <p>footnote body.</p><p>The next
paragraph in the footnote</p></note></p>

Now I have the xsl:

<xsl:template name="div">
<xsl:for-each select="./div">
This line is rather odd, it means that for each div you
ignore all its text and element children exept immediately nested divs,.
so given
<div>
<p>zz</p>
<div>
<p>xxx</p>
</div>
</div>

when the template matches on the outer div you ignore the zz paragraph
and just process the inner div.

<h1>
<xsl:value-of select="head"/>
Using value-of here rather than apply-templates means that you get the
the string value of the head but means that you will not process any
nested markup within the head.

</h1> <xsl:for-each select="p">
<p>
<xsl:value-of select="."/>
</p>
</xsl:for-each> again I don't think you want for-each and value-of in the above. </xsl:for-each>
</xsl:template>

and I get the text inside the note. How can I process this properly?

I think I'd like to leave the footnotes in my source alone, unless
there is a truly better way to do this.

Thanks in advance!

Jeremy

Something like the following should make a html div out of a TEI div,
with an html heading, and all children processed, note elements just
make a superscripted number, and at the end of the div, if there were
any notes it makes a list of the numbers and note texts (untested)

<xsl:template match="div">
<div>
<xsl:apply-templates select="head"/>
<xsl:apply-templates select="node()[not(self::head)]"/>
<xsl:if test=".//note">
<hr/>
<dl>
<xsl:for-each select=".//note">
<dt><xsl:numb er level="any"/></dt>
<dd><xsl:appl y-templates/></dd>
</xsl:for-each>
</dl>
</xsl:if>
</div>
</xsl:template>

<xsl:template match="head">
<h2><xsl:appl y-templates/></h2>
</xsl:template>

<xsl:template match="p">
<p><xsl:apply-templates/></p>
</xsl:template>

<xsl:template match="note">
<sup><xsl:numbe r level="any"/></sup>
</xsl:template>

Jul 20 '05 #2
JLP
David,

Thank you for your response!

I did have some success with this XSL. It seems to be doing much
better now. I'm still a bit stuck on exactly what:

<xsl:apply-templates select="node()[not(self::head)]"/>

does.

node() is that some form of boolean function? I was not able to find
it in the XSLT functions reference or the XPath functions. Is this
selecting all elements except "node()[not(self::head)]"?

The results of what you posted are pretty good except that I get two
sets of footnotes. I suspect that line above, hence the questions.

As you probably have guessed, I'm new to XSL. Your help is greatly
appreciated!

As for writing my own XSL/XSL:FO for TEI, the style sheets that are
available for HTML are decent, I just wanted to learn XSL/XSL:FO. What
I really want is XSL:FO, but I thought XSL would be a good starting
point. The TEI XSL:FO style sheets use PassiveTeX. I've never quite
understood how they are supposed to work physically. Logically it
seems you have to have some software installed (jadeTeX?) to process
them appropriately. I never found a good how to on configuration. At
any rate, I will probably want to customize it for my own needs
anyway. I think it is better for me to write my own.

So far this seems to be a component driven process. I mean I can write
a snippet of XSL for div elements and then use it in other places
which is nice. Are there any good references on design strategies for
this kind of thing? Not just what the XSL elements are, but how to put
them together and how to do things efficiently?

Thanks again to everyone!

Jeremy

David Carlisle <da****@nag.co. uk> wrote in message news:<yg******* ******@penguin. nag.co.uk>...
jp********@hotm ail.com (JLP) writes:
Hello,

I have a couple of hundred books in TEI based XML. I want to output
html and pdf documents. I started building my own style sheets to do
this


You know there is already a fairly extensive set of TEI stylesheets for
HTML and for FO?

http://www.tei-c.org/Stylesheets/teixsl.html

However there's no reason not to build your own as well, so:
and I ran into a problem with footnotes. Many of my documents
have longer footnotes so I did the following:

<p>Text...text. ..text...<note> <p>footnote body.</p><p>The next
paragraph in the footnote</p></note></p>

Now I have the xsl:

<xsl:template name="div">
<xsl:for-each select="./div">


This line is rather odd, it means that for each div you
ignore all its text and element children exept immediately nested divs,.
so given
<div>
<p>zz</p>
<div>
<p>xxx</p>
</div>
</div>

when the template matches on the outer div you ignore the zz paragraph
and just process the inner div.

<h1>
<xsl:value-of select="head"/>


Using value-of here rather than apply-templates means that you get the
the string value of the head but means that you will not process any
nested markup within the head.

</h1>

<xsl:for-each select="p">
<p>
<xsl:value-of select="."/>
</p>
</xsl:for-each>

again I don't think you want for-each and value-of in the above.
</xsl:for-each>
</xsl:template>

and I get the text inside the note. How can I process this properly?

I think I'd like to leave the footnotes in my source alone, unless
there is a truly better way to do this.

Thanks in advance!

Jeremy

Something like the following should make a html div out of a TEI div,
with an html heading, and all children processed, note elements just
make a superscripted number, and at the end of the div, if there were
any notes it makes a list of the numbers and note texts (untested)

<xsl:template match="div">
<div>
<xsl:apply-templates select="head"/>
<xsl:apply-templates select="node()[not(self::head)]"/>
<xsl:if test=".//note">
<hr/>
<dl>
<xsl:for-each select=".//note">
<dt><xsl:numb er level="any"/></dt>
<dd><xsl:appl y-templates/></dd>
</xsl:for-each>
</dl>
</xsl:if>
</div>
</xsl:template>

<xsl:template match="head">
<h2><xsl:appl y-templates/></h2>
</xsl:template>

<xsl:template match="p">
<p><xsl:apply-templates/></p>
</xsl:template>

<xsl:template match="note">
<sup><xsl:numbe r level="any"/></sup>
</xsl:template>

Jul 20 '05 #3


<xsl:apply-templates select="node()[not(self::head)]"/>

does.

node() is that some form of boolean function?

Not really it's a node test (along with with text() comment() and
processing-instruction()) it selects any node (* in that position
would just match element nodes. In particular if you do
<xsl:apply-templates select="node()"/>
or equivalently
<xsl:apply-templates/>
templates get applied to child text as well as child element nodes.

Obviously text nodes are never head elements so the
node()[not(self::head)]
is the same as
text()|*[not(self::head)]
(well actually it's the same as

comment()|proce ssing-instruction()|t ext()|*[not(self::head)]

I was not able to find
it in the XSLT functions reference or the XPath functions. Is this
selecting all elements except "node()[not(self::head)]"?

It's in xpath.

As for writing my own XSL/XSL:FO for TEI, the style sheets that are
available for HTML are decent, I just wanted to learn XSL/XSL:FO. What
I really want is XSL:FO, but I thought XSL would be a good starting
point.

Yes that's a good idea and you'll learn more rolling your own, although
in the end you may find that to handle complicated tei books customising
sebastian's efforts might be quicker if you just want to get the job
done rather than rolling your own. For TEI (and the conceptually
similar docbook stylesheets) a lot of years fine tuning edge cases have
gone in to the stylesheets, so for any given document it's often simpler
to write your own focussed stylesheet, but to produce something that
can handle a large range of documents within the specific dtd, using a
"standard" stylesheet has advantages.
The TEI XSL:FO style sheets use PassiveTeX.

Not really, The fO files they generate can be used by any FO renderer
(FOP, renderx, ....). Passivetex was generated at the same time by the
same person (except for the low level xml parsing part which he
tricked someone else in to writing) but the stylesheets produce standard
FO (in general, they may use a few extension elements for specific jobs,
I haven't looked recently)

Logically it
seems you have to have some software installed (jadeTeX?) to process
them appropriately.

You need tex, jadetex is something else, similar to passivetex but
working with dsssl rather than xsl dsssl being the older style language
for sgml rather than xml documents (Sebastian and I have been in this
game too long:-) If you are not already a tex user (why not:-) to be
honest I wouldn't start with passivetex I'd start with fop if you are
looking for a free FO engine as that is by far the most commonly used
free one so you'll get more "community" support using that.

So far this seems to be a component driven process. I mean I can write
a snippet of XSL for div elements and then use it in other places
which is nice. Are there any good references on design strategies for
this kind of thing? Not just what the XSL elements are, but how to put
them together and how to do things efficiently?
xsl-list has a good faq site, jeni's site is also good

http://www.dpawson.co.uk/xsl/xslfaq.html
http://www.jenitennison.com/

The results of what you posted are pretty good except that I get two
sets of footnotes. I suspect that line above, hence the questions.
Do you have nested div elements?

At the end of every div I went
<xsl:for-each select=".//note">

which processes all notes however deeply nested so if you go

<div>
xxx<note>a</note>
<div>
yyy<note>b</note>
</div>
</div>

You'll get something like

xxx^1

yyy^b
1 b

1 a
1 b
as I just use the default attributes on xsl:number (which numbers notes
(just) with its siblings and processes notes on every div.

Both of these things are easy to fix but it depends quite what you want
eg one way is to add attributes to xsl:number so notes are numbered
across the whole document and move
<xsl:if test=".//note">
<hr/>
<dl>
<xsl:for-each select=".//note">
<dt><xsl:numb er level="any"/></dt>
<dd><xsl:appl y-templates/></dd>
</xsl:for-each>
</dl>
</xsl:if>


to the end of the template that matches your book rather than having it
on every div.

David
Jul 20 '05 #4

David Carlisle wrote:
http://www.tei-c.org/Stylesheets/tei...D=body.1_div.6
It's true that the documentation does say
These style sheets were developed for use with PassiveTeX
but I wouldn't expect that to be too much of a problem passivetex is
pretty much written to process standard fo files. Like other FO systems it does have some extensions in it's own namespace (the fotex prefix).

You appear to be falling foul of
<fo:table-column column-number="1" fotex:column-align="r"
column-width="" />
(from tei-special.xsl) or a similar construct elsewhare.

I was going to say that FO engines should ignore attributes in
namespaces that they don't recognise, but your posting indicates that
they don't and I just searched the xsl spec and didn't see any anything to justify that belief...

these fotex attributes give the tex engine some extra hints on layout, but just deleting them from your copy of the stylesheet should work in most cases as far as I can see looking just now (I hadn't actually
looked recently otherwise I'd have mentioned this before, sorry)
David


No, need to apologize. Thank you for your help! I've got basic TEI
working for converting xml to pdf using altsoft's xml2pdf. FOP lacks
some features that I require currently, but maybe in the future it will
do what I need!

I have a number of questions regarding the TEI style sheets:

1) How can I get footnotes with multiple <p> elements working? In my
output I get:

1.
Footnote text in <p>.
more text in another <p>

Instead of:

1. Footnote text.
more text in another <p>.

2) How can I adjust the TOC hyperlinks to extend to the text entry as
well as the numeric entry?

I have currently:

Chapter 1...1
but only the page number 1 is active as a link.

3) How can I manage chapter numbers in TEI? I looked around in the
documentation and didn't see anything specific on chapter numbers aside
from the n attribute. If I use the n attribute that works great for
chapters with numbers, but what about chapters without numbers? If I
leave n blank in the chapter heading I get ". Chapter Heading" which
doesn't look quite right! I see several references to things I think I
may want to customize in tecommon.xsl. I'm not sure which ones to start
with!

4) How can I prevent page numbers from appearing in the header and
footer of the same page?

Perhaps there is some other documentation that I'm not aware of with
XSL TEI that will answer these kind of questions? It's really some good
stuff--I just don't know how to use it all!

Thanks,

Jeremy

Jul 20 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
2158
by: Philip Meyer | last post by:
1) setting image as Background with alignment in center not working..help Explanation : i need to set a image as background and also it should be dispalyed in the center.i am using apache fop 0.25 Problem : i am using apache fop 0.25 and i used the below to set a gif as background and alignment to be center...
4
2736
by: David | last post by:
Hello list, I'm using XML + XSL + CSS to display my data to the web. I also want to publish my pages in PDF format. To accomplish this I first must transform my XML + XSL + CSS in XSL-FO. Is there a know technique to transform my data to XSL-FO without loosing my markup. For example, transformation my data to XHTML first and later from XHTML to XSL-FO? Hope someone can help me on this one.
0
3953
by: Rary | last post by:
I am using XSL:FO to generate PDF report for my XML, generating it in tables, i want that tables should completely be at one place, if there is a page break , all the contents of the table should move to the next page. can any one suggest a way out? This is my code (number 18, Brunelli Rocco, should move to the next page): XML: <?xml version="1.0" encoding="windows-1252"?>
6
5959
by: suresh_C# | last post by:
Dear All, I want work on “XSL Formatting Objects (XSL-FO)” using .NET(C#). I found classes for working on XSLT in .NET class library but couldn’t find any sample code for XSL-FO. Please tell me where I will get “XSL-FO & .NET(C#)” code/article. Any help would be greatly appreciated.
0
2434
by: Nathan | last post by:
Hi, I seem to having a peculiar problem with the display of odd and even pages in XSL-FO. Here is a small background of the problem. My xsl stylesheet mentions my fo:layout-master-set as <fo:layout-master-set> <fo:simple-page-master margin-left="0.5in" margin-right="0.5in" page-width="8.5in" margin-bottom="0.5in" master-name="Section-odd-page" margin-top="0.5in" page-height="14in"> <fo:region-after region-name="xsl-region-after-odd"
5
4416
by: shauldar | last post by:
Is there a way (tool, hack...) to create an XSL:FO from an XSLT + XML files? My motivation is that we want to use a tool to design reports, and from that "design" generate both HTML (via XSLT) and PDF (via XSL:FO). The only tool we have seen is Altova's StyleVision, which is very unfriendly (and uses a proprietary representation, SPS, from which it generates the various XSLs). We have considered instead using InfoPath, which is WYSIWYG,...
13
2955
by: vm98123 | last post by:
Hi, could someone please give me a clue to this one: I do have an xml-File and an xslt-File so that a browser can display the xml-file. What I am trying to do is convert this to pdf or tiff. I know that with fop you can convert xml + xsl-fo to pdf.
0
2497
by: jklBruin | last post by:
i'm trying to implement converting xsl-fo to pdf on a .Net page. i''m getting the error message: Root element must be root, not http://www.w3.org/1999/XSL/Transform:stylesheet here's the xsl i'm using. <?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet
1
5327
by: cleary1981 | last post by:
Hi, I am trying to add page numbers to my document in xsl fo. I can get the page numbers to work but I need them to show at the bottom of each page. I know you can define an area as region-after but don't know how. Heres my xsl file so far. <?xml version="1.0" encoding="ISO-8859-1" ?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="http://www.w3.org/1999/XSL/Format" ...
0
9585
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10586
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10338
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10323
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
7622
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupr who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6856
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5525
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
3823
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2997
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.