用html中的xslt创建一个链接到其他html

时间:2021-08-31 01:27:16

I have the following xml code:

我有以下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>

With my XSL I already obtain 3 different HTML (one for A, one for B and one with lemma). I created a template in XSL for app:

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

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

Now I have this html:

现在我有这个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>

As you see a start to create a link in the li but I don't get what I want. I would like to say that the link goes from the wit (#A or #B or #Editor) to the same point of text in the other html. For example if I am looking a A html, in app, clicking on B I want to go to same point of text in B html. Can any one help?

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

1 个解决方案

#1


0  

If I get it right, this is only about the right composition of the link. It seems you have one apparatus file which should be linked to the different source files on each apparatus entry. Actually, you were quite close. Try this:

如果我做对了,这只是关于链接的正确组成。看来你有一个设备文件应该链接到每个设备条目上的不同源文件。实际上,你很亲密。尝试这个:

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

This will produce links like this:

这将生成如下链接:

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

I assume you have already figured it out for yourself after all the time. I wanted to answer this nonetheless, maybe it is still useful for someone.

我假设你已经一直在为自己找到它。我想回答这个问题,也许它对某些人来说仍然有用。

#1


0  

If I get it right, this is only about the right composition of the link. It seems you have one apparatus file which should be linked to the different source files on each apparatus entry. Actually, you were quite close. Try this:

如果我做对了,这只是关于链接的正确组成。看来你有一个设备文件应该链接到每个设备条目上的不同源文件。实际上,你很亲密。尝试这个:

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

This will produce links like this:

这将生成如下链接:

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

I assume you have already figured it out for yourself after all the time. I wanted to answer this nonetheless, maybe it is still useful for someone.

我假设你已经一直在为自己找到它。我想回答这个问题,也许它对某些人来说仍然有用。