aboutsummaryrefslogtreecommitdiffstats
path: root/docs
diff options
context:
space:
mode:
Diffstat (limited to 'docs')
-rw-r--r--docs/cps-path.rst22
1 files changed, 20 insertions, 2 deletions
diff --git a/docs/cps-path.rst b/docs/cps-path.rst
index eb203d8918..cfaad3ca57 100644
--- a/docs/cps-path.rst
+++ b/docs/cps-path.rst
@@ -1,6 +1,6 @@
.. This work is licensed under a Creative Commons Attribution 4.0 International License.
.. http://creativecommons.org/licenses/by/4.0
-.. Copyright (C) 2021-2023 Nordix Foundation
+.. Copyright (C) 2021-2025 Nordix Foundation
.. Modifications Copyright (C) 2023 TechMahindra Ltd
.. DO NOT CHANGE THIS LABEL FOR RELEASE NOTES - EVEN THOUGH IT GIVES A WARNING
@@ -183,7 +183,7 @@ General Notes
Query Syntax
============
-``( <absolute-path> | <descendant-path> ) [ <leaf-conditions> ] [ <text()-condition> ] [ <contains()-condition> ] [ <ancestor-axis> ]``
+``( <absolute-path> | <descendant-path> ) [ <leaf-conditions> ] [ <text()-condition> ] [ <contains()-condition> ] [ <ancestor-axis> ] [ <attribute-axis> ]``
Each CPS path expression need to start with an 'absolute' or 'descendant' xpath.
@@ -310,3 +310,21 @@ The ancestor axis can be added to any CPS path query but has to be the last part
**Limitations**
- Ancestor list elements can only be addressed using the list key leaf.
- List elements with compound keys are not supported.
+
+attribute-axis
+--------------
+
+The attribute axis can be added to a CPS path query at the end. It will return only distinct values of a specified leaf.
+
+**Syntax**: ``<cps-path> ( '/@' <leaf-name> )?``
+ - ``cps-path``: Any CPS path query.
+ - ``leaf-name``: The name of the leaf (attribute) for which values should be returned.
+
+**Examples**
+ - ``//categories/@name``
+ - ``//categories[@code='1']/books/@price``
+ - ``//books/ancestor::bookstore/@bookstore-name``
+
+**Notes**
+ - The output is a list of attribute-value pairs. For example, ``[{"name":"Kids"},{"name":"SciFi"}]``
+ - Only unique values will be returned. For example, if 3 books have a price of 5, then 5 will be returned only once.