From 1ae646419f0c6289fbca9ed6ac6ca2a688b9ed69 Mon Sep 17 00:00:00 2001 From: marthasharkey Date: Tue, 8 Oct 2024 16:23:41 +0100 Subject: [PATCH] add method for xml doc drilldown (#11258) --- .../Standard/Base/0.0.0-dev/src/Data/XML.enso | 17 +++++++++++++++++ .../0.0.0-dev/src/Table/Visualization.enso | 2 +- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/distribution/lib/Standard/Base/0.0.0-dev/src/Data/XML.enso b/distribution/lib/Standard/Base/0.0.0-dev/src/Data/XML.enso index e362df57b6ba..7ecd31dea265 100644 --- a/distribution/lib/Standard/Base/0.0.0-dev/src/Data/XML.enso +++ b/distribution/lib/Standard/Base/0.0.0-dev/src/Data/XML.enso @@ -156,6 +156,23 @@ type XML_Document _ : Integer -> if key == 0 then self.root_element else if_missing _ : Text -> if key == self.root_element.name then self.root_element else if_missing + ## GROUP Selections + ICON parse3 + Gets the child element of the inner XML Element + + Arguments: + - key: If an `Integer`, returns the element at position `at` in its list + of children. If `Text`, then if starts with `"@"`, returns the + attribute with the given name otherwise returns the first child element + with the given name. + + @key child_selector + get_child_element : Text | Integer -> Any | Text | XML_Element | Vector (Text | XML_Element) ! No_Such_Key | Index_Out_Of_Bounds | XML_Error + get_child_element self key:(Text | Integer)="." = + root = self.get 0 + root.get key + + ## GROUP Selections ICON parse3 Gets a child or attribute of an XML document. diff --git a/distribution/lib/Standard/Visualization/0.0.0-dev/src/Table/Visualization.enso b/distribution/lib/Standard/Visualization/0.0.0-dev/src/Table/Visualization.enso index 79c07065c7ac..2be4510ad018 100644 --- a/distribution/lib/Standard/Visualization/0.0.0-dev/src/Table/Visualization.enso +++ b/distribution/lib/Standard/Visualization/0.0.0-dev/src/Table/Visualization.enso @@ -161,7 +161,7 @@ make_json_for_xml_element xml_element max_items type:Text="XML_Element" = map_vector = Warning.clear (attribs + children) data = ["data", [map_vector.map .first, map_vector.map .second, map_vector.map i-> i.at 2]] - get_child_node_fields = if type == "XML_Element" then [["get_child_node_action", "get"], ["get_child_node_link_name", "key"], ["link_value_type", "number"]] else [] + get_child_node_fields = if type == "XML_Element" then [["get_child_node_action", "get"], ["get_child_node_link_name", "key"], ["link_value_type", "number"]] else [["get_child_node_action", "get_child_element"], ["get_child_node_link_name", "key"], ["link_value_type", "number"]] JS_Object.from_pairs <| [header, data, all_rows, ["type", type]] + get_child_node_fields ## PRIVATE