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
是否从XSL中的XML节点值中修剪特定字符?_Xml_Xslt - Fatal编程技术网

是否从XSL中的XML节点值中修剪特定字符?

是否从XSL中的XML节点值中修剪特定字符?,xml,xslt,Xml,Xslt,这是一些XML: <Test>This is some text</Test> <Test>This is some text:</Test> <Test>This is some text :</Test> 这是一些文本 以下是一些文字: 以下是一些文字: 使用XSL 1.0是否可以从右边任何“”和“:”字符获取值和修剪 谢谢。这里有一个快速而肮脏的方法: <xsl:template match="Test/te

这是一些XML:

<Test>This is some text</Test>
<Test>This is some text:</Test>
<Test>This is some text :</Test>
这是一些文本
以下是一些文字:
以下是一些文字:
使用XSL 1.0是否可以从右边任何“”和“:”字符获取值和修剪


谢谢。

这里有一个快速而肮脏的方法:

<xsl:template match="Test/text()">
  <xsl:value-of select="normalize-space(translate(.,':',''))"/>
</xsl:template>

<>这将导致任何元素在中间或一个前导空间中有一个或两个空格,但是如果你没有任何类似的东西,它应该工作。

这将通过不替换任何冒号来删除任何冒号,然后执行“规范化空格”,从文本中修剪尾随空格、前导空格和双空格