Skip to content

Commit

Permalink
warn empty prefix for namespace (#128)
Browse files Browse the repository at this point in the history
  • Loading branch information
bicycle1885 authored Nov 26, 2019
1 parent ed92c4c commit 839f254
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
4 changes: 3 additions & 1 deletion src/xpath.jl
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,9 @@ function Base.findall(xpath::AbstractString, node::Node, ns=namespaces(node))
throw_xml_error()
end
for (prefix, uri) in ns
if !isempty(prefix)
if isempty(prefix)
@warn "ignored the empty prefix for '$(uri)'; expected to be non-empty"
else
ret = register_namespace!(context_ptr, prefix, uri)
@assert ret == 0
end
Expand Down
5 changes: 3 additions & 2 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1287,8 +1287,9 @@ end
<term><accession>GO:0000001</accession></term>
</go>
""")
@test isempty(findall("term", root(doc)))
@test isempty(findall("./term", root(doc)))
warnmsg = "ignored the empty prefix for 'http://www.geneontology.org/dtds/go.dtd#'; expected to be non-empty"
@test isempty(@test_logs (:warn, warnmsg) findall("term", root(doc)))
@test isempty(@test_logs (:warn, warnmsg) findall("./term", root(doc)))
@test findall("go:term", root(doc), ["go" => "http://www.geneontology.org/dtds/go.dtd#"]) == elements(root(doc))
@test findall("./go:term", root(doc), ["go" => "http://www.geneontology.org/dtds/go.dtd#"]) == elements(root(doc))

Expand Down

0 comments on commit 839f254

Please sign in to comment.