我有以下xml文档:
<?xml version="1.0" encoding="UTF-8"?>
<root>
<data>
<child1> Well, some spaces and nbsps  </child1>
<child2>  some more   or whatever </child2>
<child3> a nice text</child3>
<child4>how to get rid of all the nasty spaces  ? </child4>
</data>
</root>
Run Code Online (Sandbox Code Playgroud)
我必须删除所有不可破坏的空格,连接文本并将其正常化.
我的xpath查询(它适用于连接和规范化 - 我已将替换为'x'仅用于测试目的):
normalize-space(replace(string-join(//data/*,' '),' ','x'))
Run Code Online (Sandbox Code Playgroud)
我的问题:我找不到" "-whitespace来替换它.
期待您的回答,
可能重复:
在XSLT中生成新行
如果有以下xslt文件:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="http://www.w3.org/1999/XSL/Format">
<xsl:output method="text" />
<xsl:template match="//teilnehmer">
<xsl:value-of select="name"/>
<xsl:value-of select="kind"/>
</xsl:template>
</xsl:stylesheet>
Run Code Online (Sandbox Code Playgroud)
转换后的输出是一个没有任何空格或换行符的字符串
如何添加一些格式(例如名称后的换行符)?
提前致谢!