新书推介:《语义网技术体系》
作者:瞿裕忠,胡伟,程龚
   >>中国XML论坛<<     W3CHINA.ORG讨论区     计算机科学论坛     SOAChina论坛     Blog     开放翻译计划     新浪微博  
 
  • 首页
  • 登录
  • 注册
  • 软件下载
  • 资料下载
  • 核心成员
  • 帮助
  •   Add to Google

    >> 本版讨论XSL,XSLT,XSL-FO,CSS等技术
    [返回] 中文XML论坛 - 专业的XML技术讨论区XML.ORG.CN讨论区 - XML技术『 XSL/XSLT/XSL-FO/CSS 』 → xsl函数浏览 查看新帖用户列表

      发表一个新主题  发表一个新投票  回复主题  (订阅本版) 您是本帖的第 39905 个阅读者浏览上一篇主题  刷新本主题   树形显示贴子 浏览下一篇主题
     * 贴子主题: xsl函数浏览 举报  打印  推荐  IE收藏夹 
       本主题类别:     
     孤独 帅哥哟,离线,有人找我吗?
      
      
      威望:7
      等级:大三(面向对象是个好东东!)(版主)
      文章:826
      积分:4220
      门派:XML.ORG.CN
      注册:2004/1/14

    姓名:(无权查看)
    城市:(无权查看)
    院校:(无权查看)
    给孤独发送一个短消息 把孤独加入好友 查看孤独的个人资料 搜索孤独在『 XSL/XSLT/XSL-FO/CSS 』的所有贴子 引用回复这个贴子 回复这个贴子 查看孤独的博客楼主
    发贴心情 xsl函数浏览

    XSLT supplies a number of functions.


    --------------------------------------------------------------------------------

    XSLT Functions
    Name Description
    current() Returns the current node
    document() Used to access the nodes in an external XML document
    element-available() Tests whether the element specified is supported by the XSLT processor
    format-number() Converts a number into a string
    function-available() Tests whether the function specified is supported by the XSLT processor
    generate-id() Returns a string value that uniquely identifies a specified node
    key() Returns a node-set using the index specified by an element
    system-property() Returns the value of the system properties
    unparsed-entity-uri() Returns the URI of an unparsed entity


    --------------------------------------------------------------------------------

    Inherited XPath Functions
    Node Set Functions
    Name Description Syntax
    count() 返回结点个数 number=count(node-set)
    id() Selects elements by their unique ID node-set=id(value)
    last() 返回最后一个结点的需要 number=last()
    local-name() Returns the local part of a node. A node usually consists of a prefix, a colon, followed by the local name string=local-name(node)
    name() 返回一个结点的名称 string=name(node)
    namespace-uri() 返回一个结点的名称空间 uri=namespace-uri(node)
    position() 返回结点序号 number=position()

    String Functions
    Name Description Syntax & Example
    concat() 返回一个将N个字符串连接的值 string=concat(val1, val2, ..)
    示例:
    concat('The',' ','XML')
    返回结果: 'The XML'

    contains() 如果val包含substr则返回true bool=contains(val,substr)

    示例:
    contains('XML','X')
    返回结果: true

    normalize-space() 删除多余空格 string=normalize-space(string)
    示例:
    normalize-space(' The   XML ')
    返回结果: 'The XML'

    starts-with() 如果String以substr开始则返回true bool=starts-with(string,substr)
    示例:
    starts-with('XML','X')
    返回结果: true

    string() 将数字转换为字符 string(value)
    示例:
    string(314)
    返回结果: '314'

    string-length() 返回一个字符串的长度 number=string-length(string)
    示例:
    string-length('Beatles')
    返回结果: 7

    substring() 将string从start开始一直截取到第length位 string=substring(string,start,length)
    示例:
    substring('Beatles',1,4)
    返回结果: 'Beat'

    substring-after() 将string以substr分割,选取最后一个 string=substring-after(string,substr)

    示例:
    substring-after('12/10','/')
    返回结果: '10'

    substring-before() 将string以substr分割,选取第一个 string=substring-before(string,substr)

    示例:
    substring-before('12/10','/')
    返回结果: '12'

    translate() 对字串进行替换操作 string=translate(value,string1,string2)
    示例:
    translate('12:30',':','!')
    返回结果: '12!30'

    Number Functions
    Name Description Syntax & Example
    ceiling() 返回一个整数 number=ceiling(number)
    示例:
    ceiling(3.14)
    返回结果: 4

    floor() 返回一个整数 number=floor(number)

    示例:
    floor(3.14)
    返回结果: 3

    number() 将字符型转为数字 number=number(value)

    示例:
    number('100')
    返回结果: 100

    round() 返回一个实数的四舍五入的整数值 integer=round(number)
    示例:
    round(3.14)
    返回结果: 3

    sum() 返回结点值的和 number=sum(nodeset)
    示例:
    sum(/cd/price)

    Boolean Functions
    Name Description Syntax & Example
    boolean() Converts the value argument to Boolean and returns true or false bool=boolean(value)
    false() 返回false false()
    示例:
    number(false())
    返回结果: 0

    lang() Returns true if the language argument matches the language of the the xsl:lang element, otherwise it returns false bool=lang(language)
    not() Returns true if the condition argument is false, and false if the condition argument is true bool=not(condition)
    示例:
    not(false())

    true() Returns true true()
    示例:
    number(true())
    返回结果: 1


    --------------------------------------------------------------------------------

    The current() Function

    --------------------------------------------------------------------------------

    Definition and Usage
    The current() function returns a node-set that contains only the current node. Usually the current node and the context node are the same.


    is equal to


    However, there is one difference. Look at the following XPath expression: 'catalog/cd'. This expression selects the child nodes of the current node, and then it selects the child nodes of the nodes. This means that on each step of evaluation, the '.' has a different meaning.

    The following line:


    will process all cd elements that have a title attribute with value equal to the value of the current node's ref attribute.

    This is different from


    that will process all cd elements that have a title attribute and a ref attribute with the same value.


    --------------------------------------------------------------------------------

    Syntax
    node-set current()

    Example 1

      
      
      
        Current node:
        
      
      
      


    If you have Netscape 6 or IE 5 or higher you can view: the XML file and the XSL file.

    View the result in Netscape 6 or IE 6

    The document() Function


    --------------------------------------------------------------------------------

    Definition and Usage
    The document() function is used to access nodes in an external XML document. The external XML document must be valid and parsable.

    One way to use this function is to look up data in an external document. For example we want to find the Celsius value from a Fahrenheit value and we refer to a document that contains some pre-computed results:

    --------------------------------------------------------------------------------

    Syntax
    node-set document(object,node-set?)


    Parameters
    Parameter Description
    object Required. Defines an URI to an external XML document
    node-set Optional. Used to resolve relative URI


    --------------------------------------------------------------------------------

    The element-available() Function

    --------------------------------------------------------------------------------

    Definition and Usage
    The element-available() function returns a Boolean value that indicates whether the element specified is supported by the XSLT processor.

    This function can only be used to test elements that can occur in a template body. These elements are:

    xsl:apply-imports
    xsl:apply-templates
    xsl:attributes
    xsl:call-template
    xsl:choose
    xsl:comment
    xsl:copy
    xsl:copy-of
    xsl:element
    xsl:fallback
    xsl:for-each
    xsl:if
    xsl:message
    xsl:number
    xsl:processing instruction
    xsl:text
    xsl:value-of
    xsl:variable

    --------------------------------------------------------------------------------

    Syntax
    boolean element-available(string)

    Parameters
    Parameter Description
    string Required. Specifies the element to test

    Example 1

    xsl:comment is supported.


    xsl:comment is not supported.


    xsl:delete is supported.


    xsl:delete is not supported.


    If you have Netscape 6 or IE 5 or higher you can view: the XSL file.

    View the result in Netscape 6 or IE 6

    --------------------------------------------------------------------------------

    The format-number() Function

    --------------------------------------------------------------------------------

    Definition and Usage
    The format-number() function is used to convert a number into a string.


    --------------------------------------------------------------------------------

    Syntax
    string format-number(number,format,[decimalformat])

    Parameters
    Parameter Description
    number Required. Specifies the number to be formatted
    format Required. Specifies the format pattern. Here are some of the characters used in the formatting pattern:
    # (Denotes a digit. 示例: ####)
    0 (Denotes leading and following zeros. 示例: 0000.00)
    . (The position of the decimal point 示例: ###.##)
    , (The group separator for thousands. 示例: ###,###.##)
    % (Displays the number as a percentage. 示例: ##%)
    ; (Pattern separator. The first pattern will be used for positive numbers and the second for negative numbers)

    decimalformat Optional.

    Example 1

    If you have Netscape 6 or IE 5 or higher you can view: the XSL file.

    View the result in Netscape 6 or IE 6


    The function-available() Function


    --------------------------------------------------------------------------------

    Definition and Usage
    The function-available() function returns a Boolean value that indicates whether the function specified is supported by the XSLT processor.

    You may test the XSLT functions and the inherited XPath functions.


    --------------------------------------------------------------------------------

    Syntax
    boolean function-available(string)


    Parameters
    Parameter Description
    string Required. Specifies the function to test


    Example 1

    sum() is supported.


    sum() is not supported.


    current() is supported.


    current() is not supported.



    If you have Netscape 6 or IE 5 or higher you can view: the XSL file.

    View the result in Netscape 6 or IE 6

    --------------------------------------------------------------------------------

    The generate-id() Function

    --------------------------------------------------------------------------------

    Definition and Usage
    The generate-id() function returns a string value that uniquely identifies a specified node.

    If the node-set specified is empty, an empty string is returned. If you omit the node-set parameter, it defaults to the current node.


    --------------------------------------------------------------------------------

    Syntax
    string generate-id(node-set?)

    Parameters
    Parameter Description
    node-set Optional. Specifies on which node-set to generate a unique id  

    Example 1

    Artists:


    --------------------------------------------------------------------------------

    Artist:


    Title:

    Price:
    --------------------------------------------------------------------------------

    If you have Netscape 6 or IE 5 or higher you can view: the XML file and the XSL file.

    View the result in Netscape 6 or IE 6

    --------------------------------------------------------------------------------

    The key() Function

    --------------------------------------------------------------------------------

    Definition and Usage
    The key() function returns a node-set from the document, using the index specified by an element.


    --------------------------------------------------------------------------------

    Syntax
    node-set key(string, object)

    Parameters
    Parameter Description
    string Required. Specifies the name of an xsl:key element
    object Required. A string to search for

    Example 1


      
      Title:
      
      Artist:
      
      Price:
      

    If you have Netscape 6 or IE 5 or higher you can view: the XML file and the XSL file.

    View the result in Netscape 6 or IE 6

    --------------------------------------------------------------------------------

    The system-property() Function

    --------------------------------------------------------------------------------

    Definition and Usage
    The system-property() function returns the value of the system property specified by the name.

    System properties in the XSLT namespace:

    xsl:version - The version of XSLT implemented by the processor
    xsl:vendor - The vendor of the XSLT processor
    xsl:vendor-url - The URL identifying the vendor of the XSLT processor

    --------------------------------------------------------------------------------

    Syntax
    object system-property(string)

    Parameters
    Parameter Description
    string Required. Specifies the system property to return the value of  

    Example 1


    Version:


    Vendor:


    Vendor URL:


    If you have Netscape 6 or IE 5 or higher you can view: the XSL file.

    View the result in Netscape 6 or IE 6

    --------------------------------------------------------------------------------

    The unparsed-entity-uri() Function

    --------------------------------------------------------------------------------

    Definition and Usage
    The unparsed-entity-uri() function returns the URI of an unparsed entity. The name of the entity must match the passed argument. If there is no such entity an empty string is returned.

    If the DTD contains the following declaration:


    the following expression:

    unparsed-entity-uri('pic')

    will return the URI for the file 'picture.jpg'.


    --------------------------------------------------------------------------------

    Syntax
    string unparsed-entity-uri(string)

    Parameters
    Parameter Description
    string Required. Specifies the name of an unparsed entity


       收藏   分享  
    顶(1)
      




    ----------------------------------------------
    <?xml version="1.0" encoding="gb2312"?>
    <个人签名>
      <Website>[url=http://www.mahaobo.cn]
    MaHaobo.cn[/url]
    </Website>
    <Email>aloning(at)gmail.com</Email>
      <Qq >32113739</Qq>
    </个人签名>

    点击查看用户来源及管理<br>发贴IP:*.*.*.* 2004/5/15 16:52:00
     
     robert 帅哥哟,离线,有人找我吗?
      
      
      等级:大二期末(汇编考了97分!)
      文章:77
      积分:304
      门派:XML.ORG.CN
      注册:2004/4/7

    姓名:(无权查看)
    城市:(无权查看)
    院校:(无权查看)
    给robert发送一个短消息 把robert加入好友 查看robert的个人资料 搜索robert在『 XSL/XSLT/XSL-FO/CSS 』的所有贴子 引用回复这个贴子 回复这个贴子 查看robert的博客2
    发贴心情 
    好,顶一个

    ----------------------------------------------
    [img]http://www.kcgx.com/images/rOBERT.gif[/img]

    点击查看用户来源及管理<br>发贴IP:*.*.*.* 2004/5/17 16:19:00
     
     GoogleAdSense
      
      
      等级:大一新生
      文章:1
      积分:50
      门派:无门无派
      院校:未填写
      注册:2007-01-01
    给Google AdSense发送一个短消息 把Google AdSense加入好友 查看Google AdSense的个人资料 搜索Google AdSense在『 XSL/XSLT/XSL-FO/CSS 』的所有贴子 访问Google AdSense的主页 引用回复这个贴子 回复这个贴子 查看Google AdSense的博客广告
    2024/4/28 19:25:09

    本主题贴数2,分页: [1]

    管理选项修改tag | 锁定 | 解锁 | 提升 | 删除 | 移动 | 固顶 | 总固顶 | 奖励 | 惩罚 | 发布公告
    W3C Contributing Supporter! W 3 C h i n a ( since 2003 ) 旗 下 站 点
    苏ICP备05006046号《全国人大常委会关于维护互联网安全的决定》《计算机信息网络国际联网安全保护管理办法》
    351.563ms