0

I am working with XSL version 3.0. How to highlight multiple targets in a same HTML page? For example:

First I have the TEI content to look to attribute value:

<ref n="1" target="#target1 #target2 #target3">some text</ref>

The related XSL

<xsl:template match="ref"> 
 <a href="{ref/@target}" id="{@xml:id}"><xsl:value-of select="ref[@n]"/></a>
</xsl:template>

Then, I am looking to these @xml:id values in TEI

<!-- target in @xml:id attribute -->
<l xml:id="target1">text A</l> 
<l xml:id="target2">text B</l>
<l xml:id="target3">text C</l> 

and the related XSL

<xsl:template match="l[@n]"> 
 <li><xsl:apply-templates/><!-- from previous element -->
  <sup><a href="{@xml:id}" name="{@xml:id}" id="line" ><xsl:value-of select="@n"/></a><sup>
 </li>
</xsl:template>

I'm looking to display in HTML:

<li>some text...<sup><a href="target1" name="target1" id="line">text A</a></sup></li>
<!--- other <li> -->
<!--- other <li> -->
<li>some text...textual content<sup><a href="target2" name="target2" id="line">text B</a></sup></li>
<!--- other <li> -->
<li>some text...textual content<sup><a href="target3" name="target3" id="line">text C</a></sup></li>

Each target is highlighted with CSS (a#line:focus). So, I would like to highlight all referenced targets in <a> when I click on the link. Is it possible?

In advance, thank you.

Vanessa
  • 121
  • 12
  • I don't think a single HTML hyperlink (an `a href` element can target more than one element at a time) so while you might be able to construct a link `...` that does not have any meaning in HTML and I don't think a user agent/browser will be able to recognize that this link relates to three named targets. And having various HTML elements with the same `id` attribute is also not within the HTML standard. – Martin Honnen Jan 22 '18 at 08:49
  • `I would like to highlight all referenced targets` I'm confused as to whether you are asking for help designing the HTML that delivers the required user experience in the browser, or whether you are asking for help writing the XSLT code to generate that HTML. It's best to keep the two things quite separate. – Michael Kay Jan 22 '18 at 10:43
  • Sorry @Michael if my explanation wasn't very clear. English matter... My @target points to @xml:id (a line). I'm looking in `XSLT` to highlight something similar from `HTML` form when we search for an occurrence: it highlights all requested occurrences in a webpage. Is there a way to do that in `XSLT` without a form? When a user clicks on a link, the requested lines are highlighted on the webpage. @Martin: so I need to find something else than `href` to display the lines I'm looking for since it's not possible with `href`. – Vanessa Jan 22 '18 at 13:57
  • The conventional way of using XSLT is to generate an HTML page, and it's a good idea to know what HTML you want to generate before you start writing XSLT code. XSLT doesn't highlight things: it generates HTML that highlights things. (If you're using Saxon-JS and interactive XSLT 3.0 in the browser, that story changes a little; but if that were the case, I think you'd have said so.) – Michael Kay Jan 22 '18 at 14:48
  • Apologize @Michael, and thanks for your advice for best practice to request assistance. I'm using `Saxon-PE 9.7`. I highlight with `CSS`, but I need first to indicate where the link points, and then use `CSS` for style (or I'm wrong?); that's why I thought I could do this with `XSLT`. Probably I should give up on my idea of highlighting several lines... – Vanessa Jan 22 '18 at 15:24

0 Answers0