Description
The functx:name-test function tests a name against a list of names or name wildcards. Valid name wildcards are:
*, which matches all names
*:x, where x is a local name, which matches all names with that local name, in any namespace
p:*, where p is a prefix, which matches all names in the namespace associated with that prefix.
Arguments and Return Type| Name | Type | Description |
$testname |
xs:string? |
the name to test |
$names |
xs:string* |
the list of names or name wildcards |
| return value |
xs:boolean |
XSLT Function Declaration| See XQuery definition. | | XSLT 2.0 Syntax: |
|---|
<xsl:function name="functx:name-test" as="xs:boolean"
xmlns:functx="http://www.functx.com" >
<xsl:param name="testname" as="xs:string?"/>
<xsl:param name="names" as="xs:string*"/>
<xsl:sequence select="
$testname = $names
or
$names = '*'
or
functx:substring-after-if-contains($testname,':') =
(for $name in $names
return substring-after($name,'*:'))
or
substring-before($testname,':') =
(for $name in $names[contains(.,':*')]
return substring-before($name,':*'))
"/>
</xsl:function>
|
Examples<xsl:variable name="in-xml" as="item()*"> | | <pre:a xmlns:pre="ns1">abc</pre:a> |
| </xsl:variable> |
| XSLT Example | Results |
|---|
functx:name-test(name($in-xml),('*'))
|
true
|
functx:name-test(name($in-xml),('pre:*'))
|
true
|
functx:name-test(name($in-xml),('*:a'))
|
true
|
functx:name-test(
name($in-xml),('pre:a','pre:b'))
|
true
|
functx:name-test(
name($in-xml),('a','b','c'))
|
false
|
Depends OnHistory |
|