From: danielhanrahan Date: Thu, 13 Mar 2025 14:40:57 +0000 (+0000) Subject: Add documentation for attribute-axis X-Git-Tag: 3.6.2~41^2 X-Git-Url: https://gerrit.onap.org/r/gitweb?a=commitdiff_plain;h=refs%2Fchanges%2F77%2F140477%2F2;p=cps.git Add documentation for attribute-axis Issue-ID: CPS-2624 Signed-off-by: danielhanrahan Change-Id: Iafa145d1fefbd26adc8786e4001d90883acf1463 --- 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 ============ -``( | ) [ ] [ ] [ ] [ ]`` +``( | ) [ ] [ ] [ ] [ ] [ ]`` 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``: 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.