Skip to content

Commit

Permalink
Get 'not a valid XPath' error the old way.
Browse files Browse the repository at this point in the history
  • Loading branch information
luciansmith committed Feb 16, 2024
1 parent f3ab3a8 commit 4da8a72
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion biosimulators_utils/sedml/validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -1663,9 +1663,10 @@ def validate_target(target, namespaces, context, language, model_id, model_etree
namespaces.pop(None, None)

try:
xpath = lxml.etree.XPath(target, namespaces=namespaces)
root = lxml.etree.Element("root")
try:
xpath = root.xpath(target, namespaces=namespaces)
root.xpath(target, namespaces=namespaces)

if model_etree and check_in_model_source:
if context == DataGenerator and '/@' in target:
Expand Down Expand Up @@ -1707,6 +1708,8 @@ def validate_target(target, namespaces, context, language, model_id, model_etree
ns_message = 'No namespaces are defined for the target.'

errors.append(['One or more namespaces required for target `{}` are not defined. {}'.format(target, ns_message)])
else:
errors.append(['Target `{}` is not a valid XML XPath.'.format(target)])

Check warning on line 1712 in biosimulators_utils/sedml/validation.py

View check run for this annotation

Codecov / codecov/patch

biosimulators_utils/sedml/validation.py#L1712

Added line #L1712 was not covered by tests

except lxml.etree.XPathSyntaxError:
errors.append(['Target `{}` is not a valid XML XPath.'.format(target)])
Expand Down

0 comments on commit 4da8a72

Please sign in to comment.