Словарь TEI-XML для простой таблицы HTML с использованием XSL - PullRequest
0 голосов
/ 17 ноября 2018

Нужно поместить слова "entryFree" в первый столбец (оставляя контент <form> для второго), а "sense" и прочее как секунду, каждую пару в одной строке с границами.Пример таблицы стилей XSL содержит только форматирование.

образец XML: https://drive.google.com/file/d/1sNAbWw5xo1pgwK2QfQwPrbZtZt8uV48T/view?usp=sharing

необычный XSL (изменение разрешений лицензии): https://github.com/michmech/tei-dictionary.xsl

1 Ответ

0 голосов
/ 20 ноября 2018

Если вы хотите отобразить все элементы entryFree в строки таблицы HTML (т. Е. Элементы HTML tr в HTML table), то при необходимости установите table и в процессе tbody все * 1006.* элементы, отображающие их с шаблоном в tr:

<xsl:output method="html" doctype-system="about:legacy-doctype"/>

<xsl:template match="/">
    <html>
        <head>
            <title>Test</title>
        </head>
        <body>
            <h1>Table</h1>
            <table>
                <thead>
                    <tr>
                        <th>free entry</th>
                        <th>forms/senses</th>
                    </tr>
                </thead>
                <tbody>
                    <xsl:apply-templates select="//tei:entryFree"/>
                </tbody>
            </table>
        </body>
    </html>
</xsl:template>

<xsl:template match="tei:entryFree">
    <tr>
        <td>
            <xsl:value-of select="@sortKey"/>
        </td>
        <td>
           <xsl:apply-templates/> 
        </td>
    </tr>
</xsl:template>

Вам необходимо удалить шаблон, соответствующий tei:entryFree, очевидно.

Что касается форматирования таблицы, то естьпроблема HTML / CSS, HTML 4 https://www.w3.org/TR/html401/struct/tables.html#h-11.3.1 позволяет, например,

            <table rules="all" frame="border">
                <thead>
                    <tr>
                        <th>free entry</th>
                        <th>forms/senses</th>
                    </tr>
                </thead>
                <tbody>
                    <xsl:apply-templates select="//tei:entryFree"/>
                </tbody>
            </table>

в HTML5. Я думаю, что использование CSS предпочтительнее:

<xsl:template match="/">
    <html>
        <head>
            <title>Test</title>
            <style>
                table.dict { 
                  border: 1px solid black;
                  border-collapse: collapse;
                }
                table.dict th, table.dict td {
                  border: 1px solid black;
                }
            </style>
        </head>
        <body>
            <h1>Table</h1>
            <table class="dict">
                <thead>
                    <tr>
                        <th>free entry</th>
                        <th>forms/senses</th>
                    </tr>
                </thead>
                <tbody>
                    <xsl:apply-templates select="//tei:entryFree"/>
                </tbody>
            </table>
        </body>
    </html>
</xsl:template>
...