Open lllyfeng opened 1 year ago
XPath VS XQuery(must simplification) original XPath:
current()< (/l2vpn:l2vpn/l2vpn:common/l2vpn:vpws-bgp-vpns/l2vpn:vpws-bgp-vpn[l2vpn:name=current()/../../../l2vpn:vpn-instance]/l2vpn:sites/l2vpn:site[l2vpn:name = current()/../../../l2vpn:local-site]/range + /l2vpn:l2vpn/l2vpn:common/l2vpn:vpws-bgp-vpns/l2vpn:vpws-bgp-vpn[l2vpn:name = current()/../../../l2vpn:vpn-instance]/l2vpn:sites/l2vpn:site[l2vpn:name = current()/../../../l2vpn:local-site]/default-offset) and current() >= /l2vpn:l2vpn/l2vpn:common/l2vpn:vpws-bgp-vpns/l2vpn:vpws-bgp-vpn[l2vpn:name = current()/../../../l2vpn:vpn-instance]/l2vpn:sites/l2vpn:site[l2vpn:name = current()/../../../l2vpn:local-site]/default-offset
xquery:
for $site in (/l2vpn:l2vpn/l2vpn:common/l2vpn:vpws-bgp-vpns/l2vpn:vpws-bgp-vpn[l2vpn:name=current()/../../../l2vpn:vpn-instance]/l2vpn:sites/l2vpn:site[l2vpn:name = current()/../../../l2vpn:local-site]
where current() < ($site/range+ $site/ default-offset) and current() >= $site/default-offset
List pagination: original request:
<rpc xmlns="urn:ietf:params:xml:ns:netconf:base:1.0" message-id="42">
<get-config>
<source>
<running/>
</source>
<filter type="xpath" select="/es:members/es:member"
xmlns:es="http://example.com/ns/example-social"/>
<list-pagination
xmlns="urn:ietf:params:xml:ns:yang:ietf-netconf-list-paginat\
ion">true</list-pagination>
<where>//stats//joined[starts-with(@timestamp,'2020')]</where>
<sort-by>timestamp</sort-by>
<direction>backwards</direction>
<offset>2</offset>
<limit>2</limit>
<sublist-limit>1</sublist-limit>
</filter>
</get-config>
</rpc>
the request using xQuery:
<rpc xmlns="urn:ietf:params:xml:ns:netconf:base:1.0" message-id="42">
<get-config>
<source>
<running/>
</source>
<filter type="xquery“>
<script>
for $member in /es:members/es:member
where $member//stats/joined[starts-with(@timestamp,'2020')]
order by $member/timestamp descending
</script>
</filter>
<list-pagination>
<offset>2</offset>
<limit>2</limit>
<sublist-limit>1</sublist-limit>
</list-pagination>
</get-config>
</rpc>
adaptive subscription:
original condition:
xmlns:as="urn:ietf:params:xml:ns:yang:ietf-adaptive-subscription">
<as:adaptive-period>
<as:xpath-external-eval>
/wnd:server/wnd:rssi<-65
</as:xpath-external-eval>
<as:period>5</as:period>
</as:adaptive-period>
<as:adaptive-period>
<as:xpath-external-eval>
/wnd:server/wnd:rssi>=-65
</as:xpath-external-eval>
<as:period>60</as:period>
</as:adaptive-period>
</as:adaptive-subscriptions>
the condition using xQuery:
<as:adaptive-subscriptions
xmlns:as="urn:ietf:params:xml:ns:yang:ietf-adaptive-subscription">
<as:adaptive-period>
if (/wnd:server/wnd:rssi <-65) \
then \
return 5 \
else \
return 60 \
</as:adaptive-period>
</as:adaptive-subscriptions>
This is a netconf-next issue. I think a draft to augment protocol operations is already in progress.
Close
This is not only for netconf. XQuery may be used to simplify the when/must expression.
Scenarios:
Summary:
XPath is derived from the path language and is used to indicate paths. It is not a strong point in querying data and expressing complex logical relationships. A new language or algorithm is required to replace or strengthen XPath.
Solutions: