<?xml version="1.0" encoding="utf-8"?>
<?xml-stylesheet href="/pool/xslt_ht.xslt" type="application/xml"?>
<xsl:stylesheet
  xmlns:xsl = "http://www.w3.org/1999/XSL/Transform"
  xmlns:l = "http://herbaer.de/xmlns/20141210/localization"
  xmlns:d = "http://herbaer.de/xmlns/20051201/doc"
  xmlns:h = "http://herbaer.de/xmlns/20121015/hash"
  exclude-result-prefixes = "d h"
  version = "1.0"
>
<d:info xmlns="http://herbaer.de/xmlns/20051201/doc">
  <title>localization_shortids.xslt</title>
  <subtitle>Kurze ID-Werte in Lokalisierungs-Platzhalter einsetzen</subtitle>
  <date>2016-01-05</date>
  <author>
    <personname>
      <firstname>Herbert</firstname>
      <surname>Schiemann</surname>
    </personname>
    <email>h.schiemann@herbaer.de</email>
  </author>
</d:info>

<d:para>
Pfad des XML-Dokuments mit den kurzen IDs der Platzhalter
</d:para>
<xsl:param name="p_shortids"/>

<d:para>
Das Wurzelelement der kurzen ID-Werte
</d:para>
<xsl:variable name="g_shortids" select="document ($p_shortids)/h:hash"/>

<xsl:output method="xml" encoding="utf-8"/>

<d:para>
Wurzel
</d:para>
<xsl:template match="/">
  <xsl:apply-templates select="text() | comment() | processing-instruction() | *"/>
</xsl:template>

<d:para>
Elemente werden "rekursiv" kopiert.
</d:para>
<xsl:template match="*">
  <xsl:copy>
    <xsl:apply-templates select="@* | * | text() | comment() | processing-instruction()"/>
  </xsl:copy>
</xsl:template>

<d:para>
Andere Knoten werden direkt kopiert.
</d:para>
<xsl:template match="@* | text() | comment() | processing-instruction()">
  <xsl:copy-of select="."/>
</xsl:template>

<d:para>
Ein Text zu einem Schlüssel
</d:para>
<xsl:template match="l:t | l:ph">
  <xsl:variable name="id" select="@id"/>
  <xsl:copy>
    <xsl:attribute name="id">
      <xsl:value-of select="$g_shortids/h:value[@key=$id]"/>
    </xsl:attribute>
    <xsl:apply-templates/>
  </xsl:copy>
</xsl:template>

</xsl:stylesheet>
