By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,827 Members | 2,220 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,827 IT Pros & Developers. It's quick & easy.

XML/XSL TEI Footnote questions

P: n/a
Hello,

I have several books written up in TEI with long footnotes/endnotes.
The notes often contain multiple paragraphs or lines of poems etc. It
seems perfectly legal in TEI to do the following:

<p>Some paragraph text.
<note place="foot">
<p>This note is long.</p>
<p>see, I told you it was long</p>
</note></p>

The question is then how do I process this efficiently in XSL(T)? The
documents typically have multiple div levels etc.

Typically I've set up templates in my XSL (to convert to wordml) like:

<xsl:template match="p">
<w:p>
<w:r>
<w:t>
<xsl:value-of select="."/>
</w:t>
</w:r>
<xsl:apply-templates select="note"/>
</w:p>
</xsl:template>
<xsl:template match="note">
<w:r>
<w:rPr>
<w:rStyle w:val="FootnoteReference"/>
</w:rPr>
<w:footnote>
<w:p>
<w:pPr>
<w:pStyle w:val="FootnoteText"/>
</w:pPr>
<w:r>
<w:rPr>
<w:rStyle w:val="FootnoteReference"/>
</w:rPr>
<w:footnoteRef/>
</w:r>
<w:r>
<w:t>
<xsl:value-of select="."/>
</w:t>
</w:r>
</w:p>
</w:footnote>
</w:r>
</xsl:template>
This works ok, but it produces duplicate text for footnotes: like

<w:r>
<w:t>Some paragraph text.This note is long.
see, I told you it was long</w:t>
</w:r>
<w:r>
<w:rPr>
<w:rStyle w:val="FootnoteReference"/>
</w:rPr>
<w:footnote>
<w:p>
<w:pPr>
<w:pStyle w:val="FootnoteText"/>
</w:pPr>
<w:r>
<w:rPr>
<w:rStyle w:val="FootnoteReference"/>
</w:rPr>
<w:footnoteRef/>
</w:r>
<w:r>
<w:t>This note is long.see, I told you it was long</w:t>
</w:r>
</w:p>
</w:footnote>
</w:r>

So they are not quite formatted the way I'd like!

Any suggestions would be helpful.

Thank you,

Jeremy

Mar 16 '06 #1
Share this Question
Share on Google+
4 Replies


P: n/a
Jeremy Porter wrote:
Hello,

I have several books written up in TEI with long footnotes/endnotes.
The notes often contain multiple paragraphs or lines of poems etc. It
seems perfectly legal in TEI to do the following:

<p>Some paragraph text.
<note place="foot">
<p>This note is long.</p>
<p>see, I told you it was long</p>
</note></p>
Yes, except I'd use <p>Some paragraph text.<note place="foot">
with no white-space after the period. Otherwise if the end of the
sentence happens by chance to fall at a suitable line-end point,
the formatter might use the white-space as a signal that it's OK
to break the line there...and then put the footnote reference
mark at the start of the next line :-)
The question is then how do I process this efficiently in XSL(T)? The
documents typically have multiple div levels etc.


I'll leave the WordML problem to someone who knows Word better than
I do.

When outputting to a pageless model (eg HTML), the technique is to
insert just the footnote marks when you encounter the footnote, and
then at the change of div, test for any footnotes in the preceding
chunk, which will be either the previous div at the same level, or the
material at the start of a div which precedes the first div; and
process them at that point using a named template.

For example, assuming div0 itself contains just metadata/head:

template div1
apply-templates
do-footnotes from last div2 of this div1

template div2
if first div2 in this div1
do-footnotes in preceding-sibling::*
apply-templates
do-footnotes from last div3 of this div2

similarly for div3/4/5/6/7

template named do-footnotes
use param for context
calculate the counter-start
for-each through the the footnotes

This way the footnotes come out at a suitable breakpoint, and are
never too far from the point of reference. It works fine with HTML:
as I don't know Word's internal footnoting mechanism I can't say
if it would apply there.

///Peter
--
XML FAQ: http://xml.silmaril.ie/
Mar 16 '06 #2

P: n/a
SL
"Jeremy Porter" a écrit :
Hello,

I have several books written up in TEI with long footnotes/endnotes.
The notes often contain multiple paragraphs or lines of poems etc. It
seems perfectly legal in TEI to do the following:

<p>Some paragraph text.
<note place="foot">
<p>This note is long.</p>
<p>see, I told you it was long</p>
</note></p>

The question is then how do I process this efficiently in XSL(T)? The
documents typically have multiple div levels etc.

Typically I've set up templates in my XSL (to convert to wordml) like:

<xsl:template match="p">
<w:p>
<w:r>
<w:t>
<xsl:value-of select="."/>
</w:t>
</w:r>
<xsl:apply-templates select="note"/>
</w:p>
</xsl:template>


With this value-of, the text of the note is selected, since value-of
create a concatenation of all the text nodes descending from the
current node. So the text of the note is include a first time in the
paragraphe template, and then a second time in your "note" template.

For a fix you may consider using <xsl:apply-templates /> instead of
<xsl:value-of select="." /> in your "p" template, make a template
producing nothing for the "note" element (so that it does not output
its text content when walking through the tree), and use a named
template instead of <xsl:apply-templates select="note" />. I'm not
sure to be clear nor to have corectly understand your problem :-)

The TEI is complex to process. Have you consider using the TEI
stylesheet on the TEI web site ?

See http://www.tei-c.org/Stylesheets/teic/

And sourceforge
(http://sourceforge.net/project/showf...roup_id=106328) for
downloading the stylesheets. Output in HTML, XSL-FO or latex. Perhaps
it's simpler to convert your document in HTML and import the file in
Word.

Mar 18 '06 #3

P: n/a
Thanks for the replies. I have considered the TEI stylesheets and do
use them for HTML/XSL:FO, but they do not convert to WordProcessingML
and even if I convert to XSL:FO then what? It seems that most FO
processors are either very expensive or in their infancy in their
ability to produce pdf documents. I really need printable pdf documents
out of my TEI xml documents.

Peter, you wrote out some nice logic statements in your post--any idea
where I might get a good overview of XSL(T) Programing Paradigms? I
read about a few different things on the internet but they seemed not
quite in scope with what I want. I would like to find a method similar
to say database normalization or object oriented design--something that
you can follow when I start to write up my XSL for this.

I think I will start with the existing TEI stylesheets. What I would
like to do is use the existing XSL:FO sheets for TEI to create
WordProcessingML sheets. I'm sure there will be some translation in
what they do, but I bet I can handle that if I can just all the
language details down.

Thanks!

Jeremy

Mar 19 '06 #4

P: n/a
SL
"Jeremy Porter" a écrit :
Thanks for the replies. I have considered the TEI stylesheets and do
use them for HTML/XSL:FO, but they do not convert to
WordProcessingML and even if I convert to XSL:FO then what? It seems
that most FO processors are either very expensive or in their
infancy in their ability to produce pdf documents.
Yes, it seems. There is a new FOP version (I haven't used) claming to
be more complete. If you use a restricted set of FO objects it may be
sufficient ?

Note that you can indicate the intended target FO engine in the
stylesheet (in stylesheet/fo/tei-param.xsl) :

<xd:doc type="string" class="output">
<xd:short>Name of intended XSL FO engine</xd:short>
<xd:detail>This is used to tailor the result for different XSL FO processors.
By default, no special measures are taken, so
there are no bookmarks or other such features. Possible values are
<ul>
<li>passivetex (the TeX-based PassiveTeX processor</li>
<li>xep (XEP)</li>
<li>fop (FOP)</li>
<li>antenna (Antenna House)</li>
</ul>
</xd:detail>
</xd:doc>
<xsl:param name="foEngine">fop</xsl:param>
I really need printable pdf documents out of my TEI xml documents.
There is also the possibility of using TEI->latex stylesheet, but I
have never used them.

But you may consider too converting your TEI files into HTML and
import this HTML file into Word.
I think I will start with the existing TEI stylesheets.


Looks reasonable :-)

Mar 19 '06 #5

This discussion thread is closed

Replies have been disabled for this discussion.