Hints

Here are some hints, how the XSLT scripts should be modified. All these examples are taken from an XSLT transformer with XSL-FO result - feel free to modify these snippets for your result document appropriately.

First, you must define EuroMath2 namespace, of course. Just put this definition into root element of XSLT:

xmlns:emp="http://www.uniba.sk/euromath/reserved" xmlns:empar="http://www.uniba.sk/euromath/parameters"

Use the following template to handle emp:mark elements:

<xsl:template match="emp:mark">
  <xsl:copy-of select="."/>
</xsl:template>

You may safely ignore processing these elements if schema doesn't support inserting elements from another namespaces.

This template prints out the ID of node(s):

<!-- Prints ID of given node. -->
<xsl:template match="@*" mode="emp.id" priority="1">
  <xsl:value-of select="../@emp:id"/><xsl:text>@</xsl:text><xsl:value-of select="name()"/>:0
</xsl:template>
<xsl:template match="*" mode="emp.id" priority="1">
  <xsl:value-of select="@emp:id"/>:0
</xsl:template>
<xsl:template match="node()" mode="emp.id" priority="0">
  <xsl:value-of select="../@emp:id"/>;<xsl:value-of select="count(preceding-sibling::node())"/>:0
</xsl:template>

Note that the :0 part is optional and may not be used at all. It serves for diferencing equal IDs: when element is copied multiple times in the result XML file and the XML processor does not like multiple equal id attributes. You may replace :0 with some XSLT code that is able to generate unique values for one node, however this step is optional: XSLT/exporter, renderer and coordinator must be able to uniqualize emp:ids if they need unique ids.

To instantiate attribute containing ID of given node, the following snippet can be used: (note that this attribute is instantiated only when the emp:id attribute exists - it is useful for XSLT to be usable both with and without EuroMath)

<!-- Instantiates an id attribute for given node. -->
<xsl:template match="*" mode="emp.createIdAttr" priority="1">
  <xsl:if test="@emp:id">
    <xsl:attribute name="emp:id"><xsl:apply-templates select="." mode="emp.id"/></xsl:attribute>
  </xsl:if>
</xsl:template>
<xsl:template match="node() | @*" mode="emp.createIdAttr" priority="0">
  <xsl:if test="../@emp:id and $empar:processingSource">
    <xsl:attribute name="emp:id"><xsl:apply-templates select="." mode="emp.id"/></xsl:attribute>
  </xsl:if>
</xsl:template>

<xsl:value-of select="nodeset"> works OK, if you don't want to transport IDs of text. If you do, use <xsl:apply-templates select="nodeset" mode="emp.text"> instead, and put following template into your XSLT script:

<!-- Prints text value of given node with proper IDs, as if by the <xsl:value-of/> call. -->
<xsl:template match="*" mode="emp.text">
  <xsl:apply-templates mode="emp.text"/>
</xsl:template>
<xsl:template match="text()" mode="emp.text">
  <xsl:choose>
    <xsl:when test="../@emp:id and $empar:processingSource">
      <fo:inline>
        <xsl:apply-templates select="." mode="emp.createIdAttr"/>
        <xsl:value-of select="."/>
      </fo:inline>
    </xsl:when>
    <xsl:otherwise>
      <xsl:value-of select="."/>
    </xsl:otherwise>
  </xsl:choose>
</xsl:template>

Easiest way to transfer IDs of text is to define this template:

<!-- retains ids of all text nodes -->
<xsl:template match="text()">
  <apply-templates select="." mode="emp.text"/>
</xsl:template>

Because each element may contain the emp:id attribute, then we must replace all XPath tests such as @* with the following test:

@*[name()!='emp:id']

To detect whether the ID of context node is synthetic or not please use this template:

contains(substring-before(@emp:id, ':'), '@;')