-
Bug
-
Resolution: Duplicate
-
Medium
-
Montreal Release
-
None
When testing the attached JSON data for CPS-1696 the following inconsistencies are observed between Get Node and Query Node API
The sample data consists of 3 books with following titles and their respective xpath having [ and ] brackets.
- Book with [ in title
- xpath: /bookstore/categories[@code=1]/books[@title="Book with [ in title"]
- Book with ] in title
- xpath: /bookstore/categories[@code=1]/books[@title="Book with ] in title"]
- Book with [ and ] in title
-
- xpath: /bookstore/categories[@code=1]/books[@title="Book with [ and ] in title"]
All the three books are part of the list books. So, when retrieving the list using Query Node API the expected response should be as follows:
xpath: /bookstore/categories[@code=1]/books
[ { "book-store:books": { "lang": "English", "price": 15, "title": "Book with ] in title", "authors": [ "Test" ], "editions": [ 1999 ] } }, { "book-store:books": { "lang": "English", "price": 10, "title": "Book with [ in title", "authors": [ "Test" ], "editions": [ 1988, 2000 ] } }, { "book-store:books": { "lang": "English", "price": 10, "title": "Book with [ and ] in titl", "authors": [ "Test" ], "editions": [ 1988, 2000 ] } } ]
But we get the following response (with the book having only ] in the title):
[ { "book-store:books": { "lang": "English", "price": 15, "title": "Book with ] in title", "authors": [ "Test 2" ], "editions": [ 1999 ] } } ]
And when we use the parent node xpath we see the following bug in the response
[ { "book-store:categories": { "code": "1", "name": "Children", "books": [ { "lang": "English", "price": 15, "title": "Book with ] in title", "authors": [ "Test 2" ], "editions": [ 1999 ] } ], "books[@title='Book with ": [ { "lang": "English", "price": 10, "title": "Book with [ in title", "authors": [ "Test" ], "editions": [ 1988, 2000 ] }, { "lang": "English", "price": 15, "title": "Book with [ and ] in title", "authors": [ "Test 3" ], "editions": [ 1999 ] } ] } } ]
We can see that the get node API processes the books with [ in title differently and adds them to a separate list with list name "books[@title='Book with " which is nonexistent and invalid.
Similarly, when testing the Get Node API for same scenario with changes of CPS 1696 we get the following response:
xpath: /bookstore/categories[@code=1]/books
[ { "book-store:books": { "lang": "English", "price": 15, "title": "Book with ] in title", "authors": [ "Test 2" ], "editions": [ 1999 ] } } ]
And with parent node xpath we get the following response:
xpath: /bookstore/categories[@code=1]
[ { "book-store:categories": { "code": "1", "name": "Children", "books": [ { "lang": "English", "price": 15, "title": "Book with ] in title", "authors": [ "Test 2" ], "editions": [ 1999 ] } ], "books[@title='Book with ": [ { "lang": "English", "price": 10, "title": "Book with [ in title", "authors": [ "Test" ], "editions": [ 1988, 2000 ] }, { "lang": "English", "price": 15, "title": "Book with [ and ] in title", "authors": [ "Test 3" ], "editions": [ 1999 ] } ] } } ]
Here again we can see that the get node API processes the books with [ in title differently and adds them to a separate list with list name "books[@title='Book with " which is nonexistent and invalid.
Now we try to retrieve the data using the absolute path for
- Book with ] in title
- Book with [ and ] in title
We get the following responses for both Get API and Query API for:
Book with ] in title (xpath: /bookstore/categories[@code=1]/books[@title="Book with ] in title"])
Same response by GET and Query API
[ { "book-store:books": { "lang": "English", "price": 15, "title": "Book with ] in title", "authors": [ "Test 2" ], "editions": [ 1999 ] } } ]
-
- But for the following book title we get different responses from Get and Query API
Book with [ and ] in title (xpath: /bookstore/categories[@code=1]/books[@title="Book with [ and ] in title"])
Get API Response[ { "book-store:books[@title='Book with ": { "lang": "English", "price": 15, "title": "Book with [ and ] in title", "authors": [ "Test 3" ], "editions": [ 1999 ] } } ]
Query API response
[ ]
- But for the following book title we get different responses from Get and Query API