本文出自http://technet.microsoft.com/zh-cn/magazine/ms256063%28VS.90%29.aspx

通过去掉前导和尾随空白并使用单个空格替换一系列空白字符,使空白标准化。 如果省略了该参数,上下文节点的字符串值将标准化并返回。

以下函数调用返回“abc def”:

normalize-space(" abc def ")

如果参数不是字符串类型,将先转换成字符串再计算。 请参见下面的示例。

如果参数不是字符串类型,将先使用 string() 函数转换为字符串,然后计算该转换的结果。

警告

作为参数传递给此函数的节点集的字符串转换可能会产生意外的结果。 有关更多信息,请参见 string 函数

此函数区分大小写。

示例

以下示例使用非标准化的空白(单词间的制表符、前导和尾随的空格以及多个空格)标准化文本字符串块。 文本字符串是 <text> 元素的值。

 XML 文件 (normSpace.xml)
Xml
<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="normalizeSpace.xsl"?>
<text>
This is a
test, with a lot of
irregular spacing and
waiting to be normalizaed. </text>
 XSLT 文件 (normSpace.xsl)
Xml
<?xml version='1.0'?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output method="xml"
omit-xml-declaration="yes"/> <xsl:template match="/text">
Unnormalized:
"<xsl:value-of select='.'/>"
Normalized: "<xsl:value-of select='normalize-space()'/>"
</xsl:template> </xsl:stylesheet>

该 XSLT 生成以下输出:

Unormalized:

"

This is a

test, with a lot of

irregular spacing and

waiting to be normalizaed.

"

Normalized:

"This is a test, with a lot of irregular spacing and waiting to be normalized."

xsl: normalize-space(string str) 函数的更多相关文章

  1. 经典String str = new String("abc")内存分配问题

    出自:http://blog.csdn.net/ycwload/article/details/2650059 今天要找和存储管理相关的一些知识,网上搜了半天也没有找到完善的(30%的程度都不到),没 ...

  2. string.capwords()函数

    string.capwords()函数 string.capwords()函数,有需要的朋友可以参考下. 代码 : import syssys.path.append("C:/Python2 ...

  3. Python repr() 或str() 函数(转)

    Python 有办法将任意值转为字符串:将它传入repr() 或str() 函数.函数str() 用于将值转化为适于人阅读的形式,而repr() 转化为供解释器读取的形式(如果没有等价的语法,则会发生 ...

  4. public static void main(String[] args){}函数诠释

    public static void main(String[] args){}函数诠释 主函数的一般写法如下: public static void main(String[] args){-} 下 ...

  5. Java——String.split()函数

    在java doc里有 String[] java.lang.String.split(String regex) Splits this string around matches of the g ...

  6. c++中string.erase()函数的用法(转)

    erase函数的原型如下:(1)string& erase ( size_t pos = 0, size_t n = npos );(2)iterator erase ( iterator p ...

  7. String 常用函数

    判断字符串是否包含指定字符str.contains("string"); 查找指定字符索引str.indexOf("s"'); 查找最后出现的字符索引str.i ...

  8. C++中的string常用函数用法

    标准c++中string类函数介绍   注意不是CString 之所以抛弃char*的字符串而选用C++标准程序库中的string类,是因为他和前者比较起来,不必 担心内存是否足够.字符串长度等等,而 ...

  9. Python str() 函数

    Python str() 函数  Python 内置函数 描述 str() 函数将对象转化为适于人阅读的形式. 语法 以下是 str() 方法的语法: class str(object='') 参数 ...

随机推荐

  1. CJCMS系列--持久层对MangoDB的支持

    持久层添加对MangoDB数据库的支持 using System; using System.Collections.Generic; using System.Linq; using System. ...

  2. java.lang.ClassNotFoundException: com.mysql.jdbc.Driver解决办法

    这个问题的原因是没有导入mysql连接库,我从官网上下载后照着网上的教程各种导入无果,最后发现是我导入的文件错了.... 官网上下下来的压缩文件是这个,不过这并不是直接要导入的文件,首先解压文件,然后 ...

  3. JS数组求最大值和最小值

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...

  4. HDU4329

    #include<cstdio> #include<algorithm> #include<map> using namespace std; int main() ...

  5. ubuntu下C++连接mysql数据库

    参考了该博客的做法:http://zhmy.michael.blog.163.com/blog/static/861578792012101244715692/ 1.安装mysql: sudo apt ...

  6. bzoj4555题解

    我们计算$f(i)=\sum_{j=1}^i S(i,j)\times 2^j\times (j!)$,容(o)易(e)知(i)道(s)$f(i)$的指数生成函数为$\frac{1}{3-2\time ...

  7. linux回退到上次访问目录

    cd / cd ..  回到上级目录 cd - 回到上次访问目录

  8. 出售Illustrator脚本插件面板(包含面板源码,以及面板上所有的功能源码)

    出售Illustrator脚本插件面板(包含面板源码,以及面板上所有的功能源码) 购买后可提供相应的小修改,以及教你使用往这个多列面里再加上按钮功能! 这套源码可作为工作使用,也可用为新手学习AI脚面 ...

  9. 如何利用rem在移动端不同设备上让字体自适应大小

    本人也是一个刚刚接触前端的小虾米,对于移动端这一块更是一抹眼的黑,前端时间接手开始一个移动端的项目,在网上查询了一下rem的作用,百度搜索下来全是介绍rem的作用原理的(rem是根据根元素计算的),然 ...

  10. Linux 系统中堆栈的使用方法

    本节内容概要描述了Linux内核从开机引导到系统正常运行过程中对堆栈的使用方式.这部分内容的说明与内核代码关系比较密切,可以先跳过.在开始阅读相应代码时再回来仔细研究. Linux 0.12系统中共使 ...