<xsl:import href="objcontent.xsl"/>
-<xsl:key name="id" use="@id" match="LAMBDA|PROD|CAST|REL|SORT|APPLY|VAR|META|CONST|MUTIND|MUTCONSTRUCT|MUTCASE|FIX|COFIX|Definition|Axiom|CurrentProof|InductiveDefinition|Variable"/>
-
-<xsl:key name="annid" use="@of" match="Annotation"/>
+<xsl:key name="id" use="@id" match="LAMBDA|LETIN|PROD|CAST|REL|SORT|APPLY|VAR|META|CONST|MUTIND|MUTCONSTRUCT|MUTCASE|FIX|COFIX|Definition|Axiom|CurrentProof|InductiveDefinition|Variable"/>
<xsl:template match="Definition|Axiom|CurrentProof|InductiveDefinition|Variable">
+ <xsl:variable name="id" select="@id"/>
<xsl:choose>
- <xsl:when test="key('annid',@id)">
+ <xsl:when test="$annotations='yes' and $CICAnnotations/Annotations/Annotation[@of=$id]">
<annotation helm:xref="{@id}">
- <xsl:apply-templates select="key('annid',@id)"/>
+ <xsl:apply-templates select="$CICAnnotations/Annotations/Annotation[@of=$id]"/>
</annotation>
</xsl:when>
<xsl:otherwise>
</xsl:choose>
</xsl:template>
-<xsl:template match="LAMBDA|PROD|CAST|REL|SORT|APPLY|VAR|META|CONST|MUTIND|MUTCONSTRUCT|MUTCASE|FIX|COFIX">
+<xsl:template match="LAMBDA|LETIN|PROD|CAST|REL|SORT|APPLY|VAR|META|CONST|MUTIND|MUTCONSTRUCT|MUTCASE|FIX|COFIX">
+ <xsl:variable name="id" select="@id"/>
<xsl:choose>
- <xsl:when test="key('annid',@id)">
+ <xsl:when test="$annotations='yes' and $CICAnnotations/Annotations/Annotation[@of=$id]">
<annotation helm:xref="{@id}">
- <xsl:apply-templates select="key('annid',@id)"/>
+ <xsl:apply-templates select="$CICAnnotations/Annotations/Annotation[@of=$id]"/>
</annotation>
</xsl:when>
<xsl:otherwise>
</xsl:choose>
</xsl:template>
-<xsl:template match="node">
- <xsl:variable name="id" select="@id"/>
+<!-- The next two templates must be invoked with the context node -->
+<!-- belonging to the original document DOM tree -->
+
+<xsl:template mode="changecontextdocumentnode" match="*">
+ <xsl:param name="id" select="''"/>
<xsl:apply-templates select="key('id',$id)"/>
</xsl:template>
-<xsl:template match="attribute">
- <xsl:variable name="id" select="@id"/>
- <xsl:variable name="name" select="@name"/>
- <xsl:variable name="child" select="@child"/>
- <xsl:variable name="grandchild" select="@grandchild"/>
+<xsl:template mode="changecontextdocumentattribute" match="*">
+ <xsl:param name="id" select="''"/>
+ <xsl:param name="name" select="''"/>
+ <xsl:param name="child" select="''"/>
+ <xsl:param name="grandchild" select="''"/>
<xsl:choose>
<xsl:when test="$child">
<xsl:choose>
</xsl:choose>
</xsl:template>
+<!-- $cicroot holds the root of the original document DOM tree -->
+<!-- The next two templates are trampolines to the previous two -->
+<!-- that are used to change the context node to a node in the -->
+<!-- document DOM tree of $cicroot -->
+
+<xsl:variable name="cicroot" select="/"/>
+
+<xsl:template match="node">
+ <xsl:apply-templates select="$cicroot/*[1]" mode="changecontextdocumentnode">
+ <xsl:with-param name="id" select="@id"/>
+ </xsl:apply-templates>
+</xsl:template>
+
+<xsl:template match="attribute">
+ <xsl:apply-templates select="$cicroot/*[1]" mode="changecontextdocumentattribute">
+ <xsl:with-param name="id" select="@id"/>
+ <xsl:with-param name="name" select="@name"/>
+ <xsl:with-param name="child" select="@child"/>
+ <xsl:with-param name="grandchild" select="@grandchild"/>
+ </xsl:apply-templates>
+</xsl:template>
+
</xsl:stylesheet>