【问题标题】:select all text out of nodes从节点中选择所有文本
【发布时间】:2015-08-10 16:38:52
【问题描述】:

我有以下 xml,我需要提取节点“合理”之外的文本。

<html><head><title>test</title></head><body><p><justificado><negrita>TEST.- </negrita>Hello people <negrita>it is</negrita><negrita>,</negrita> fa test ./justificado></p></body></html>

我尝试了以下但没有成功

<xsl:template match="not (*/negrita[preceding-sibling::*[1]self::negrita]])">test-123</xsl:template>

【问题讨论】:

标签: xslt select text


【解决方案1】:

我需要提取节点“justified”之外的文本。

XSLT 样式表的default behavior 是复制所有文本节点 - 所以为了提取特定元素之外的所有文本,您只需要一个与内部文本节点匹配的空模板 strong> 指定元素:

XSLT 1.0

<xsl:stylesheet version="2.0" 
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="text" encoding="UTF-8"/>

<xsl:template match="text()[ancestor::justificado]"/>

</xsl:stylesheet>

应用于您的示例输入(更正结束 &lt;/justificado&gt; 标记后!),结果是:

test

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-08-28
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多