<?xml version="1.0" encoding="utf-8"?>
<?xml-stylesheet href="/pool/xslt_ht.xslt" type="application/xml"?>
<?install location = "admin/attrvals.xslt"?>
<xsl:stylesheet
  xmlns = "http://www.w3.org/1999/xhtml"
  xmlns:d = "http://herbaer.de/xmlns/20051201/doc"
  xmlns:ht = "http://www.w3.org/1999/xhtml"
  xmlns:xsl = "http://www.w3.org/1999/XSL/Transform"
  xmlns:xl = "http://www.w3.org/1999/xlink"
  version = "1.0"
  exclude-result-prefixes = "d xl"
>
<!--
  Liste von Attributwerten
  2020-06-19 Herbert Schiemann <h.schiemann@herbaer.de>
  Borkener Str. 167, 46284 Dorsten, Germany
  GPL Version 2 oder neuer
-->
<d:info xmlns="http://herbaer.de/xmlns/20051201/doc">
  <title>attrvals.xslt</title>
  <subtitle>Liste von Attributwerten</subtitle>
  <date>2020-06-19</date>
  <author>
    <personname>
      <firstname>Herbert</firstname>
      <surname>Schiemann</surname>
    </personname>
    <email>h.schiemann@herbaer.de</email>
  </author>
</d:info>

<d:section role="stylesheet">
  <title>Typische Anwendung</title>
  <programlisting>
xsltproc attrvals.xslt STYLESHEET.xslt &gt; ATTRIBUTWERTE.xhtml
  </programlisting>
</d:section>

<d:para>Komma-getrennte Liste der Attributnamen</d:para>
<xsl:param name="p_attrnames" select="'x-h,x-l,id,mode,class'"/>

<d:para>Pfad des Dokuments</d:para>
<xsl:param name="p_docpath" select="'/style/pinw.xslt'"/>

<d:para>Wurzel des XML-Dokuments</d:para>
<xsl:variable name="g_docroot" select="document($p_docpath)/*"/>

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

<d:para>
Einträge in einer Liste einfach
</d:para>
<xsl:include href="/pool/applyunique.xslt"/>

<d:para>
Vorlagen für einfachen Text
</d:para>
<xsl:include href="/pool/txt.xslt"/>

<d:para>Rahmen</d:para>
<xsl:template match="/">
  <xsl:variable name="title" select="concat ('Attributwerte ', $p_docpath)"/>
  <html>
    <head>
      <title><xsl:value-of select="$title"/></title>
    </head>
    <body>
      <h1><xsl:value-of select="$title"/></h1>
      <xsl:call-template name="txt.split">
        <xsl:with-param name="txt" select="$p_attrnames"/>
        <xsl:with-param name="sep" select="','"/>
        <xsl:with-param name="elem" select="document('')/xsl:stylesheet/xsl:template [@name = 'attrvalues']"
        />
      </xsl:call-template>
    </body>
  </html>
</xsl:template>

<d:para>Liste der Werte eines Attributs</d:para>
<xsl:template name="attrvalues" mode="txt.apply" match="xsl:template [@name = 'attrvalues']"
>
  <!-- der Attributname -->
  <xsl:param name="txt"/>
  <div id="attr.{$txt}">
    <h2><xsl:value-of select="concat('Attribut ', $txt)"/></h2>
    <ul>
      <xsl:call-template name="apply_unique">
        <!-- Liste der Attributwerte -->
        <xsl:with-param name="inlist">
          <xsl:for-each select="$g_docroot//@*[local-name() = $txt]">
            <xsl:value-of select="concat(' ', .)"/>
          </xsl:for-each>
        </xsl:with-param>
        <xsl:with-param name="element" select="document('')/xsl:stylesheet/xsl:template [@name = 'put_value']"
        />
      </xsl:call-template>
    </ul>
  </div>
</xsl:template>

<d:para>
Attributwert ausgeben,
aufgerufen aus der Vorlage <d:literal>attrvalues</d:literal>
</d:para>
<xsl:template name="put_value" mode="xslt_apply" match="xsl:template [@name = 'put_value']"
>
  <!-- der Attributwert -->
  <xsl:param name="name"/>
  <li><xsl:value-of select="$name"/></li>
</xsl:template>

</xsl:stylesheet>
