zoukankan      html  css  js  c++  java
  • XPath: normalizespace 函数

    返回去掉了前导、尾随和重复的空白的参数字符串

    string normalize-space(string)

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

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

    normalize-space("  abc    def  ")

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

    Sample:

    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:

    <?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>

    Result:

    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."

    From: msdn: <http://msdn.microsoft.com/zh-cn/library/ms256063(VS.80).aspx>

  • 相关阅读:
    [HAOI2009] 毛毛虫
    [NOI2015]品酒大会
    SDOI2016 生成魔咒
    [POJ2406]字符串的幂
    [SPOJ705]不同的子串
    快速幂和矩阵快速幂
    对于最近的一些日常总结by520(17.10.18)
    思维训练
    趣味性的高智商(贼有意思)的题(坑)
    C++手动开O2优化
  • 原文地址:https://www.cnblogs.com/aot/p/2989121.html
Copyright © 2011-2022 走看看