根据head-title - XSLT包装部分下的内容

时间:2017-06-17 14:31:13

标签: xslt

我在修改标题之间的内容时遇到问题。

例如,我有一个XML结构如下:

<?xml version="1.0" encoding="UTF-8"?>
<root>
    <title1>This is first-level head</title1>
    <p>first paragraph...</p>
    <p>second paragraph...</p>
    <p>so on...</p>
    <title2>This is second-level head</title2>
    <p>first paragraph under level-2 nesting</p>
    <p>second paragraph..</p>
    <p>so on...</p>
    <title1>This is first-level head</title1>
    <p>first paragraph...</p>
    <p>second paragraph...</p>
    <p>so on...</p>
    <title1>This is first-level head</title1>
    <p>first paragraph...</p>
    <p>second paragraph...</p>
    <p>so on...</p>
</root>

我希望将其转换为:

<?xml version="1.0" encoding="UTF-8"?>
<root>
    <section>
        <title>This is first-level head</title>
        <p>first paragraph...</p>
        <p>second paragraph...</p>
        <p>so on...</p>
        <section>
            <title>This is second-level head</title>
            <p>first paragraph under level-2 nesting</p>
            <p>second paragraph..</p>
            <p>so on...</p>
        </section>
    </section>
    <section>
        <title>This is first-level head</title>
        <p>first paragraph...</p>
        <p>second paragraph...</p>
        <p>so on...</p>
    </section>
    <section>
        <title>This is first-level head</title>
        <p>first paragraph...</p>
        <p>second paragraph...</p>
        <p>so on...</p>
    </section>
</root>

就像那样,具有深层嵌套结构。

帮助我制作以下结构化输出。 如果我们不会使用for-each循环会非常感激,因为内容很大并会影响性能。

0 个答案:

没有答案