[Issue with bare axis names](https://github.com/clicon/clixon/issues/54)
This commit is contained in:
parent
7e4cce0000
commit
28bd698968
4 changed files with 31 additions and 18 deletions
|
|
@ -155,6 +155,7 @@
|
||||||
* New config option: CLICON_CLI_MODEL_TREENAME defining name of generated syntax tree if CLIXON_CLI_GENMODEL is set.
|
* New config option: CLICON_CLI_MODEL_TREENAME defining name of generated syntax tree if CLIXON_CLI_GENMODEL is set.
|
||||||
|
|
||||||
### Corrected Bugs
|
### Corrected Bugs
|
||||||
|
* [Issue with bare axis names](https://github.com/clicon/clixon/issues/54)
|
||||||
* Did not check for missing keys in validate. [Key of a list isn't mandatory](https://github.com/clicon/clixon/issues/73)
|
* Did not check for missing keys in validate. [Key of a list isn't mandatory](https://github.com/clicon/clixon/issues/73)
|
||||||
* Problem here is that you can still add keys via netconf - since validation is a separate step, but in cli or restconf it should not be possible.
|
* Problem here is that you can still add keys via netconf - since validation is a separate step, but in cli or restconf it should not be possible.
|
||||||
* Partially corrected: [yang type range statement does not support multiple values](https://github.com/clicon/clixon/issues/59).
|
* Partially corrected: [yang type range statement does not support multiple values](https://github.com/clicon/clixon/issues/59).
|
||||||
|
|
|
||||||
|
|
@ -94,8 +94,7 @@ real ({digit}+[.]{digit}*)|({digit}*[.]{digit}+)
|
||||||
<TOKEN>\r { }
|
<TOKEN>\r { }
|
||||||
<TOKEN><<EOF>> { return X_EOF; }
|
<TOKEN><<EOF>> { return X_EOF; }
|
||||||
<TOKEN>".." { return DOUBLEDOT; }
|
<TOKEN>".." { return DOUBLEDOT; }
|
||||||
<TOKEN>[()\[\]\.@,/:|] { return *yytext; }
|
<TOKEN>[()\[\]\.,/:|] { return *yytext; }
|
||||||
<TOKEN>"::" { return DOUBLECOLON; }
|
|
||||||
<TOKEN>and { clixon_xpath_parselval.intval = clicon_str2int(xpopmap, yytext); return LOGOP; }
|
<TOKEN>and { clixon_xpath_parselval.intval = clicon_str2int(xpopmap, yytext); return LOGOP; }
|
||||||
<TOKEN>or { clixon_xpath_parselval.intval = clicon_str2int(xpopmap, yytext); return LOGOP; }
|
<TOKEN>or { clixon_xpath_parselval.intval = clicon_str2int(xpopmap, yytext); return LOGOP; }
|
||||||
<TOKEN>div { clixon_xpath_parselval.intval = clicon_str2int(xpopmap,yytext); return ADDOP; }
|
<TOKEN>div { clixon_xpath_parselval.intval = clicon_str2int(xpopmap,yytext); return ADDOP; }
|
||||||
|
|
@ -110,24 +109,28 @@ real ({digit}+[.]{digit}*)|({digit}*[.]{digit}+)
|
||||||
<TOKEN>last { clixon_xpath_parselval.string = strdup(yytext); return FUNCTIONNAME; }
|
<TOKEN>last { clixon_xpath_parselval.string = strdup(yytext); return FUNCTIONNAME; }
|
||||||
<TOKEN>position { clixon_xpath_parselval.string = strdup(yytext); return FUNCTIONNAME; }
|
<TOKEN>position { clixon_xpath_parselval.string = strdup(yytext); return FUNCTIONNAME; }
|
||||||
<TOKEN>count { clixon_xpath_parselval.string = strdup(yytext); return FUNCTIONNAME; }
|
<TOKEN>count { clixon_xpath_parselval.string = strdup(yytext); return FUNCTIONNAME; }
|
||||||
<TOKEN>ancestor { clixon_xpath_parselval.intval = A_ANCESTOR; return AXISNAME; }
|
|
||||||
<TOKEN>ancestor-or-self { clixon_xpath_parselval.intval = A_ANCESTOR_OR_SELF; return AXISNAME; }
|
<TOKEN>@ { return *yytext; }
|
||||||
<TOKEN>attribute { clixon_xpath_parselval.intval = A_ATTRIBUTE; return AXISNAME; }
|
<TOKEN>ancestor:: { clixon_xpath_parselval.intval = A_ANCESTOR; return AXISNAME; }
|
||||||
<TOKEN>child { clixon_xpath_parselval.intval = A_CHILD; return AXISNAME; }
|
<TOKEN>ancestor-or-self:: { clixon_xpath_parselval.intval = A_ANCESTOR_OR_SELF; return AXISNAME; }
|
||||||
<TOKEN>descendant { clixon_xpath_parselval.intval = A_DESCENDANT; return AXISNAME; }
|
<TOKEN>attribute:: { clixon_xpath_parselval.intval = A_ATTRIBUTE; return AXISNAME; }
|
||||||
<TOKEN>descendant-or-self { clixon_xpath_parselval.intval = A_DESCENDANT_OR_SELF; return AXISNAME; }
|
<TOKEN>child:: { clixon_xpath_parselval.intval = A_CHILD; return AXISNAME; }
|
||||||
<TOKEN>following { clixon_xpath_parselval.intval = A_FOLLOWING; return AXISNAME; }
|
<TOKEN>descendant:: { clixon_xpath_parselval.intval = A_DESCENDANT; return AXISNAME; }
|
||||||
<TOKEN>following-sibling { clixon_xpath_parselval.intval = A_FOLLOWING_SIBLING; return AXISNAME; }
|
<TOKEN>descendant-or-self:: { clixon_xpath_parselval.intval = A_DESCENDANT_OR_SELF; return AXISNAME; }
|
||||||
<TOKEN>namespace { clixon_xpath_parselval.intval = A_NAMESPACE; return AXISNAME; }
|
<TOKEN>following:: { clixon_xpath_parselval.intval = A_FOLLOWING; return AXISNAME; }
|
||||||
<TOKEN>parent { clixon_xpath_parselval.intval = A_PARENT; return AXISNAME; }
|
<TOKEN>following-sibling:: { clixon_xpath_parselval.intval = A_FOLLOWING_SIBLING; return AXISNAME; }
|
||||||
<TOKEN>preceding { clixon_xpath_parselval.intval = A_PRECEEDING; return AXISNAME; }
|
<TOKEN>namespace:: { clixon_xpath_parselval.intval = A_NAMESPACE; return AXISNAME; }
|
||||||
<TOKEN>preceding-sibling { clixon_xpath_parselval.intval = A_PRECEEDING_SIBLING; return AXISNAME; }
|
<TOKEN>parent:: { clixon_xpath_parselval.intval = A_PARENT; return AXISNAME; }
|
||||||
<TOKEN>self { clixon_xpath_parselval.intval = A_SELF; return AXISNAME; }
|
<TOKEN>preceding:: { clixon_xpath_parselval.intval = A_PRECEEDING; return AXISNAME; }
|
||||||
|
<TOKEN>preceding-sibling:: { clixon_xpath_parselval.intval = A_PRECEEDING_SIBLING; return AXISNAME; }
|
||||||
|
<TOKEN>self:: { clixon_xpath_parselval.intval = A_SELF; return AXISNAME; }
|
||||||
|
|
||||||
<TOKEN>current { clixon_xpath_parselval.string = strdup(yytext); return NODETYPE; }
|
<TOKEN>current { clixon_xpath_parselval.string = strdup(yytext); return NODETYPE; }
|
||||||
<TOKEN>comment { clixon_xpath_parselval.string = strdup(yytext); return NODETYPE; }
|
<TOKEN>comment { clixon_xpath_parselval.string = strdup(yytext); return NODETYPE; }
|
||||||
<TOKEN>text { clixon_xpath_parselval.string = strdup(yytext); return NODETYPE; }
|
<TOKEN>text { clixon_xpath_parselval.string = strdup(yytext); return NODETYPE; }
|
||||||
<TOKEN>processing-instructions { clixon_xpath_parselval.string = strdup(yytext); return NODETYPE; }
|
<TOKEN>processing-instructions { clixon_xpath_parselval.string = strdup(yytext); return NODETYPE; }
|
||||||
<TOKEN>node { clixon_xpath_parselval.string = strdup(yytext); return NODETYPE; }
|
<TOKEN>node { clixon_xpath_parselval.string = strdup(yytext); return NODETYPE; }
|
||||||
|
|
||||||
<TOKEN>\" { BEGIN(QLITERAL); return QUOTE; }
|
<TOKEN>\" { BEGIN(QLITERAL); return QUOTE; }
|
||||||
<TOKEN>\' { BEGIN(ALITERAL); return APOST; }
|
<TOKEN>\' { BEGIN(ALITERAL); return APOST; }
|
||||||
<TOKEN>\-?({integer}|{real}) { sscanf(yytext,"%lf",&clixon_xpath_parselval.dval); return NUMBER;}
|
<TOKEN>\-?({integer}|{real}) { sscanf(yytext,"%lf",&clixon_xpath_parselval.dval); return NUMBER;}
|
||||||
|
|
@ -135,6 +138,7 @@ real ({digit}+[.]{digit}*)|({digit}*[.]{digit}+)
|
||||||
return NAME; /* rather be catch-all */
|
return NAME; /* rather be catch-all */
|
||||||
}
|
}
|
||||||
<TOKEN>. { fprintf(stderr,"LEXICAL ERROR\n"); return -1; }
|
<TOKEN>. { fprintf(stderr,"LEXICAL ERROR\n"); return -1; }
|
||||||
|
|
||||||
<QLITERAL>\" { BEGIN(TOKEN); return QUOTE; }
|
<QLITERAL>\" { BEGIN(TOKEN); return QUOTE; }
|
||||||
<QLITERAL>. { clixon_xpath_parselval.string = strdup(yytext);
|
<QLITERAL>. { clixon_xpath_parselval.string = strdup(yytext);
|
||||||
return CHAR;}
|
return CHAR;}
|
||||||
|
|
|
||||||
|
|
@ -63,7 +63,6 @@
|
||||||
%token <string> NAME
|
%token <string> NAME
|
||||||
%token <string> NODETYPE
|
%token <string> NODETYPE
|
||||||
%token <string> DOUBLEDOT
|
%token <string> DOUBLEDOT
|
||||||
%token <string> DOUBLECOLON
|
|
||||||
%token <string> DOUBLESLASH
|
%token <string> DOUBLESLASH
|
||||||
%token <string> FUNCTIONNAME
|
%token <string> FUNCTIONNAME
|
||||||
|
|
||||||
|
|
@ -243,7 +242,7 @@ step : axisspec nodetest predicates {$$=xp_new(XP_STEP,$1,0.0, NULL, NULL
|
||||||
| DOUBLEDOT predicates { $$=xp_new(XP_STEP, A_PARENT, 0.0,NULL, NULL, NULL, $2); clicon_debug(2,"step-> .."); }
|
| DOUBLEDOT predicates { $$=xp_new(XP_STEP, A_PARENT, 0.0,NULL, NULL, NULL, $2); clicon_debug(2,"step-> .."); }
|
||||||
;
|
;
|
||||||
|
|
||||||
axisspec : AXISNAME DOUBLECOLON { clicon_debug(2,"axisspec-> AXISNAME(%d) ::", $1); $$=$1;}
|
axisspec : AXISNAME { clicon_debug(2,"axisspec-> AXISNAME(%d) ::", $1); $$=$1;}
|
||||||
| '@' { $$=A_ATTRIBUTE; clicon_debug(2,"axisspec-> @"); }
|
| '@' { $$=A_ATTRIBUTE; clicon_debug(2,"axisspec-> @"); }
|
||||||
| { clicon_debug(2,"axisspec-> "); $$=A_CHILD;}
|
| { clicon_debug(2,"axisspec-> "); $$=A_CHILD;}
|
||||||
;
|
;
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,6 @@ s="$_" ; . ./lib.sh || if [ "$s" = $0 ]; then exit 0; else return 0; fi
|
||||||
xml=$dir/xml.xml
|
xml=$dir/xml.xml
|
||||||
xml2=$dir/xml2.xml
|
xml2=$dir/xml2.xml
|
||||||
xml3=$dir/xml3.xml
|
xml3=$dir/xml3.xml
|
||||||
xml4=$dir/xml4.xml
|
|
||||||
|
|
||||||
cat <<EOF > $xml
|
cat <<EOF > $xml
|
||||||
<aaa>
|
<aaa>
|
||||||
|
|
@ -59,6 +58,7 @@ cat <<EOF > $xml2
|
||||||
<here2><here/></here2>
|
<here2><here/></here2>
|
||||||
<ifType>ethernet</ifType>
|
<ifType>ethernet</ifType>
|
||||||
<ifMTU>1500</ifMTU>
|
<ifMTU>1500</ifMTU>
|
||||||
|
<namespace>urn:example:foo</namespace>
|
||||||
</bbb>
|
</bbb>
|
||||||
</aaa>
|
</aaa>
|
||||||
EOF
|
EOF
|
||||||
|
|
@ -174,6 +174,15 @@ expecteof "$clixon_util_xpath -f $xml2 -i /aaa/bbb" 0 "ifType != \"atm\" or (ifM
|
||||||
new "xpath .[name='bar']"
|
new "xpath .[name='bar']"
|
||||||
expecteof "$clixon_util_xpath -f $xml2 -p .[name='bar'] -i /aaa/bbb/routing/ribs/rib" 0 "" "^nodeset:0:<rib><name>bar</name><address-family>myfamily</address-family></rib>$"
|
expecteof "$clixon_util_xpath -f $xml2 -p .[name='bar'] -i /aaa/bbb/routing/ribs/rib" 0 "" "^nodeset:0:<rib><name>bar</name><address-family>myfamily</address-family></rib>$"
|
||||||
|
|
||||||
|
new "xpath /aaa/bbb/namespace (namespace is xpath axisname)"
|
||||||
|
echo "$clixon_util_xpath -f $xml2 -p /aaa/bbb/namespace"
|
||||||
|
expecteof "$clixon_util_xpath -f $xml2 -p /aaa/bbb/namespace" 0 "" "^nodeset:0:<namespace>urn:example:foo</namespace>$"
|
||||||
|
|
||||||
|
# See https://github.com/clicon/clixon/issues/54
|
||||||
|
# But it is not only axis names. There are also, for example, nodetype like this example:
|
||||||
|
#new "xpath /aaa/bbb/comment (comment is xpath nodetype)"
|
||||||
|
#expecteof "$clixon_util_xpath -f $xml2 -p /aaa/bbb/comment" 0 "" "^kalle$"
|
||||||
|
|
||||||
new "Multiple entries"
|
new "Multiple entries"
|
||||||
new "xpath bbb[ccc='foo']"
|
new "xpath bbb[ccc='foo']"
|
||||||
expecteof "$clixon_util_xpath -f $xml3 -p bbb[ccc='foo']" 0 "" "^nodeset:0:<bbb x=\"hello\"><ccc>foo</ccc><ccc>42</ccc><ccc>bar</ccc></bbb>1:<bbb x=\"bye\"><ccc>99</ccc><ccc>foo</ccc></bbb>$"
|
expecteof "$clixon_util_xpath -f $xml3 -p bbb[ccc='foo']" 0 "" "^nodeset:0:<bbb x=\"hello\"><ccc>foo</ccc><ccc>42</ccc><ccc>bar</ccc></bbb>1:<bbb x=\"bye\"><ccc>99</ccc><ccc>foo</ccc></bbb>$"
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue