【发布时间】:2019-01-28 20:56:26
【问题描述】:
输入是:
<p> </p>
输出是:
<p></p>
我想删除输出文件中的空标签,因为&#160; 是 nbsp 并且在输出中它被转换为空格,但我不希望这个标签带有空格。
输入是:
<div>
<title>Operational Commands</title>
<p>show ip nat filtershow ip nat interfaceshow ip nat interface-statistics</p>
<div>
<title>Release Information</title>
<p>Command introduced in Viptela Software Release 18.3.</p>
</div>
<div>
<title>Additional Information</title>
<p>See the Configuring Transport-Side NAT article for your software release.</p>
<p> </p>
</div>
我的 xslt 代码是:
<xsl:variable name='list' select='//div'/>
<xsl:template match='/'>
<xsl:for-each select='$list'>
<xsl:element name='section'>
<xsl:apply-templates select='*[not(name(.)="div")]'/>
</xsl:element>
</xsl:for-each>
</xsl:template>
输出是:
<section>
<title>Operational Commands</title>
<p>show ip nat filtershow ip nat interfaceshow ip nat interface-statistics</p>
</section><section>
<title>Release Information</title>
<p>Command introduced in Viptela Software Release 18.3.</p>
</section><section>
<title>Additional Information</title>
<p>See the Configuring Transport-Side NAT article for your software release.</p>
<p> </p>
</section>
在最后一节中,<p> 标签有空间,被认为是空标签,那么我需要删除这个空标签。我怎样才能删除它?
【问题讨论】:
-
这里的输入是:
ASCII 格式的 nbsp
i. e 160 ; -
如果您有任何现有的 XSLT 可以将该不间断空间“转换”为正常空间,那么您应该向我们展示该代码。目前尚不清楚您是要修复某些特定的 XSLT 代码还是要编写 XSLT 以从任何输入中删除任何
<p>&#160;</p>元素。 -
我在下面写了我的代码..
-
请编辑您的问题以提供任何详细信息,而不是作为答案。还可以考虑向我们展示最少但完整的示例和信息,以便我们重现问题。您在“答案”中显示的 XSLT 部分根本不会创建任何
p元素。它也不会将不间断空格之类的字符转换为空格。 -
好的...那么我需要做些什么来删除空的
标签?