<?xml version="1.0" encoding="utf-8"?>
<xsl:transform xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                version="1.0">


  <!-- blogTEI - Francois Lachance - TEIblog-->

  <!-- this is a template to include in a XSLT file -->
  <!-- it is desiged to disply URL reference  -->
  <!-- it targets markup of ref elements -->
 
  <!-- see TEI Guidelines for more on the content model -->
  <!-- see XSLT Recomendation for more on templates and AVT -->

  <xsl:output method="html"/>

<xsl:template match="ref">
  <!-- compares value of target attribute on ref element -->
  <!-- to value of id attribute on item element -->
  <xsl:param name="urlbuild" select="@target"/>
  <xsl:if test="//back/div/list/item/@id=$urlbuild">
    <!-- builds an HTML anchor element -->
    <a href="{//back/div/list/item[@id=$urlbuild]}"><xsl:value-of select="."/></a>
  </xsl:if>
</xsl:template>



<xsl:template match="ref[@type='jardin']">

  <!-- blogTEI - Francois Lachance - TEIblog-->

  <!-- this is a template to include in a XSLT file -->
  <!-- it is desiged to create hyperlink   -->
  <!-- it targets markup of ref elements of type 'jardin' -->
  <!-- produces output dependent on content -->
  <!-- of num element of type "die_roll" -->

  <!-- see TEI Guidelines for more on the content model -->
  <!-- see XSLT Recomendation for more on templates -->

<xsl:param name="content" select="."/>
<xsl:param name="entryNo" select="@target"/>

<xsl:if test="//div/head/num/@id=$entryNo">

  <!-- if "die_roll" 2, send to blogTEI.htm with fragment identifier -->
  <xsl:if test="//div/head[num/@id=$entryNo]/num[@type='die_roll']='2'">
    <a href="../html/blogTEI.htm#{concat(//div/head[num/@id=$entryNo]/index/@level1,//div/head[num/@id=$entryNo]/num[@type='accession'])}"><xsl:value-of select="$content"/>
</a>
</xsl:if>

  <!-- if "die_roll" 3, send to TEIblog.htm with fragment identifier -->
  <xsl:if test="//div/head[num/@id=$entryNo]/num[@type='die_roll']='3'">
    <a href="../html/TEIblog.htm#{concat(//div/head[num/@id=$entryNo]/index/@level1,//div/head[num/@id=$entryNo]/num[@type='accession'])}"><xsl:value-of select="$content"/>
</a>
</xsl:if>

  <!-- if "die_roll" 4, send to invertblogTEI.htm with fragment identifier -->
  <xsl:if test="//div/head[num/@id=$entryNo]/num[@type='die_roll']='4'">
    <a href="../html/invertblogTEI.htm#{concat(//div/head[num/@id=$entryNo]/index[@level1='category'],//div/head[num/@id=$entryNo]/num[@type='accession'])}"><xsl:value-of select="$content"/>
</a>
</xsl:if>

 <!-- if "die_roll" 5, send to invertTEIblog.htm with fragment identifier -->
  <xsl:if test="//div/head[num/@id=$entryNo]/num[@type='die_roll']='5'">
    <a href="../html/invertTEIblog.htm#{concat(//div/head[num/@id=$entryNo]/index/@level1,//div/head[num/@id=$entryNo]/num[@type='accession'])}"><xsl:value-of select="$content"/>
</a>
</xsl:if>

 <!-- if "die_roll" 1, send to blogTEI.htm with fragment identifier -->
 <xsl:if test="//div/head[num/@id=$entryNo]/num[@type='die_roll']='1'">
  <a href="../html/blogTEI.htm#{concat(//div/head[num/@id=$entryNo]/index/@level1,//div/head[num/@id=$entryNo]/num[@type='accession'])}"><xsl:value-of select="$content"/>
</a>
</xsl:if>

<!-- if "die_roll" 6, send to xml file -->
<xsl:if test="//div/head[num/@id=$entryNo]/num[@type='die_roll']='6'">
    <a href="../xml/jardin.xml"><xsl:value-of select="$content"/>
</a>
</xsl:if>

</xsl:if>


</xsl:template>


</xsl:transform>

