From ebefdf4a838b863f2fe88564bd4f838ba40ae5f1 Mon Sep 17 00:00:00 2001 From: Cyber MacGeddon Date: Fri, 5 Sep 2025 14:47:55 +0100 Subject: [PATCH] Structured data loader CLI --- .../trustgraph/cli/load_structured_data.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/trustgraph-cli/trustgraph/cli/load_structured_data.py b/trustgraph-cli/trustgraph/cli/load_structured_data.py index d6e22ddf..969f7801 100644 --- a/trustgraph-cli/trustgraph/cli/load_structured_data.py +++ b/trustgraph-cli/trustgraph/cli/load_structured_data.py @@ -342,8 +342,17 @@ def load_structured_data( root = ET.fromstring(raw_data) # Find record elements using XPath - records = root.findall(record_path) - logger.info(f"Found {len(records)} records using XPath: {record_path}") + # ElementTree XPath support is limited, convert absolute paths to relative + xpath_expr = record_path + if xpath_expr.startswith('/ROOT/'): + # Remove /ROOT/ prefix since we're already at the root + xpath_expr = xpath_expr[6:] + elif xpath_expr.startswith('/'): + # Convert absolute path to relative by removing leading / + xpath_expr = '.' + xpath_expr + + records = root.findall(xpath_expr) + logger.info(f"Found {len(records)} records using XPath: {record_path} (converted to: {xpath_expr})") # Convert XML elements to dictionaries record_count = 0