netmod-wg / yang-next

Feature requests for future versions of YANG
6 stars 0 forks source link

The next step of XPath #119

Open lllyfeng opened 1 year ago

lllyfeng commented 1 year ago

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:

lllyfeng commented 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
lllyfeng commented 1 year ago

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>
lllyfeng commented 1 year ago

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&lt;-65
       </as:xpath-external-eval>
       <as:period>5</as:period>
      </as:adaptive-period>
      <as:adaptive-period>
       <as:xpath-external-eval>
        /wnd:server/wnd:rssi&gt;=-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>
abierman commented 2 months ago

This is a netconf-next issue. I think a draft to augment protocol operations is already in progress.

Close

lllyfeng commented 2 months ago

This is not only for netconf. XQuery may be used to simplify the when/must expression.

kwatsen commented 1 month ago

Not NETCONF-only. E.g., List-pagination is for RESTCONF also, and it uses XPath (see Section 3.1.1)

Given that the LP-rc draft is almost in WGLC, and it is unlikely to change, and already the issue exists, it seems the only option would be to offer the possibility of optionally using XQuery.

Worth it? IDK

BalazsLengyel commented 1 month ago

Seems to complex. Even Xpath is complicated sometimes. Don't support.

kwatsen commented 1 month ago

Rob: may be better for YANG to define a "simple" (YANGpath?) expression language Andy: protocol-query filters != must/when expressions Rob: Xpath 1.0 is currently dead !!! Kent: This was importance low, because we don't want to do it for 2.0, but it is actually an important issue! Rob: Cisco has it's own simpler language