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 |
XQuery Function Declaration| See XSLT definition. | declare namespace functx = "http://www.functx.com";
declare function functx:name-test
( $testname as xs:string? ,
$names as xs:string* ) as xs:boolean {
$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,':*'))
} ; |
Exampleslet $in-xml := | <pre:a xmlns:pre="ns1">abc</pre:a> | return |
| XQuery 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 |
Recommended Reading: 
|