You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
ifshow_namespace_prefixes_from_queryandtag[0] isnotNone: # if the element belongs to a namespace
157
-
unique_prefix=next((prefixforprefixinnamespaces.keys() ifnamespaces[prefix] == (tag[0], node.prefix)), None) # find the first prefix in the map that relates to this uri
157
+
unique_prefix=next((prefixforprefixinnamespaces.keys() ifnamespaces[prefix] == (tag[0], node.prefixor'')), None) # find the first prefix in the map that relates to this uri
158
158
ifunique_prefixisnotNone:
159
159
tag= (tag[0], tag[1], unique_prefix+':'+tag[1]) # ensure that the path we display can be used to query the element
results=list((resultforresultinget_results_for_xpath_query_multiple_trees(query, self.contexts[1], self.contexts[2])))# if not isinstance(result, etree.CommentBase)))
861
-
exceptetree.XPathErrorase:
861
+
except(ValueError, etree.XPathError)ase:
862
862
last_char=query.rstrip()[-1]
863
863
ifnotlast_charin ('/', ':', '@', '[', '(', ','): # log exception to console only if might be useful
864
864
print('XPath: exception evaluating results for "'+query+'": '+repr(e))
# TODO: if result is not a node, break out as we can't offer any useful suggestions (currently we just get an exception: Non-Element values not supported at this point - got 'example string') when it tries $expression_contexts/*
1078
-
exceptetree.XPathErrorase: # xpath query invalid, just show static contexts
1079
+
except(ValueError, etree.XPathError)ase: # xpath query invalid, just show static contexts
1079
1080
completion_contexts=None
1080
1081
print('XPath: exception obtaining completions for subquery "'+query+'": '+repr(e))
ifnsisnotNone: # ensure we get the prefix that we have mapped to the namespace for the query
1089
1090
root=result.getroottree().getroot()
1090
-
ns_prefix=next((nsprefixfornsprefixinnamespaces[root].keys() ifnamespaces[root][nsprefix] == (ns, result.prefix))) # find the first prefix in the map that relates to this uri
1091
-
fullname=ns_prefix+':'+localname
1091
+
ns_prefix=next((nsprefixfornsprefixinnamespaces[root].keys() ifnamespaces[root][nsprefix] == (ns, result.prefixor'')), None) # find the first prefix in the map that relates to this uri
1092
+
ifns_prefix:
1093
+
fullname=ns_prefix+':'+localname
1094
+
else:
1095
+
print('XPath warning: unable to find', ns, result.prefix, ' in root namespaces', namespaces[root], 'while generating completions')
1092
1096
ifnotlast_location_step.endswith(':') orlast_location_step.endswith('::') orlast_location_step.endswith(ns_prefix+':'): # ensure `prefix :` works correctly and also `different_prefix_to_suggestion:` (note that we don't do this for attributes - attributes are not allowed spaces before the colon, and if the prefix differs when there is no space, Sublime will replace it with the completion anyway)
0 commit comments