+ <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"/>
+</xsl:template>
+
+<!-- makeURL4embedding() maps URIs into URLs -->
+<!-- The target of the URL is only the processed document -->
+
+<xsl:template name="makeURL4embedding">
+<xsl:param name="uri" select="''"/>
+<xsl:param name="type" select="'standalone'"/>
+ <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="$header1"/>
+ <xsl:value-of select="$quotedembedkeys"/>
+ <xsl:value-of select="$header2"/>
+ <xsl:value-of select="$bothheader2"/>
+ <xsl:value-of select="$cleanuri"/>&param.CICURI=<xsl:value-of select="$cleanuri"/>&param.type=<xsl:value-of select="$type"/><xsl:value-of select="$sharpsuffix"/>
+</xsl:template>
+
+<!-- makeURL4InnerTypes() maps URIs into URLs -->
+<!-- The target of the URL is only the processed document -->
+
+<xsl:template name="makeURL4InnerTypes">
+<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">