Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/xml/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Xml 如何列出para元素中显示的数据?_Xml_Xslt - Fatal编程技术网

Xml 如何列出para元素中显示的数据?

Xml 如何列出para元素中显示的数据?,xml,xslt,Xml,Xslt,如何列出显示为段落的数据 这是我的XML数据: <para>In this appeal against the judgment of Tribunal: <list> <listitem> <listnum>(a)</listnum> <listbody>Ajeet</listbody> </listitem>

如何列出显示为段落的数据

这是我的XML数据:

<para>In this appeal against the judgment of Tribunal:
    <list>
        <listitem>
            <listnum>(a)</listnum>
            <listbody>Ajeet</listbody>
        </listitem>
        <listitem>
            <listnum>(b)</listnum>
            <listbody>Kumar</listbody>
        </listitem>
        <listitem>
            <listnum>(c)</listnum>
            <listbody>Singh</listbody>
        </listitem>
        <listitem>
            <listnum>(d)</listnum>
            <listbody>Motihari</listbody>
        </listitem>
    </list>
</para>
i want to output
<p class="j2">In this appeal against the judgment of Tribunal:</p>
<p class="p3">(a) Ajeet</p>
<p class="p3">(b) Kumar</p>
<p class="p3">(c) Singh</p>
<p class="p3">(d) Motihari</p>
在本次针对法庭判决的上诉中:
(a)
阿吉特
(b)
古玛
(c)
辛格
(d)
莫蒂哈里
我想要输出

在本次针对法庭判决的上诉中:

(a)一个

库马尔

辛格

(d)莫蒂哈里

我使用下面的代码,但不是我的输出要求未完全填充。请检查并更新我的代码

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

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

<xsl:template match="listitem">
    <p class="p3"><xsl:apply-templates/></p>
</xsl:template>

<xsl:template match="listnum">
    <xsl:apply-templates/><xsl:text> </xsl:text>
</xsl:template>

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


使用以下内容更改您的para模板:

<xsl:template match="para">
    <xsl:for-each-group select="node()" group-adjacent="boolean(self::list)">
        <xsl:choose>
            <xsl:when test="current-grouping-key()">
                <xsl:apply-templates select="current-group()"></xsl:apply-templates>
            </xsl:when>
            <xsl:when test="replace(current-group(), '[ &#xa;]', '') != ''"><p>
                <xsl:copy-of select="current-group()"></xsl:copy-of>
            </p></xsl:when>
        </xsl:choose>
    </xsl:for-each-group>
</xsl:template>



请参见

上的转换,您的问题是什么?