+ <xsl:variable name="uri_after_sharp" select="substring-after($uri,'#')"/>
+ <xsl:variable name="cleanuri">
+ <xsl:choose>
+ <xsl:when test="$uri_after_sharp">
+ <xsl:value-of select="substring-before($uri,'#')"/>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:value-of select="$uri"/>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:variable>
+ <xsl:variable name="sharpsuffix">
+ <xsl:choose>
+ <xsl:when test="$uri_after_sharp">%23<xsl:value-of select="$uri_after_sharp"/></xsl:when>
+ <xsl:otherwise></xsl:otherwise>
+ </xsl:choose>
+ </xsl:variable>
+ <xsl:value-of select="$biquotedfixedheader"/>
+ <xsl:value-of select="$cleanuri"/>%26param.CICURI%3D<xsl:value-of select="$cleanuri"/>
+ <xsl:value-of select="$sharpsuffix"/>
+</xsl:template>
+
+<xsl:template name="makeTheoryURL">
+<xsl:param name="uri" select="''"/>
+ <xsl:variable name="uri_after_sharp" select="substring-after($uri,'#')"/>
+ <xsl:variable name="cleanuri">
+ <xsl:choose>
+ <xsl:when test="$uri_after_sharp">
+ <xsl:value-of select="substring-before($uri,'#')"/>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:value-of select="$uri"/>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:variable>
+ <xsl:variable name="sharpsuffix">
+ <xsl:choose>
+ <xsl:when test="$uri_after_sharp">%23<xsl:value-of select="$uri_after_sharp"/></xsl:when>
+ <xsl:otherwise></xsl:otherwise>
+ </xsl:choose>
+ </xsl:variable>
+ <xsl:value-of select="$biquotedthfixedheader"/>
+ <xsl:value-of select="$cleanuri"/>%26param.CICURI%3D<xsl:value-of select="$cleanuri"/>
+ <xsl:value-of select="$sharpsuffix"/>