本文出自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. MFC双缓存技术代码

    屏蔽背景刷新,在View中添加对WM_ERASEBKGND的响应,直接返回TRUE: BOOL CTEMV1View::OnEraseBkgnd(CDC* pDC) { // TODO: 在此添加消息 ...

  2. css text-overflow:ellipsis 文字多余剪切

    text-overflow: ellipsis;多度剪切white-space: nowrap;禁止换行overflow: hidden;多余隐藏

  3. MVC开发模式下的用户角色权限控制

    前提: MVC开发模式 大概思想: 1.在MVC开发模式下,每个功能都对应着不同的控制器或操作方法名(如修改密码功能可能对应着User/changepd),把每个功能对应的控制器名和操作方法名存到数据 ...

  4. 我的js函数库(持续更新)

    常用js初始化函数 function id(obj) { return document.getElementById(obj); } function bind(obj, ev, fn) { if ...

  5. composer 报错:Your requirements could not be resolved to an installable set of packages 解决方法

    composer 报错: - Your requirements could not be resolved to an installable set of packages xxxxxxxxxxx ...

  6. Mantis搭建步骤

    (1)安装EeasyPHP (2)解压Mantis到EeasyPHP内www目录下 (3)将PHP复制到www目录下 并修改apache下httpd.conf及php.ini两个文件的php配置目录 ...

  7. Java对象的深拷贝和浅拷贝、集合的交集并集

    http://blog.csdn.net/lian_1988/article/details/45970927 http://www.cnblogs.com/yxnchinahlj/archive/2 ...

  8. $compile

    <html ng-app="compile"> <head> <script src="http://apps.bdimg.com/libs ...

  9. UILabel 的一个蛋疼问题

    一.问题描述 在iOS8以下版本,numberOfLines设置为0,编译警告Automatic Preferred Max Layout Width before iOS8.0,同时不能换行. 二. ...

  10. 为什么使用Junit Test而不用普通java main方法来完成测试?

    因为在程序里边,一个接口对应一个实现方法,而在接口中常常会定义相关的很多方法,所以在测试的时候,如果都在main方法里边进行测试,main方法就会显得臃肿,而且不便于以后其他人测试以及查看测试数据,用 ...