Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Table of Contents

Resources

...

IncorrectCorrectBookstore XML extract for testing xPath Queries online


Code Block
languagexml
<categories>
	<code>01</code>
    <name>SciFi</name>
	<books>
    </books>
</categories>



Code Block
languagexml
<categories code=01 name='SciFi'>
	<books>
    </books>
</categories>



Code Block
languagexml
titleBookstore
    <bookstore name="Chapters"> 
        <bookstore-name>Chapters</bookstore-name> 
        <categories code="01" name="SciFi"> 
            <books>
                 <book name="Feersum Endjinn"/>
                 <book name="Chapters"/>
           </books>
        </categories>
        <categories code="02" name="kids" /> 
        <categories code="03" name="Chapters" /> 
    </bookstore>



Open Issues & Decision

#SloganNotesAnswer
1Is there and xPath expression to 'include or exclude all descendants'Alternatively client can pass an enum option

Need to use output option additional to the cpsPath (xpath) expression!

Although xpath has many options to include or exclude children from filters (conditions) it does NOT control what is being returned.
The descendants are part of the data and a (xpath) query is not able to modify the data!

Queries

Scope of queries

  1. The assumes scope for all below Queries is one Dataspace and oen Anchor. 
  2. It will be relatively easy to extend the scope to multiple anchors in a later user story.
  3. There is no need to extend the scope beyond one Dataspace

xpath functions


SlogancpsPathJiraNotesPriority / When do we need this? 
1get (list element) by xpath/bookstore/categories[@code='01']

Jira
serverONAP JIRA
serverId425b2b0a-557c-3c0c-b515-579789cceedb
keyCPS-71

This is not really a query as code is the key attributes and this xpath is stored with the target fragmentAlready implemented
2filter list element by other (then key) leaf value/bookstore/categories[@name='SciFi']

Jira
serverONAP JIRA
serverId425b2b0a-557c-3c0c-b515-579789cceedb
keyCPS-231

Compare to #1, notice how from a cpsPath perspective it is not clear which is a get and which is a query. The customer might not know either! See issue #1Required for E2E Slicing see CPS-200 study
3xpath ending (with possible refernce to list key)

//book
//categories[@code=01]


Client ignore/does not care/does not know the preceding xpathInvestigate if needed for E2E Slicing. 
4xpath ending combined with leafvalue filter//categories[@name='SciFi']


5filter on leaf value without any path//*[@name='Chapters']
This will return anything with that name, might be useful when working with small models
6allow any element from list ie. find something under any possible list entry/bookstore/categories/books/book[@name='Chapters']
Not obvious but since /categories is not indexed  (no key defined using [@...] notation)  it will return a book from any categories
7partial xpath, wildcard in the middle of the path . Could be seen as combination of starts-with and end-with/bookstore/categories//book[@name='Chapters']
using // in the middle of a path is like a wildcard for any containers or lists between /categories and /book
8

combining several leaf values (and, or etc.)

Can bee seen too for composite list-keys and does work in scenario #1 above (but is order dependent)

[@id1 =  x and @id2 = y]
just for illustration purposes
9(string) leave value contains something[contains()]
just for illustration purposes
10get direct ancestor

//*[child::book[@name='Chapters']]

//book[@name="Chapters"]/..




11get ancestor by type

<query>/ancestor::bookstore

e.g //book[@name="Chapters"]/ancestor::bookstore


Required for end to end API call #1

...

Note 2.  At  the start the cpsPath can probably be examined using regular expression to distinguish between the queries. But at some stage we might need to write a more advanced parsing using tools like Antlr. There might also be existing utilities breaking down xpaths?

Updates

...

Jira
serverONAP JIRA
columnskey,summary,type,created,updated,due,assignee,reporter,priority,status,resolution
serverId425b2b0a-557c-3c0c-b515-579789cceedb
keyCPS-58

...

should be possible to add node with just the data for the new node (which includes a full xpath so that the parent an be identified)
further descendant can easily be included (should not require additional work ie. separate user story)

question: should the xpath for the list entry be generated (using the model and keyfield(s) data) or included in the dat provided by the client

...