小编And*_*ndy的帖子

XSLT从Select中排除一个特定节点

为了得到答案,我看起来高低不一,并尝试了数百种排列,但一切都没有效果.

我正在尝试处理第一个节点的简单XML文档EXCEPT的所有<title>节点.基本上,我正在尝试找到一个xslt指令来完成它的精确反转

<xsl:apply-templates select="/topic/title"/>
Run Code Online (Sandbox Code Playgroud)

这是我的源XML:

<topic>
    <title>Name of the Document</title>
    <p>Document body</p>
    <topic>
        <title>First Document Subtopic</title>
        <p>Body text for first document subtopic</p>
    </topic>
    <p>Body text continued for document</p>
    <topic>
        <title>Second Document Subtopic</title>
        <p>Body text for document subtopic</p>
        <topic>
            <title>First Document Sub-subtopic</title>
            <p>Body text for first document sub-subtopic</p>
        </topic>
    </topic>
    <p>Body text continued a second time for document</p>
</topic>
Run Code Online (Sandbox Code Playgroud)

这是我的XSLT(我最初认为在应用模板的调用中应该起作用):

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0">
    <xsl:output omit-xml-declaration="yes" encoding="UTF-8" method="xml"/>
    <xsl:strip-space elements="*"/>

    <xsl:template match="/">
        <BOX> …
Run Code Online (Sandbox Code Playgroud)

xslt select apply-templates

2
推荐指数
1
解决办法
1万
查看次数

标签 统计

apply-templates ×1

select ×1

xslt ×1