<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">
<!--***********************************************************************-->
<!-- First draft: March 16 2001, Irene Schena -->
<!--***********************************************************************-->
-<xsl:param name="getterURL" select="'http://localhost:8081/'"/>
-<xsl:param name="processorURL" select="'http://localhost:8080/helm/servlet/uwobo/'"/>
-<xsl:param name="keys" select="'C1,HC2'"/>
-<xsl:param name="naturalLanguage" select="'yes'"/>
-<xsl:param name="annotations" select="'no'"/>
-<xsl:param name="media-type" select="'xhtml'"/>
-<xsl:param name="doctype-public" select="'-//W3C//DTD XHTML 1.0 Transitional//EN'"/>
-<xsl:param name="encoding" select="iso-8859-1"/>
+<xsl:import href="links_library.xsl"/>
-<xsl:variable name="absPath"><xsl:value-of select="$getterURL"/>getxml?uri=</xsl:variable>
+<xsl:key name="id" use="@id" match="m:*"/>
-<xsl:variable name="header"><xsl:value-of select="$processorURL"/>apply?keys=<xsl:value-of select="$keys"/>&param.naturalLanguage=<xsl:value-of select="$naturalLanguage"/>&param.annotations=<xsl:value-of select="$annotations"/>&prop.media-type=<xsl:value-of select="$media-type"/>&prop.doctype-public=<xsl:value-of select="$doctype-public"/>&prop.encoding=<xsl:value-of select="$encoding"/>&param.keys=<xsl:value-of select="$keys"/>&param.getterURL=<xsl:value-of select="$getterURL"/>&param.processorURL=<xsl:value-of select="$processorURL"/>&xmluri=<xsl:value-of select="$absPath"/></xsl:variable>
-
-<xsl:template name="makeURL">
-<xsl:param name="uri" select="''"/>
- <xsl:value-of select="concat(string($header),string($uri),'&param.CICURI=',string($uri))"/>
+<xsl:template match = "m:semantics">
+ <xsl:apply-templates select="*[1]" mode="semantics"/>
</xsl:template>
-<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:apply-templates/>
- </xsl:copy>
+<!-- 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: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>
-<xsl:template match="a[@href]">
+<!-- _top to refresh the whole frameset (avoids the matrioska effect ;-) -->
+<!-- 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: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>
</xsl:copy>
</xsl:template>
-</xsl:stylesheet>
\ No newline at end of file
+</xsl:stylesheet>