diff --git a/biosimulators_utils/sedml/validation.py b/biosimulators_utils/sedml/validation.py index fdb4a5ce..11a0619b 100644 --- a/biosimulators_utils/sedml/validation.py +++ b/biosimulators_utils/sedml/validation.py @@ -1715,7 +1715,7 @@ def validate_target(target, namespaces, context, language, model_id, model_etree return errors, warnings -def validate_target_xpaths(targets, model_etree, attr='id'): +def validate_target_xpaths(targets, model_etree, attr='id', separator=None): """ Validate that the target of each model change or variable matches one object in an XML-encoded model and, optionally, return the value of one of its attributes @@ -1736,6 +1736,17 @@ def validate_target_xpaths(targets, model_etree, attr='id'): x_path, _, _ = x_path.rpartition('/@') x_path_attrs[target.target] = validate_xpaths_ref_to_unique_objects( model_etree, [x_path], target.target_namespaces, attr=attr)[x_path] + if separator is None: + return x_path_attrs + for xpath in x_path_attrs: + xpath_list = xpath.split("@" + attr + "=") + if len(xpath_list) < 3: + continue + combined_id = "" + for i in range(1, len(xpath_list)-1): + combined_id = combined_id + xpath_list[i].split(']')[0][1:-1] + separator + x_path_attrs[xpath] = combined_id + x_path_attrs[xpath] + return x_path_attrs