<?xml version="1.0" encoding="utf-8"?>
<?xml-stylesheet href="/pool/xslt_ht.xslt" type="application/xml"?>
<xsl:stylesheet
  xmlns = "http://www.w3.org/1999/xhtml"
  xmlns:xsl = "http://www.w3.org/1999/XSL/Transform"
  xmlns:d = "http://herbaer.de/xmlns/20051201/doc"
  xmlns:ht = "http://www.w3.org/1999/xhtml"
  xmlns:xl = "http://www.w3.org/1999/xlink"
  version = "1.0"
  exclude-result-prefixes = "d ht xl"
>

<d:info xmlns="http://herbaer.de/xmlns/20051201/doc">
  <title>xhtml_settarget.xslt</title>
  <subtitle>Attribut a/@target setzen</subtitle>
  <date>2011-06-11</date>
  <author>
    <personname>
      <firstname>Herbert</firstname>
      <surname>Schiemann</surname>
    </personname>
    <email>h.schiemann@herbaer.de</email>
  </author>
</d:info>

<d:para>
Default-Wert des Attributs <d:code>a/@target</d:code>
</d:para>
<xsl:param name="p_target" select="'_blank'"/>

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

<xsl:template match="ht:a">
  <xsl:copy>
    <xsl:apply-templates select="@*"/>
    <xsl:if test="not (@target)">
      <xsl:attribute name="target">
        <xsl:value-of select="$p_target"/>
      </xsl:attribute>
    </xsl:if>
    <xsl:apply-templates select="* | text()"/>
  </xsl:copy>
</xsl:template>

<d:para>Alle anderen Elemente kopieren</d:para>
<xsl:template match="*">
  <xsl:copy>
    <xsl:apply-templates select="@*|*|text()"/>
  </xsl:copy>
</xsl:template>

<d:para>Attribute werden kopiert</d:para>
<xsl:template match="@*">
  <xsl:copy-of select="."/>
</xsl:template>

</xsl:stylesheet>
