Dear Good Friends and Teachers,
I want to have the Japanese/Chinese characters in my text, but only for
only the first usage of a term, and have the stylesheet generate a glossary
at the end. Cutting and pasting and rewriting, it is easy to forget if a
term has been "glossed" or not, and I cannot figure out a correct xsl test
to see if the term is properly marked up the first time it is used.
I have cobbled together some xsl to have the stylesheet generate a sorted
list of terms with their characters at the end of the paper. But I do not
see how to do it properly within TEI guidelines. It seems to me that
neither <gloss> nor <list> is quite correct. I think I need an element that
contains the Japanese word as romanized and its characters in separate
sub-elements. I can then capture both of them for the glossary and output
them in the body of the text under control of the stylesheet.
Besides the problem of not seeing how to follow TEI guidelines to do this,
I want the xsl to check to see if I have accidentally used a Japanese term
before I have glossed it.
It seems like it should be easy to check with a simple <xsl:if test---> but
I do not seem to be able to get it to work.
If I have this source:
<p>The Buddhist way is zazen. When first practicing sitting meditation
<mygloss><gr>zazen</gr><gk>==Japanese Characters==</gk><mygloss> select a
quiet place. </p>
And my stylesheet includes:
<xsl:template match="mygloss">
<xsl:if test="contains(ancestor::text(), gr) or contains(preceding::text(), gr)">
XXX ERROR-- NOT FIRST USAGE XXX
</xsl:if>
<!----- rest of template to put in italic, proper font etc -->
</xsl:template>
The above test does not find and output the error of the earlier first use,
i.e. when I forgot to gloss it when I first used in the beginning of the paper.
I tried this test:
contains(ancestor::*, gr) or contains(preceding::*, gr)
But the test is always true, even if there is no prior use.
This following test works if the word is not further marked in the
paragraph, but of course it fails to look in end notes and such:
contains(ancestor::p/text(), gr) or contains(preceding::p/text(), gr)
So, in sum, how do I do this properly? And of course, a kind explanation to
get me out of my confusion about the xsl would be very much appreciated.
David Riggs
Nichibunken, Kyoto
|