ebeshero / DHClass-Hub

a repository to help introduce and orient students to the GitHub collaboration environment, and to support DH classes.
GNU Affero General Public License v3.0
27 stars 27 forks source link

XSLT 6: Links #726

Closed amberpeddicord closed 4 years ago

amberpeddicord commented 4 years ago

I thought I had done everything right with putting in my links, but when I look at my HTML locally in my browser, clicking the links only jumps the page down to the link I just clicked on, and not the poem I am trying to reference!

For the links, I have this code:

 <xsl:template match="$dickinsonColl//body" mode="toc">
        <li><a href="#p{//idno}"><xsl:apply-templates select="descendant::title"/></a> : <xsl:apply-templates select="descendant::l[1]"/><xsl:text>Variations:</xsl:text>[<xsl:value-of select="count(descendant::rdg)"/>]
        </li>

And for the target I have this:

<xsl:template match="$dickinsonColl//title">
        <h2 id="p{//idno}"><xsl:apply-templates/></h2>
    </xsl:template>
ebeshero commented 4 years ago

@amberpeddicord I'd like to take a look at a sample of your output. One thing I notice is that you're constructing the @href and the @id attributes properly. But I wonder if there's a problem with your @match on your <xsl:template> elements. You have

<xsl:template match="$dickinsonColl//body" mode="toc">

and

<xsl:template match="$dickinsonColl//title">

But you don't need or want them at this point! You've already chosen the collection earlier in the <xsl:apply-templates> stage that calls these template rules, so you don't need to tell it again to run through the entire collection. Instead, think of what you're doing in the new template rules as looking for every <body> and <title> element within the collection of files. I suspect that what's going wrong here has to do with the //idno in the context of a template rule that starts with $dickinsonColl. I'd suggest changing the @match in each of these to remove $dickinsoncoll// and simply to process title.

Note: When I test this, changing the @match attribute really doesn't matter, and my links are working here...so I think I want to take a look at your HTML output.

ebeshero commented 4 years ago

Just a quick update for anyone following this: We figured out what was wrong by looking at @amberpeddicord 's output in HTML. She needed one more template rule with mode="toc" set on it, because otherwise she was outputting the titles of the poems up in the table of contents and down in the body of the poems. The links were actually working, but were jumping to the first heading they found (inside the table of contents). We needed to process those TOC titles differently, in the "toc" mode, so they didn't get @id set on them.