<commit_before><?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    version="1.0">
    <xsl:template match="article" mode="article-modals">
        <!--
            Cria todos os modals do documento
        -->
        <!-- modal do contribs -->
        <xsl:apply-templates select="." mode="modal-contribs"/>

        <!-- modal que apresenta juntos figuras, tabelas e fórmulas -->
        <xsl:apply-templates select="." mode="modal-grouped-figs-tables-schemes"/>

        <!-- cria um modal para cada figura -->
        <xsl:apply-templates select="." mode="fig-individual-modal"/>
        
        <!-- cria um modal para cada tabela -->
        <xsl:apply-templates select="." mode="table-individual-modal"/>
        
        <!-- cria um modal para cada fórmula -->
        <xsl:apply-templates select="." mode="scheme-individual-modal"/>
        
        <!-- cria um modal para como citar -->
        <xsl:apply-templates select="." mode="modal-how2cite"/>
    </xsl:template>
    
    <xsl:template match="article" mode="table-individual-modal">
        <!--
            Cria um modal para cada tabela
            encontrada em article,
            de acordo com o idioma selecionado para o texto
        -->
        <xsl:variable name="translation" select=".//sub-article[@xml:lang=$TEXT_LANG and @article-type='translation']"/>

        <xsl:choose>
            <xsl:when test="$translation">
                <xsl:apply-templates select="front | $translation | back" mode="table-individual-modal"/>
            </xsl:when>
            <xsl:otherwise>
                <xsl:apply-templates select="front | body | back" mode="table-individual-modal"/>
            </xsl:otherwise>
        </xsl:choose>
    </xsl:template>
    
    <xsl:template match="front | body | back | sub-article" mode="table-individual-modal">
        <!-- cria um modal para cada tabela existente no body-->
        <xsl:apply-templates select=".//table-wrap[@xml:lang=$TEXT_LANG] | .//table-wrap[not(@xml:lang)]" mode="modal"/>
    </xsl:template>
    
    <xsl:template match="article" mode="scheme-individual-modal">
        <!--
            Cria um modal para cada fórmula
            encontrada em article,
            de acordo com o idioma selecionado para o texto
        -->
        <xsl:variable name="translation" select=".//sub-article[@xml:lang=$TEXT_LANG and @article-type='translation']"/>

        <xsl:choose>
            <xsl:when test="$translation">
                <xsl:apply-templates select="front | $translation | back" mode="scheme-individual-modal"/>
            </xsl:when>
            <xsl:otherwise>
                <xsl:apply-templates select="front | body | back" mode="scheme-individual-modal"/>
            </xsl:otherwise>
        </xsl:choose>
    </xsl:template>

    <xsl:template match="front | body | back | sub-article" mode="scheme-individual-modal">
        <!-- cria um modal para cada formula existente no body-->
        <xsl:apply-templates select=".//disp-formula[@id]" mode="modal"/>
    </xsl:template>
    
    <xsl:template match="article" mode="fig-individual-modal">
        <!--
            Cria um modal para cada figura
            encontrada em article,
            de acordo com o idioma selecionado para o texto
        -->
        <xsl:variable name="translation" select=".//sub-article[@xml:lang=$TEXT_LANG and @article-type='translation']"/>

        <xsl:choose>
            <xsl:when test="$translation">
                <xsl:apply-templates select="front | $translation | back" mode="fig-individual-modal"/>
            </xsl:when>
            <xsl:otherwise>
                <xsl:apply-templates select="front | body | back" mode="fig-individual-modal"/>
            </xsl:otherwise>
        </xsl:choose>
    </xsl:template>
    
    <xsl:template match="front | body | back | sub-article" mode="fig-individual-modal">
        <!-- cria um modal para cada figura existente no body-->
        <xsl:apply-templates select=".//fig-group[@id] | .//fig[@id]" mode="modal"></xsl:apply-templates>
    </xsl:template>
    
    <xsl:template match="article" mode="modal-grouped-figs-tables-schemes">
        <!-- 
            Modal que apresenta juntos figuras, tabelas e fórmulas presentes
            em um dado idioma do texto do artigo<commit_msg>Aplica o modal para figuras, mesmo sem atributo `@id`<commit_after><?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    version="1.0">
    <xsl:template match="article" mode="article-modals">
        <!--
            Cria todos os modals do documento
        -->
        <!-- modal do contribs -->
        <xsl:apply-templates select="." mode="modal-contribs"/>

        <!-- modal que apresenta juntos figuras, tabelas e fórmulas -->
        <xsl:apply-templates select="." mode="modal-grouped-figs-tables-schemes"/>

        <!-- cria um modal para cada figura -->
        <xsl:apply-templates select="." mode="fig-individual-modal"/>
        
        <!-- cria um modal para cada tabela -->
        <xsl:apply-templates select="." mode="table-individual-modal"/>
        
        <!-- cria um modal para cada fórmula -->
        <xsl:apply-templates select="." mode="scheme-individual-modal"/>
        
        <!-- cria um modal para como citar -->
        <xsl:apply-templates select="." mode="modal-how2cite"/>
    </xsl:template>
    
    <xsl:template match="article" mode="table-individual-modal">
        <!--
            Cria um modal para cada tabela
            encontrada em article,
            de acordo com o idioma selecionado para o texto
        -->
        <xsl:variable name="translation" select=".//sub-article[@xml:lang=$TEXT_LANG and @article-type='translation']"/>

        <xsl:choose>
            <xsl:when test="$translation">
                <xsl:apply-templates select="front | $translation | back" mode="table-individual-modal"/>
            </xsl:when>
            <xsl:otherwise>
                <xsl:apply-templates select="front | body | back" mode="table-individual-modal"/>
            </xsl:otherwise>
        </xsl:choose>
    </xsl:template>
    
    <xsl:template match="front | body | back | sub-article" mode="table-individual-modal">
        <!-- cria um modal para cada tabela existente no body-->
        <xsl:apply-templates select=".//table-wrap[@xml:lang=$TEXT_LANG] | .//table-wrap[not(@xml:lang)]" mode="modal"/>
    </xsl:template>
    
    <xsl:template match="article" mode="scheme-individual-modal">
        <!--
            Cria um modal para cada fórmula
            encontrada em article,
            de acordo com o idioma selecionado para o texto
        -->
        <xsl:variable name="translation" select=".//sub-article[@xml:lang=$TEXT_LANG and @article-type='translation']"/>

        <xsl:choose>
            <xsl:when test="$translation">
                <xsl:apply-templates select="front | $translation | back" mode="scheme-individual-modal"/>
            </xsl:when>
            <xsl:otherwise>
                <xsl:apply-templates select="front | body | back" mode="scheme-individual-modal"/>
            </xsl:otherwise>
        </xsl:choose>
    </xsl:template>

    <xsl:template match="front | body | back | sub-article" mode="scheme-individual-modal">
        <!-- cria um modal para cada formula existente no body-->
        <xsl:apply-templates select=".//disp-formula[@id]" mode="modal"/>
    </xsl:template>
    
    <xsl:template match="article" mode="fig-individual-modal">
        <!--
            Cria um modal para cada figura
            encontrada em article,
            de acordo com o idioma selecionado para o texto
        -->
        <xsl:variable name="translation" select=".//sub-article[@xml:lang=$TEXT_LANG and @article-type='translation']"/>

        <xsl:choose>
            <xsl:when test="$translation">
                <xsl:apply-templates select="front | $translation | back" mode="fig-individual-modal"/>
            </xsl:when>
            <xsl:otherwise>
                <xsl:apply-templates select="front | body | back" mode="fig-individual-modal"/>
            </xsl:otherwise>
        </xsl:choose>
    </xsl:template>
    
    <xsl:template match="front | body | back | sub-article" mode="fig-individual-modal">
        <!-- cria um modal para cada figura existente no body-->
        <xsl:apply-templates select=".//fig-group[@id] | .//fig" mode="modal"></xsl:apply-templates>
    </xsl:template>
    
    <xsl:template match="article" mode="modal-grouped-figs-tables-schemes">
        <!-- 
            Modal que apresenta juntos figuras, tabelas e fórmulas presentes
            em um dado idioma do texto do artigo
{'fraction_non_alphanumeric': 0.1533615851563395, 'fraction_numerical': 0.0025197571870347038, 'mean_word_length': 2.2864132480240875, 'pattern_counts': {'":': 0, '<': 139, '<?xml version=': 2, '>': 137, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 14}, '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': '4622538', 'n_tokens_mistral': 2675, 'n_tokens_neox': 2427, 'n_words': 567}