1

我正在尝试在正文部分之后自动制作带有名称列表的 epub。为了做到这一点,我正在更改 tei 样式表。首先,我尝试将此代码插入“to.xsl”文件中的“profiles/default/epub”文件夹中:

  <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>

在这种情况下,输出会在正文部分之前显示名称列表。然后我找到了你可以在这里看到的“bodyHook”模板,但是它不起作用(或者我不明白如何使用它)。我试着写这样的东西:

  <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>

在此先感谢,这将有助于我得到一些答案。

4

1 回答 1

0

我认为您对如何自定义 TEI XSLT 行为有些误解。您不应该修改预定义文件。本页顶部给出了一个简单的解释。基本上,这个想法是您将创建自己的 XSLT 文件来导入该tei.xsl文件,并将您自己的模板添加到您自己的 XSLT 文件中以自定义行为。例如,要定义要在该<body>部分末尾插入的模板,您可以在 XSLT 文件中添加如下内容:

<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是什么都不做,但您可以通过添加自己的模板来覆盖该默认行为。

于 2013-01-19T20:38:21.260 回答