XSLTsuppliesanumberoffunctions.
--------------------------------------------------------------------------------
XSLTFunctions
NameDescription
current()Returnsthecurrentnode
document()UsedtoaccessthenodesinanexternalXMLdocument
element-available()TestswhethertheelementspecifiedissupportedbytheXSLTprocessor
format-number()Convertsanumberintoastring
function-available()TestswhetherthefunctionspecifiedissupportedbytheXSLTprocessor
generate-id()Returnsastringvaluethatuniquelyidentifiesaspecifiednode
key()Returnsanode-setusingtheindexspecifiedbyanelement
system-property()Returnsthevalueofthesystemproperties
unparsed-entity-uri()ReturnstheURIofanunparsedentity
--------------------------------------------------------------------------------
InheritedXPathFunctions
NodeSetFunctions
NameDescriptionSyntax
count()返回结点个数number=count(node-set)
id()SelectselementsbytheiruniqueIDnode-set=id(value)
last()返回最后一个结点的需要number=last()
local-name()Returnsthelocalpartofanode.Anodeusuallyconsistsofaprefix,acolon,followedbythelocalnamestring=local-name(node)
name()返回一个结点的名称string=name(node)
namespace-uri()返回一个结点的名称空间uri=namespace-uri(node)
position()返回结点序号number=position()
StringFunctions
NameDescriptionSyntax&Example
concat()返回一个将N个字符串连接的值string=concat(val1,val2,..)
示例:
concat('The','','XML')
返回结果:'TheXML'
contains()如果val包含substr则返回truebool=contains(val,substr)
示例:
contains('XML','X')
返回结果:true
normalize-space()删除多余空格string=normalize-space(string)
示例:
normalize-space('TheXML')
返回结果:'TheXML'
starts-with()如果String以substr开始则返回truebool=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'
NumberFunctions
NameDescriptionSyntax&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)
BooleanFunctions
NameDescriptionSyntax&Example
boolean()ConvertsthevalueargumenttoBooleanandreturnstrueorfalsebool=boolean(value)
false()返回falsefalse()
示例:
number(false())
返回结果:0
lang()Returnstrueifthelanguageargumentmatchesthelanguageofthethexsl:langelement,otherwiseitreturnsfalsebool=lang(language)
not()Returnstrueiftheconditionargumentisfalse,andfalseiftheconditionargumentistruebool=not(condition)
示例:
not(false())
true()Returnstruetrue()
示例:
number(true())
返回结果:1
--------------------------------------------------------------------------------
Thecurrent()Function
--------------------------------------------------------------------------------
DefinitionandUsage
Thecurrent()functionreturnsanode-setthatcontainsonlythecurrentnode.Usuallythecurrentnodeandthecontextnodearethesame.
isequalto
However,thereisonedifference.LookatthefollowingXPathexpression:'catalog/cd'.Thisexpressionselectsthechildnodesofthecurrentnode,andthenitselectsthechildnodesofthenodes.Thismeansthatoneachstepofevaluation,the'.'hasadifferentmeaning.
Thefollowingline:
willprocessallcdelementsthathaveatitleattributewithvalueequaltothevalueofthecurrentnode'srefattribute.
Thisisdifferentfrom
thatwillprocessallcdelementsthathaveatitleattributeandarefattributewiththesamevalue.
--------------------------------------------------------------------------------
Syntax
node-setcurrent()
Example1
Currentnode:
IfyouhaveNetscape6orIE5orhigheryoucanview:theXMLfileandtheXSLfile.
ViewtheresultinNetscape6orIE6
Thedocument()Function
--------------------------------------------------------------------------------
DefinitionandUsage
Thedocument()functionisusedtoaccessnodesinanexternalXMLdocument.TheexternalXMLdocumentmustbevalidandparsable.
Onewaytousethisfunctionistolookupdatainanexternaldocument.ForexamplewewanttofindtheCelsiusvaluefromaFahrenheitvalueandwerefertoadocumentthatcontainssomepre-computedresults:
--------------------------------------------------------------------------------
Syntax
node-setdocument(object,node-set?)
Parameters
ParameterDescription
objectRequired.DefinesanURItoanexternalXMLdocument
node-setOptional.UsedtoresolverelativeURI
--------------------------------------------------------------------------------
Theelement-available()Function
--------------------------------------------------------------------------------
DefinitionandUsage
Theelement-available()functionreturnsaBooleanvaluethatindicateswhethertheelementspecifiedissupportedbytheXSLTprocessor.
Thisfunctioncanonlybeusedtotestelementsthatcanoccurinatemplatebody.Theseelementsare:
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:processinginstruction
xsl:text
xsl:value-of
xsl:variable
--------------------------------------------------------------------------------
Syntax
booleanelement-available(string)
Parameters
ParameterDescription
stringRequired.Specifiestheelementtotest
Example1
xsl:commentissupported.
xsl:commentisnotsupported.
xsl:deleteissupported.
xsl:deleteisnotsupported.
IfyouhaveNetscape6orIE5orhigheryoucanview:theXSLfile.
ViewtheresultinNetscape6orIE6
--------------------------------------------------------------------------------
Theformat-number()Function
--------------------------------------------------------------------------------
DefinitionandUsage
Theformat-number()functionisusedtoconvertanumberintoastring.
--------------------------------------------------------------------------------
Syntax
stringformat-number(number,format,[decimalformat])
Parameters
ParameterDescription
numberRequired.Specifiesthenumbertobeformatted
formatRequired.Specifiestheformatpattern.Herearesomeofthecharactersusedintheformattingpattern:
#(Denotesadigit.示例:####)
0(Denotesleadingandfollowingzeros.示例:0000.00)
.(Thepositionofthedecimalpoint示例:###.##)
,(Thegroupseparatorforthousands.示例:###,###.##)
%(Displaysthenumberasapercentage.示例:##%)
;(Patternseparator.Thefirstpatternwillbeusedforpositivenumbersandthesecondfornegativenumbers)
decimalformatOptional.
Example1
IfyouhaveNetscape6orIE5orhigheryoucanview:theXSLfile.
ViewtheresultinNetscape6orIE6
Thefunction-available()Function
--------------------------------------------------------------------------------
DefinitionandUsage
Thefunction-available()functionreturnsaBooleanvaluethatindicateswhetherthefunctionspecifiedissupportedbytheXSLTprocessor.
YoumaytesttheXSLTfunctionsandtheinheritedXPathfunctions.
--------------------------------------------------------------------------------
Syntax
booleanfunction-available(string)
Parameters
ParameterDescription
stringRequired.Specifiesthefunctiontotest
Example1
sum()issupported.
sum()isnotsupported.
current()issupported.
current()isnotsupported.
IfyouhaveNetscape6orIE5orhigheryoucanview:theXSLfile.
ViewtheresultinNetscape6orIE6
--------------------------------------------------------------------------------
Thegenerate-id()Function
--------------------------------------------------------------------------------
DefinitionandUsage
Thegenerate-id()functionreturnsastringvaluethatuniquelyidentifiesaspecifiednode.
Ifthenode-setspecifiedisempty,anemptystringisreturned.Ifyouomitthenode-setparameter,itdefaultstothecurrentnode.
--------------------------------------------------------------------------------
Syntax
stringgenerate-id(node-set?)
Parameters
ParameterDescription
node-setOptional.Specifiesonwhichnode-settogenerateauniqueid
Example1
Artists:
--------------------------------------------------------------------------------
Artist:
Title:
Price:
--------------------------------------------------------------------------------
IfyouhaveNetscape6orIE5orhigheryoucanview:theXMLfileandtheXSLfile.
ViewtheresultinNetscape6orIE6
--------------------------------------------------------------------------------
Thekey()Function
--------------------------------------------------------------------------------
DefinitionandUsage
Thekey()functionreturnsanode-setfromthedocument,usingtheindexspecifiedbyanelement.
--------------------------------------------------------------------------------
Syntax
node-setkey(string,object)
Parameters
ParameterDescription
stringRequired.Specifiesthenameofanxsl:keyelement
objectRequired.Astringtosearchfor
Example1
Title:
Artist:
Price:
IfyouhaveNetscape6orIE5orhigheryoucanview:theXMLfileandtheXSLfile.
ViewtheresultinNetscape6orIE6
--------------------------------------------------------------------------------
Thesystem-property()Function
--------------------------------------------------------------------------------
DefinitionandUsage
Thesystem-property()functionreturnsthevalueofthesystempropertyspecifiedbythename.
SystempropertiesintheXSLTnamespace:
xsl:version-TheversionofXSLTimplementedbytheprocessor
xsl:vendor-ThevendoroftheXSLTprocessor
xsl:vendor-url-TheURLidentifyingthevendoroftheXSLTprocessor
--------------------------------------------------------------------------------
Syntax
objectsystem-property(string)
Parameters
ParameterDescription
stringRequired.Specifiesthesystempropertytoreturnthevalueof
Example1
Version:
Vendor:
VendorURL:
IfyouhaveNetscape6orIE5orhigheryoucanview:theXSLfile.
ViewtheresultinNetscape6orIE6
--------------------------------------------------------------------------------
Theunparsed-entity-uri()Function
--------------------------------------------------------------------------------
DefinitionandUsage
Theunparsed-entity-uri()functionreturnstheURIofanunparsedentity.Thenameoftheentitymustmatchthepassedargument.Ifthereisnosuchentityanemptystringisreturned.
IftheDTDcontainsthefollowingdeclaration:
thefollowingexpression:
unparsed-entity-uri('pic')
willreturntheURIforthefile'picture.jpg'.
--------------------------------------------------------------------------------
Syntax
stringunparsed-entity-uri(string)
Parameters
ParameterDescription
stringRequired.Specifiesthenameofanunparsedentity
相关推荐
XSL函数大全 XSL元素大全 常用的XPATH手册 XSL知识速查
用 xsl 中的各种函数为 XML 显示提供灵活性
一本非常好的XSL入门教程, 分成以下几大单元 1.第一个XML文档 2.XSL入门 3.XSL模板与...运算符,关系与逻辑运算符,特殊字符等 7.XSL函数之一 8.脚本与XSL的结合及应用 9.XSL函数之二(DOM中对象的方法)
XSL functions CLX. XSLT Functions CLXI. YAZ Functions CLXII. YP/NIS Functions CLXIII. Zip File Functions (Read Only Access) CLXIV. Zlib Compression Functions VII. PHP 和 Zend 引擎内部资料 44. PHP ...
一本非常好的XSL入门教程, 分成以下几大单元 1.第一个XML文档 2.XSL入门 3.XSL模板与匹配模式 4.测试模式 5.XSL中的choose ...6.运算符,关系与逻辑运算符,特殊字符等 ...9.XSL函数之二(DOM中对象的方法)
稍熟悉XPATH的人都知道,在XSL中使用translate函数可以将一个字符串进行逐字符替换。但是,如果要替换一个子字符串为另一个子字符串,对XPATH1.0而言,用translate就有点力不从心了。 一般来讲,在XSL中进行字符串...
本文相关代码,解压为一个eclipse工程 博文链接:https://capslk.iteye.com/blog/457347
XSL基础、 函数、 元素参考手册、 学习笔记
BasicXSLT在GitHub上有一个新主页,网址为:... 允许将多个XSL样式表链接在一起,并允许在每个样式表上设置参数和输出属性。 记住配置信息并提供定时号。
QTP调用XML的方法大全,所有函数都应有尽有
版权信息 前言 入门指引 简介 ...XSL — XSL functions XSLT — XSLT Functions YAZ — YAZ Functions YP/NIS — YP/NIS Functions Zip — Zip File Functions Zlib — Zlib Compression Functions ...
Mehdi Achour Friedhelm Betz ...XSL — XSL functions XSLT — XSLT Functions YAZ — YAZ Functions YP/NIS — YP/NIS Functions Zip — Zip File Functions Zlib — Zlib Compression Functions ...
XSL functions CLX. XSLT Functions CLXI. YAZ Functions CLXII. YP/NIS Functions CLXIII. Zip File Functions (Read Only Access) CLXIV. Zlib Compression Functions VII. PHP 和 Zend 引擎内部资料 44. PHP ...
C++函数库.chm, directx9_c.chm, Linux命令大全.chm, MFC类库详解.chm, MFC中文帮助.chm, windows_pd.chm, WINDOWS核心编程.chm, windows脚本技术.chm, 经典 C++ 语言教程.chm, 数据结构与算法综合资料库.chm, 新编...
XSL functions CLXXXV. XSLT Functions CLXXXVI. YAZ Functions CLXXXVII. YP/NIS Functions CLXXXVIII. Zip File Functions CLXXXIX. Zlib Compression Functions VII. ...
XSL functions CLX. XSLT Functions CLXI. YAZ Functions CLXII. YP/NIS Functions CLXIII. Zip File Functions (Read Only Access) CLXIV. Zlib Compression Functions VII. PHP 和 Zend 引擎内部资料 44. PHP ...
XSL functions CLX. XSLT Functions CLXI. YAZ Functions CLXII. YP/NIS Functions CLXIII. Zip File Functions (Read Only Access) CLXIV. Zlib Compression Functions VII. PHP 和 Zend 引擎内部资料 44. ...
XSL functions CLXV. XSLT Functions CLXVI. YAZ Functions CLXVII. YP/NIS Functions CLXVIII. Zip File Functions (Read Only Access) CLXIX. Zlib Compression Functions VII. PHP 和 Zend 引擎内部资料 44. ...
XSL functions CLX. XSLT Functions CLXI. YAZ Functions CLXII. YP/NIS Functions CLXIII. Zip File Functions (Read Only Access) CLXIV. Zlib Compression Functions VII. PHP 和 Zend 引擎内部资料 44. PHP ...
XSL functions CLXXXV. XSLT Functions CLXXXVI. YAZ Functions CLXXXVII. YP/NIS Functions CLXXXVIII. Zip File Functions CLXXXIX. Zlib Compression Functions VII. ...