<?xml version="1.0" encoding="utf-8"?>
<?xml-stylesheet href="/pool/xslt_ht.xslt" type="application/xml"?>
<xsl:stylesheet
  xmlns = "http://docbook.org/ns/docbook"
  xmlns:d = "http://herbaer.de/xmlns/20051201/doc"
  xmlns:xsl = "http://www.w3.org/1999/XSL/Transform"
  xmlns:df = "http://herbaer.de/xmlns/20200620/docframejs/"
  xmlns:xl = "http://www.w3.org/1999/xlink"
  version = "1.0"
  exclude-result-prefixes = "d"
>
<!--
  docframe zu docbook
  2020-06-20 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>docframe_db.xslt</title>
  <subtitle>docframe zu docbook</subtitle>
  <date>2020-06-20</date>
  <author>
    <personname>
      <firstname>Herbert</firstname>
      <surname>Schiemann</surname>
    </personname>
    <email>h.schiemann@herbaer.de</email>
  </author>
</d:info>

<xsl:variable name="g_basename" select="/df:docframejs/df:basename"/>

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

<xsl:template match="/df:docframejs">
  <article>
    <xsl:apply-templates select="df:entries" mode="listing"/>
    <xsl:apply-templates select="df:entries" mode="varlist"/>
  </article>
</xsl:template>

<d:para>
Listing mit Verweisen
</d:para>
<xsl:template match="df:entries" mode="listing">
  <programlisting>
    <xsl:apply-templates select="df:entry" mode="listing"/>
  </programlisting>
</xsl:template>

<d:para>
Eine Variable im Code-Listing
</d:para>
<xsl:template match="df:entry[df:type = 'var']" mode="listing">
  <xsl:text>var </xsl:text>
  <varname xl:href="#{$g_basename}.{df:key}">
    <xsl:value-of select="df:key"/>
  </varname>
  <xsl:text>
</xsl:text>
</xsl:template>

<d:para>
Eine Funktion im Code-Listing
</d:para>
<xsl:template match="df:entry[df:type = 'func']" mode="listing">
  <xsl:text>function </xsl:text>
  <function xl:href="#{$g_basename}.{df:key}">
    <xsl:value-of select="df:key"/>
  </function>
  <xsl:apply-templates select="df:args" mode="funclisting"/>
  <xsl:text>
</xsl:text>
</xsl:template>

<d:para>
Argumentliste zu einer Funktion
</d:para>
<xsl:template match="df:args" mode="funclisting">
  <xsl:text> (</xsl:text>
  <xsl:apply-templates select="df:arg" mode="listing"/>
  <xsl:text>)</xsl:text>
</xsl:template>

<d:para>
Eine Methode im Code-Listing
</d:para>
<xsl:template match="df:entry[df:type = 'method']" mode="listing">
  <function xl:href="#{$g_basename}.{df:class}">
    <xsl:value-of select="df:class"/>
  </function>
  <xsl:text>.prototype.</xsl:text>
  <function xl:href="#{$g_basename}.{df:class}.{df:key}">
    <xsl:value-of select="df:key"/>
  </function>
  <xsl:apply-templates select="df:args" mode="methodlisting"/>
  <xsl:text>
</xsl:text>
</xsl:template>

<d:para>
Argumentliste zu einer Methode
</d:para>
<xsl:template match="df:args" mode="methodlisting">
  <xsl:text> = function (</xsl:text>
  <xsl:apply-templates select="df:arg" mode="listing"/>
  <xsl:text>)</xsl:text>
</xsl:template>

<d:para>
Argument einer Funktion im  Listing
</d:para>
<xsl:template match="df:arg" mode="listing">
  <xsl:if test="position() &gt; 1">
    <xsl:text>, </xsl:text>
  </xsl:if>
  <xsl:value-of select="."/>
</xsl:template>

<d:para>
Liste der Programm-Elemente
</d:para>
<xsl:template match="df:entries" mode="varlist">
  <variablelist>
    <xsl:apply-templates select="df:entry" mode="varlist"/>
  </variablelist>
</xsl:template>

<d:para>
Dokumentation zu einer Variablen
</d:para>
<xsl:template match="df:entry[df:type = 'var']" mode="varlist">
  <varlistentry>
    <xsl:attribute name="xml:id">
      <xsl:value-of select="concat ($g_basename, '.', df:key)"/>
    </xsl:attribute>
    <term>
      <code>
        <xsl:text>var </xsl:text>
        <varname>
          <xsl:value-of select="df:key"/>
        </varname>
        <xsl:apply-templates select="df:args" mode="funclisting"/>
      </code>
    </term>
    <listitem>
      <para>
        <xsl:text>
        </xsl:text>
      </para>
    </listitem>
  </varlistentry>
</xsl:template>

<d:para>
Dokumentation zu einer Funktion
</d:para>
<xsl:template match="df:entry[df:type = 'func']" mode="varlist">
  <varlistentry>
    <xsl:attribute name="xml:id">
      <xsl:value-of select="concat ($g_basename, '.', df:key)"/>
    </xsl:attribute>
    <term>
      <code>
        <xsl:text>function </xsl:text>
        <function>
          <xsl:value-of select="df:key"/>
        </function>
        <xsl:apply-templates select="df:args" mode="funclisting"/>
      </code>
    </term>
    <listitem>
      <para>
        <xsl:text>
        </xsl:text>
      </para>
    </listitem>
  </varlistentry>
</xsl:template>

<d:para>
Dokumentation zu einer Methode
</d:para>
<xsl:template match="df:entry[df:type = 'method']" mode="varlist">
  <varlistentry>
    <xsl:attribute name="xml:id">
      <xsl:value-of select="concat ($g_basename, '.', df:class, '.', df:key)"/>
    </xsl:attribute>
    <term>
      <code>
        <function xl:href="#{$g_basename}.{df:class}">
          <xsl:value-of select="df:class"/>
        </function>
        <xsl:text>.prototype.</xsl:text>
        <function>
          <xsl:value-of select="df:key"/>
        </function>
        <xsl:apply-templates select="df:args" mode="methodlisting"/>
      </code>
    </term>
    <listitem>
      <para>
        <xsl:text>
        </xsl:text>
      </para>
    </listitem>
  </varlistentry>
</xsl:template>

</xsl:stylesheet>
