<?xml version="1.0"?>
<!-- addids1.xsl: Add ID values to all entry-elements that don't have them. -->
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
  <xsl:output method="xml"/>
<!-- Adderar ett attribut 'id' for varje element som matchar xpathen
     'p|xref' och via funktionen 'generate-id()' tilldelar detta ett 
     unikt vaerde - *om* det inte redan finns ett id.
     Andra bara xpathen 'p|xrf' sa att den matchar de element du vill 
     generera IDn for -->
  <xsl:template match="p|xref">
    <xsl:copy>
    <xsl:if test="not(@id)">
      <xsl:attribute name="id">
        <xsl:value-of select="generate-id()"/>
      </xsl:attribute>
    </xsl:if>
      <xsl:apply-templates select="@*|node()"/>
    </xsl:copy>
  </xsl:template>

  <xsl:template match="@*|processing-instruction()|comment()|node()">
    <xsl:copy>
      <xsl:apply-templates select="@*|node()"/>
    </xsl:copy>
  </xsl:template>

</xsl:stylesheet>
