<commit_before><?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns="http://www.w3.org/1999/xhtml" xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns:d="http://docbook.org/ns/docbook" exclude-result-prefixes="xsl d xhtml">

<xsl:import href="article-edit-xhtml.xsl" />

<xsl:output method="xml" indent="no" omit-xml-declaration="yes"/>

<xsl:template match="/">
    <html xmlns="http://www.w3.org/1999/xhtml"
        xmlns:xsd="http://www.w3.org/2001/XMLSchema#"
        xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"
        xmlns:calli="http://callimachusproject.org/rdf/2009/framework#">
    <head>
        <title><xsl:value-of select="/*/d:title|/*/d:info/d:title" /></title>
        <link rel="edit-form" href="?edit" />
        <link rel="describedby" href="?describe" />
        <link rel="version-history" href="?history" />
        <xsl:apply-templates mode="rel" />
        <style type="text/css">
            .anchor { font-size: smaller; }
            ul.toc { list-style: none; }
        </style>
    </head>
    <body>
        <xsl:apply-templates />
    </body>
    </html>
</xsl:template>

<xsl:template mode="rel" match="node()" />

<xsl:template mode="rel" match="d:actknowledgements|d:appendix|d:article|d:bibliography|d:book|d:chapter|d:colophon|d:dedication|d:glossary|d:index|d:para|d:part|d:preface|d:refentry|d:reference|d:section|d:toc|d:set|d:setindex">
    <xsl:if test="base-uri()!=base-uri(..)">
        <link rel="section" href="{base-uri()}" type="application/docbook+xml" />
    </xsl:if>
    <xsl:apply-templates mode="rel" />
</xsl:template>

<xsl:template match="d:book">
    <div class="book">
        <xsl:apply-templates select="@xml:id" />
        <xsl:apply-templates select="d:info|d:title|d:preface" />
        <nav>
            <h3>Table of Contents</h3>
            <ul class="toc">
                <xsl:apply-templates mode="toc" />
            </ul>
        </nav>
        <xsl:apply-templates select="*[not(self::d:info|self::d:title|self::d:preface)]" />
    </div>
</xsl:template>

<xsl:template match="d:part">
    <div class="part">
        <xsl:apply-templates select="@xml:id" />
        <xsl:apply-templates select="d:info|d:title|d:preface|d:partintro" />
        <nav>
            <h3>Contents</h3>
            <ul class="toc">
                <xsl:apply-templates mode="toc" />
            </ul>
        </nav>
        <xsl:apply-templates select="*[not(self::d:info|self::d:title|self::d:preface|self::d:partintro)]" />
    </div>
    <xsl:if test="following-sibling::*">
        <hr />
    </xsl:if>
</xsl:template>

<xsl:template match="d:chapter">
    <div class="chapter">
        <xsl:apply-templates select="@xml:id" />
        <xsl:apply-templates select="d:info|d:title" />
        <nav>
            <h3>Contents</h3>
            <ul class="toc">
                <xsl:apply-templates mode="toc" />
            </ul>
        </nav>
        <xsl:apply-templates select="*[not(self::d:info|self::d:title)]" />
    </div>
    <xsl:if test="following-sibling::*">
        <hr />
    </xsl:if>
</xsl:template>

<xsl:template match="d:info">
    <xsl:apply-templates select="d:title" />
    <xsl:apply-templates select="d:abstract" />
</xsl:template>

<xsl:template mode="toc" match="node()" />

<xsl:template mode="toc" match="d:chapter|d:part|d:article|d:appendix|d:chapter/d:section">
    <xsl:variable name="text">
        <xsl:value-of select="d:info/d:title|d:title" />
    </xsl:variable>
    <xsl:variable name="id">
        <xsl:choose>
            <xsl:when test="@xml:id">
                <xsl:value-of select="@xml:id" />
            </xsl:when>
            <xsl:otherwise>
                <xsl:value-of select="replace(normalize-space($text), '\W','_')" />
            </xsl:otherwise>
        </xsl:choose>
    </xsl:variable>
    <li>
        <xsl:apply-templates mode="heading-prefix" select="d:info/d:title|d:title" />
        <a href="#{$id}">
            <xsl:value-of select="$text" />
        </a>
        <xsl:if test="d:chapter|d:part|d:article|d:appendix or self::d:chapter/d:section">
            <ul class="toc">
                <xsl:apply-templates mode="toc" />
            </ul>
        </xsl:if>
    </li>
</xsl:template>

<xsl:template match="d:article">
    <article>
        <xsl:apply-templates select="@xml:id" />
        <xsl:apply-templates />
    </article>
    <xsl:if test="following-sibling::*">
        <hr />
    </xsl:if>
</xsl:template>

<!-- FIXME this should be part of docbook2xhtml -->
<xsl:template match="d:figure">
    <figure>
        <xsl:apply-templates select="@xml:id" />
        <xsl:apply-templates select="d:mediaobject|d:caption" />
        <xsl:if test="not(d:caption)">
            <figcaption>
                <xsl:apply-templates select="d:info/d:title/node()|d:title/node()" />
            </figcaption><commit_msg>Don't wrap book/articles in tags<commit_after><?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns="http://www.w3.org/1999/xhtml" xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns:d="http://docbook.org/ns/docbook" exclude-result-prefixes="xsl d xhtml">

<xsl:import href="article-edit-xhtml.xsl" />

<xsl:output method="xml" indent="no" omit-xml-declaration="yes"/>

<xsl:template match="/">
    <html xmlns="http://www.w3.org/1999/xhtml"
        xmlns:xsd="http://www.w3.org/2001/XMLSchema#"
        xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"
        xmlns:calli="http://callimachusproject.org/rdf/2009/framework#">
    <head>
        <title><xsl:value-of select="/*/d:title|/*/d:info/d:title" /></title>
        <link rel="edit-form" href="?edit" />
        <link rel="describedby" href="?describe" />
        <link rel="version-history" href="?history" />
        <xsl:apply-templates mode="rel" />
        <style type="text/css">
            .anchor { font-size: smaller; }
            ul.toc { list-style: none; }
        </style>
    </head>
    <body>
        <xsl:apply-templates />
    </body>
    </html>
</xsl:template>

<xsl:template mode="rel" match="node()" />

<xsl:template mode="rel" match="d:actknowledgements|d:appendix|d:article|d:bibliography|d:book|d:chapter|d:colophon|d:dedication|d:glossary|d:index|d:para|d:part|d:preface|d:refentry|d:reference|d:section|d:toc|d:set|d:setindex">
    <xsl:if test="base-uri()!=base-uri(..)">
        <link rel="section" href="{base-uri()}" type="application/docbook+xml" />
    </xsl:if>
    <xsl:apply-templates mode="rel" />
</xsl:template>

<xsl:template match="d:book">
    <xsl:apply-templates select="@xml:id" />
    <xsl:apply-templates select="d:info|d:title|d:preface" />
    <nav>
        <h3>Table of Contents</h3>
        <ul class="toc">
            <xsl:apply-templates mode="toc" />
        </ul>
    </nav>
    <xsl:apply-templates select="*[not(self::d:info|self::d:title|self::d:preface)]" />
</xsl:template>

<xsl:template match="d:part">
    <xsl:apply-templates select="@xml:id" />
    <xsl:apply-templates select="d:info|d:title|d:preface|d:partintro" />
    <nav>
        <h3>Contents</h3>
        <ul class="toc">
            <xsl:apply-templates mode="toc" />
        </ul>
    </nav>
    <xsl:apply-templates select="*[not(self::d:info|self::d:title|self::d:preface|self::d:partintro)]" />
    <xsl:if test="following-sibling::*">
        <hr />
    </xsl:if>
</xsl:template>

<xsl:template match="d:chapter">
    <xsl:apply-templates select="@xml:id" />
    <xsl:apply-templates select="d:info|d:title" />
    <nav>
        <h3>Contents</h3>
        <ul class="toc">
            <xsl:apply-templates mode="toc" />
        </ul>
    </nav>
    <xsl:apply-templates select="*[not(self::d:info|self::d:title)]" />
    <xsl:if test="following-sibling::*">
        <hr />
    </xsl:if>
</xsl:template>

<xsl:template match="d:info">
    <xsl:apply-templates select="d:title" />
    <xsl:apply-templates select="d:abstract" />
</xsl:template>

<xsl:template mode="toc" match="node()" />

<xsl:template mode="toc" match="d:chapter|d:part|d:article|d:appendix|d:chapter/d:section">
    <xsl:variable name="text">
        <xsl:value-of select="d:info/d:title|d:title" />
    </xsl:variable>
    <xsl:variable name="id">
        <xsl:choose>
            <xsl:when test="@xml:id">
                <xsl:value-of select="@xml:id" />
            </xsl:when>
            <xsl:otherwise>
                <xsl:value-of select="replace(normalize-space($text), '\W','_')" />
            </xsl:otherwise>
        </xsl:choose>
    </xsl:variable>
    <li>
        <xsl:apply-templates mode="heading-prefix" select="d:info/d:title|d:title" />
        <a href="#{$id}">
            <xsl:value-of select="$text" />
        </a>
        <xsl:if test="d:chapter|d:part|d:article|d:appendix or self::d:chapter/d:section">
            <ul class="toc">
                <xsl:apply-templates mode="toc" />
            </ul>
        </xsl:if>
    </li>
</xsl:template>

<xsl:template match="d:article">
    <xsl:apply-templates select="@xml:id" />
    <xsl:apply-templates />
    <xsl:if test="following-sibling::*">
        <hr />
    </xsl:if>
</xsl:template>

<!-- FIXME this should be part of docbook2xhtml -->
<xsl:template match="d:figure">
    <figure>
        <xsl:apply-templates select="@xml:id" />
        <xsl:apply-templates select="d:mediaobject|d:caption" />
        <xsl:if test="not(d:caption)">
            <figcaption>
                <xsl:apply-templates select="d:info/d:title/node()|d:title/node()" />
            </figcaption>
{'fraction_non_alphanumeric': 0.21314515298238385, 'fraction_numerical': 0.011744102194292779, 'mean_word_length': 2.9003615910004017, 'pattern_counts': {'":': 0, '<': 247, '<?xml version=': 2, '>': 247, 'https://': 0, 'lorem ipsum': 0, 'www.': 14, 'xml': 40}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2991639', 'n_tokens_mistral': 3772, 'n_tokens_neox': 3433, 'n_words': 448}