create a link with xslt in html to other html

300 Views Asked by At

I have the following xml code:

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

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

1

There are 1 best solutions below

0
On

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.