<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:m="http://www.w3.org/1998/Math/MathML"
+ xmlns:helm="http://www.cs.unibo.it/helm"
xmlns:xlink="http://www.w3.org/1999/xlink">
<!--***********************************************************************-->
<xsl:import href="links_library.xsl"/>
-<xsl:template match="*[@xlink:href]">
- <xsl:copy>
- <xsl:copy-of select="@*"/>
- <xsl:attribute name="xlink:href">
- <xsl:call-template name="makeURL">
- <xsl:with-param name="uri" select="@xlink:href"/>
- </xsl:call-template>
- </xsl:attribute>
- <xsl:attribute name="xlink:show">other</xsl:attribute>
+<xsl:key name="id" use="@id" match="m:*"/>
+
+<xsl:template match = "m:semantics">
+ <xsl:apply-templates select="*[1]" mode="semantics"/>
+</xsl:template>
+
+<!-- Discharging content markup mantaining the linking info (helm:xref and
+xlink:href) -->
+<xsl:template match = "*" mode="semantics">
+ <xsl:copy>
+ <xsl:copy-of select="@*"/>
+ <xsl:if test="@xref">
+ <xsl:variable name="cnode" select="key('id',@xref)"/>
+ <xsl:if test="$cnode/@definitionURL">
+ <xsl:attribute name="xlink:href">
+ <xsl:call-template name="makeURL"><xsl:with-param name="uri" select="$cnode/@definitionURL"/></xsl:call-template>
+ </xsl:attribute>
<!-- xlink:show='other' requires the exact modality to be -->
<!-- specified in non-xlink markup. The point is that the -->
<!-- element is already MathML ==> we can't add other -->
<!-- markup without introducing another new namespace. -->
<!-- So, for now no markup is used. -->
- <xsl:apply-templates/>
- </xsl:copy>
+ <xsl:attribute name="xlink:show">other</xsl:attribute>
+ </xsl:if>
+ <xsl:if test="$cnode/@helm:xref">
+ <xsl:attribute name="helm:xref">
+ <xsl:value-of select="$cnode/@helm:xref"/>
+ </xsl:attribute>
+ </xsl:if>
+ </xsl:if>
+ <xsl:apply-templates mode="semantics"/>
+ </xsl:copy>
</xsl:template>
<!-- _top to refresh the whole frameset (avoids the matrioska effect ;-) -->
-<xsl:template match="a[@href]">
+<!-- a[@href] doesn't match with every anchor elements!!! -->
+<xsl:template match="*[@href]">
<xsl:copy>
<xsl:copy-of select="@*"/>
- <xsl:attribute name="href">
- <xsl:call-template name="makeURL">
- <xsl:with-param name="uri" select="@href"/>
- </xsl:call-template>
- </xsl:attribute>
- <xsl:attribute name="target">cic</xsl:attribute>
+ <xsl:choose>
+ <xsl:when test="starts-with(@href,"cic:")">
+ <xsl:attribute name="href">
+ <xsl:call-template name="makeURL">
+ <xsl:with-param name="uri" select="@href"/>
+ </xsl:call-template>
+ </xsl:attribute>
+ <xsl:attribute name="target">cic</xsl:attribute>
+ </xsl:when>
+ <xsl:when test="starts-with(@href,"theory:")">
+ <xsl:attribute name="href">
+ <xsl:call-template name="makeTheoryURL">
+ <xsl:with-param name="uri" select="@href"/>
+ </xsl:call-template>
+ </xsl:attribute>
+ <xsl:attribute name="target">theory</xsl:attribute>
+ </xsl:when>
+ <xsl:when test="starts-with(@href,"#")">
+ <xsl:attribute name="href"><xsl:value-of select="@href"/></xsl:attribute>
+ <xsl:if test="@target">
+ <xsl:attribute name="target"><xsl:value-of select="@target"/></xsl:attribute>
+ </xsl:if>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:attribute name="href"><xsl:value-of select="@href"/></xsl:attribute>
+ <xsl:attribute name="target">_blank</xsl:attribute>
+ </xsl:otherwise>
+ </xsl:choose>
<xsl:apply-templates/>
</xsl:copy>
</xsl:template>