Need to add sublist in between closing para and item and footnote inside closing para

試著忘記壹切 提交于 2019-12-08 14:08:24

You haven't really explained which are the criteria to wrap nodes into para, here is a sample using for-each-group group-adjacent="boolean(self::ul)" to wrap any adjacent nodes not being ul elements into para elements:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:xs="http://www.w3.org/2001/XMLSchema"
    exclude-result-prefixes="xs"
    version="2.0">

    <xsl:template match="@* | node()" mode="#all">
        <xsl:copy>
            <xsl:apply-templates select="@* | node()" mode="#current"/>
        </xsl:copy>
    </xsl:template>

    <xsl:template match="p">
        <para>
            <xsl:apply-templates/>
        </para>
    </xsl:template>

    <xsl:template match="ul[@outputclass='l1'] | ul[@outputclass='l2'] | ul[@outputclass='l3']">
        <itemizedlist type="&#x2022;">
            <xsl:apply-templates/>
        </itemizedlist>
    </xsl:template>

    <xsl:template match="li[@outputclass='lt1'] | li[@outputclass='lt2'] | li[@outputclass='lt3']">
        <item>
            <xsl:for-each-group select="node()" group-adjacent="boolean(self::ul)">
                <xsl:choose>
                    <xsl:when test="current-grouping-key()">
                        <xsl:apply-templates select="current-group()"/>
                    </xsl:when>
                    <xsl:otherwise>
                        <para>
                            <xsl:apply-templates select="current-group()" mode="preserve"/>
                        </para>
                    </xsl:otherwise>
                </xsl:choose>
            </xsl:for-each-group>
        </item>
    </xsl:template>

</xsl:stylesheet>
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!