* C-API: Added xpath_first_localonly() as an xpath function that skips prefix and namespace checks.
* Added experimental code for optizing XPath search using binary search. * Enable with XPATH_LIST_OPTIMIZE * Changed `clicon_rpc_generate_error(msg, xerr)` to `clicon_rpc_generate_error(xerr, msg, arg)`
This commit is contained in:
parent
ab46ce9820
commit
7ad16bd84b
56 changed files with 602 additions and 227 deletions
65
test/test_xpath_canonical.sh
Executable file
65
test/test_xpath_canonical.sh
Executable file
|
|
@ -0,0 +1,65 @@
|
|||
#!/usr/bin/env bash
|
||||
# Test xpath canonical namespace context form
|
||||
|
||||
# Magic line must be first in script (see README.md)
|
||||
s="$_" ; . ./lib.sh || if [ "$s" = $0 ]; then exit 0; else return 0; fi
|
||||
|
||||
: ${clixon_util_xpath:=clixon_util_xpath}
|
||||
|
||||
ydir=$dir/yang
|
||||
|
||||
if [ ! -d $ydir ]; then
|
||||
mkdir $ydir
|
||||
fi
|
||||
|
||||
# canonical namespace xpath tests
|
||||
# need yang modules
|
||||
cat <<EOF > $ydir/a.yang
|
||||
module a{
|
||||
namespace "urn:example:a";
|
||||
prefix a;
|
||||
container x{
|
||||
leaf xa{
|
||||
type string;
|
||||
}
|
||||
}
|
||||
}
|
||||
EOF
|
||||
|
||||
cat <<EOF > $ydir/b.yang
|
||||
module b{
|
||||
namespace "urn:example:b";
|
||||
prefix b;
|
||||
container y{
|
||||
leaf ya{
|
||||
type string;
|
||||
}
|
||||
}
|
||||
}
|
||||
EOF
|
||||
|
||||
new "xpath canonical form (already canonical)"
|
||||
expectpart "$($clixon_util_xpath -c -y $ydir -p /a:x/b:y -n a:urn:example:a -n b:urn:example:b)" 0 '/a:x/b:y' '0 : a = "urn:example:a"' '1 : b = "urn:example:b"'
|
||||
|
||||
new "xpath canonical form (default)"
|
||||
expectpart "$($clixon_util_xpath -c -y $ydir -p /x/b:y -n null:urn:example:a -n b:urn:example:b)" 0 '/a:x/b:y' '0 : a = "urn:example:a"' '1 : b = "urn:example:b"'
|
||||
|
||||
new "xpath canonical form (other)"
|
||||
expectpart "$($clixon_util_xpath -c -y $ydir -p /i:x/j:y -n i:urn:example:a -n j:urn:example:b)" 0 '/a:x/b:y' '0 : a = "urn:example:a"' '1 : b = "urn:example:b"'
|
||||
|
||||
new "xpath canonical form predicate 1"
|
||||
expectpart "$($clixon_util_xpath -c -y $ydir -p "/i:x[j:y='e1']" -n i:urn:example:a -n j:urn:example:b)" 0 "/a:x\[b:y='e1'\]" '0 : a = "urn:example:a"' '1 : b = "urn:example:b"'
|
||||
|
||||
new "xpath canonical form predicate self"
|
||||
expectpart "$($clixon_util_xpath -c -y $ydir -p "/i:x[.='42']" -n i:urn:example:a -n j:urn:example:b)" 0 "/a:x\[.='42'\]" '0 : a = "urn:example:a"'
|
||||
|
||||
new "xpath canonical form descendants"
|
||||
expectpart "$($clixon_util_xpath -c -y $ydir -p "//x[.='42']" -n null:urn:example:a -n j:urn:example:b)" 0 "//a:x\[.='42'\]" '0 : a = "urn:example:a"'
|
||||
|
||||
new "xpath canonical form (no default should fail)"
|
||||
expectpart "$($clixon_util_xpath -c -y $ydir -p /x/j:y -n i:urn:example:a -n j:urn:example:b)" 255
|
||||
|
||||
new "xpath canonical form (wrong namespace should fail)"
|
||||
expectpart "$($clixon_util_xpath -c -y $ydir -p /i:x/j:y -n i:urn:example:c -n j:urn:example:b)" 255
|
||||
|
||||
rm -rf $dir
|
||||
Loading…
Add table
Add a link
Reference in a new issue