我正在尝试自动地制作epubs,在body部分后面有一个名字列表。为此,我更改了tei样式表。首先,我尝试在"profiles/default/epub“文件夹中的"to.xsl”文件中插入以下代码:
<xsl:template match="tei:body">
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
<xsl:element name="back" namespace="http://www.tei-c.org/ns/1.0">
<xsl:element name="div" namespace="http://www.tei-c.org/ns/1.0">
<xsl:for-each select="//tei:rs[@type='luogo']">
<xsl:element name="p" namespace="http://www.tei-c.org/ns/1.0">
<xsl:value-of select="."/>
</xsl:element>
</xsl:for-each>
</xsl:element>
</xsl:element>
</xsl:template>在本例中,输出在body部分之前显示名称列表。然后我找到了"bodyHook“模板,你可以看到here,但它不工作(或者我不知道如何使用它)。我试着写了这样的东西:
<xsl:param name="indiceNomi">
<back>
<div>
<xsl:for-each select="//tei:rs[@type='luogo']">
<p>
<xsl:value-of select="."/>
</p>
</xsl:for-each>
</div>
</back>
</xsl:param>
<xsl:template match="tei:body">
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
<xsl:call-template name="bodyHook"/>
<xsl:with-param name="creaIndice" select="$indiceNomi"/>
</xsl:template>但这是不正确的(似乎xsl:with-param不能在xsl:template中,即使我看到了类似这样的示例)。那么,如果这是我的输入文件,我需要编写什么样的代码呢?
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="file:/C:/Users/User/Desktop/prova2.xsl"?>
<TEI xmlns="http://www.tei-c.org/ns/1.0">
<teiHeader><fileDesc>
<titleStmt>
<title>AA</title>
</titleStmt>
<publicationStmt><p><!-- supply publication information --></p></publicationStmt>
<sourceDesc>
<bibl>AA</bibl>
</sourceDesc>
</fileDesc><profileDesc>
<langUsage>
<language ident="ita">AA</language>
<language ident="lat">AA</language>
</langUsage>
</profileDesc></teiHeader>
<text>
<body>
<div type="book" n="3" xml:id="L3">
<head>AA
</head>
<div type="capitolo" n="1" xml:id="L3-01">
<head>AA</head>
<p>AA
<pb n="200"/>textt<rs type="luogo">Genova</rs>texttex ttexttexttexttexttexttexttexttext<rs type="luogo">London</rs>exttextte<rs type="luogo">Paris</rs>
texttexttexttexttexttexttexttexttext<rs type="luogo">Tokyo</rs>xttexttexttexttexttexttexttext<rs type="luogo">New York</rs>
<rs type="luogo">Dublin</rs><rs type="luogo">Moscow</rs><rs type="luogo">Cairo</rs>texttexttexttexttexttexttexttexttexttexttexttexttexttexttext</p>
</div>
</div>
</body>
</text>
</TEI>提前感谢,能得到一些答案会对我有很大帮助。
发布于 2013-01-20 04:38:21
我认为您在某种程度上误解了如何定制TEI XSLT行为。您不应该修改预定义的文件。this page的顶部给出了一个简单的解释。基本上,您可以创建自己的XSLT文件来导入tei.xsl文件,并将自己的模板添加到自己的XSLT文件中以自定义行为。例如,要定义一个要插入到xslt节末尾的模板,可以向<body>文件添加类似以下内容的内容:
<xsl:template name="bodyEndHook">
<back>
<div>
<xsl:for-each select="//tei:rs[@type='luogo']">
<p>
<xsl:value-of select="."/>
</p>
</xsl:for-each>
</div>
</back>
</xsl:template>据推测,TEI转换会在<body>的末尾自动调用此模板。bodyEndHook的默认行为是不执行任何操作,但是您可以通过添加自己的模板来覆盖该默认行为。
https://stackoverflow.com/questions/12534748
复制相似问题