XML : Dynamically linking pointers

I have an encoded journal entry in this xml document that will display on a web page. I would like for a user to be able to click on a note and be taken to the corresponding note within the Notes section of the page (like the 'Contents' section of a Wikipedia page, except each note is interspersed throughout the document).

Here is an example of something from the encoded journal entry.

  <body>   <div type="section">    <p>     Blah blah blah<ptr target="#note1" xml:id="nr1"/>    </p>   </div>  </body>    <back>   <div type="notes">    <note xml:id="note1">Blah was invented in the year Blah    </note>   </div>  <back>    

What I have merely takes the user from note 1 to the notes section of the page rather than to note 1's specific content. The other issue is that there are currently 50 notes within the document. So rather than matching and linking each note individually I wanted to dynamically assign each note to its corresponding place within the notelist. The best thing I could come up with was a for-each loop, but I wasn't sure how to increment to the next pointer (since they use xml:ids).

Here is basically the xslt/html that I have.

  <xsl:template match="/">      <html>          <head>              <link rel="stylesheet" type="text/css" href="cranch.css"/>          </head>          <body>              <xsl:apply-templates/>              <xsl:call-template name="notelist"/>          </body>      </html>  </xsl:template>    <xsl:template match="tei:ptr[@target='#note1']">      <a href="#notelist">          <span class="noteRef">[1]</span>      </a>  </xsl:template>    <xsl:template name="notelist">      <a name="thenotes"><h1>Notes:</h1></a>      <ol>          <xsl:for-each select="//tei:back/descendant::tei:note">              <li>                  <xsl:apply-templates/>              </li>          </xsl:for-each>      </ol>  </xsl:template>    

Somewhat irrelated question: I don't understand how my link anchor "thenotes" works precisely. Previously, I used #thenotes in my href declaration, but when I changed it to #notelist (without changing the name in the second part), the link still brought me to the link destination. I assumed this meant I could omit the:

  <a name"thenotes">    

but that did not work.

Tiada ulasan:

Catat Ulasan