5

我有以下 xml 代码:

<?xml version="1.0" encoding="UTF-8"?>
<?xml-model href="http://www.tei-c.org/release/xml/tei/custom/schema/relaxng/tei_all.rng" type="application/xml" schematypens="http://relaxng.org/ns/structure/1.0"?>
<?xml-model href="http://www.tei-c.org/release/xml/tei/custom/schema/relaxng/tei_all.rng" type="application/xml"
        schematypens="http://purl.oclc.org/dsdl/schematron"?>
<TEI xmlns="http://www.tei-c.org/ns/1.0">
    <teiHeader/>
    <text>
        <head n="3">Capitulo primeyro</head>
        <pb facs="folio16r.jpg"/>
        <div>
            <p>... figurado <app>
                <lem>pollo</lem>
                <rdg wit="#A">pollo</rdg>
                <rdg wit="#B">pello</rdg>
            </app> Parayso ...</p>
            <p> ... <app>
                <lem>sacarõ</lem>
                <rdg wit="#A">sacarõ</rdg>
                <rdg wit="#B">ssaee</rdg>
                </app> ...</p>
        </div>
        <pb facs="folio16v.jpg"/>
        <div>
            <p> .... os fisicos <app>
                <lem>dessesperarom</lem>
                <rdg wit="#A">desseperarom</rdg>
                <rdg wit="#B">desesperõ</rdg>
                </app> ... que assy <app>
                <lem>saa</lem>
                <rdg wit="#A">sooa</rdg>
                <rdg wit="#B">saa</rdg>
                </app> ...</p>
        </div>
    </body>
</text>

使用我的 XSL,我已经获得了 3 种不同的 HTML(一种用于 A,一种用于 B,一种用于引理)。我在 XSL 中为应用程序创建了一个模板:

<xsl:template match="app">
    <xsl:variable name="appNumber" select="count(preceding::app) + 1"/>
    <a href="#app_{$appNumber}"><xsl:apply-templates select="lem"/></a>
</xsl:template>

<xsl:template match="app" mode="footnote">
    <xsl:variable name="appNumber" select="count(preceding::app) + 1"/>
    <li id="app_{$appNumber}">
        <xsl:for-each select="rdg">
            <i><xsl:apply-templates/></i><xsl:text> </xsl:text>
            <a>
                <xsl:attribute name="href">
                    <xsl:text>#</xsl:text>
                    <xsl:apply-templates select="app"/>
                </xsl:attribute>
                <xsl:value-of select="substring-after(@wit, '#')">
                </xsl:value-of>
            </a>
            <xsl:text> </xsl:text>
            <br/>
            <xsl:if test="position() lt last()"></xsl:if>
        </xsl:for-each>
    </li>
</xsl:template>

现在我有这个html:

<ul>
    <li id="app_1"><i>prophetas</i> <a href="#">Editor</a> <br /><i>prophetas</i> <a href="#">A</a> <br /></li>
    <li id="app_2"><i>pollo</i> <a href="#">Editor</a> <br /><i>pollo</i> <a href="#">A</a> <br /></li>
    <li id="app_3"><i>sacarõ</i> <a href="#">Editor</a> <br /><i>sacarõ</i> <a href="#">A</a> <br /></li>
    <li id="app_4"><i>dessesperarom</i> <a href="#">Editor</a> <br /><i>desseperarom</i> <a href="#">A</a> <br /></li>
    <li id="app_5"><i>saa</i> <a href="#">Editor</a> <br /><i>sooa</i> <a href="#">A</a> <br /></li>
    <li id="app_6"><i>ante</i> <a href="#">Editor</a> <br /><i>ante</i> <a href="#">A</a> <br /></li>
</ul>

如您所见,开始在 li 中创建链接,但我没有得到我想要的。我想说链接从机智(#A 或 #B 或 #Editor)到另一个 html 中的同一文本点。例如,如果我正在查看 A html,在应用程序中,单击 BI 想要转到 B html 中的同一文本点。任何人都可以帮忙吗?

4

1 回答 1

0

如果我做对了,这只是关于链接的正确组成。似乎您有一个设备文件,该文件应链接到每个设备条目上的不同源文件。其实,你们已经很亲近了。尝试这个:

<xsl:attribute name="href">
    <xsl:value-of select="substring-after(@wit, '#')"/>
    <xsl:text>.html#app_</xsl:text>
    <xsl:value-of select="$appNumber"/>
    <xsl:apply-templates select="app"/>
</xsl:attribute>

这将产生如下链接:

<a href="A.html#app_2">A</a>

我假设您一直以来都已经自己弄清楚了。尽管如此,我还是想回答这个问题,也许它对某人仍然有用。

于 2017-11-17T10:23:45.037 回答