diff options
author | 2025-03-13 17:07:24 +0000 | |
---|---|---|
committer | 2025-03-13 17:07:24 +0000 | |
commit | 6a4daaebb10e30960a2a76b3fed62d49f5fa4ea2 (patch) | |
tree | 5984d5c72bfa2ee56948f7d634f14a59cbe71c34 | |
parent | 5157f49e4c9b2be38d0c287d4c5ee35a6222160e (diff) | |
parent | a6ba7e2981fdfc27d1603e89742cd5c4d2db0a05 (diff) |
Merge "Add documentation for attribute-axis"
-rw-r--r-- | docs/cps-path.rst | 22 |
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. |