Closed JonasDoe closed 1 year ago
Use CompileWithNS()
to specified NamespaceURL.
expr, _ := xpath.CompileWithNS("rdf:RDF/owl:Axiom/owl:annotatedSource[@rdf:resource='http://www.my-company.io/ontologies#MyEntity']/parent::owl:Axiom", map[string]string{
"rdf": "http://www.w3.org/1999/02/22-rdf-syntax-ns#",
"owl": "http://www.w3.org/2002/07/owl#",
})
axioms = xmlquery.QuerySelectorAll(source, expr)
Considing rollback v1.3.14 version for default NamespaceURL, may be will not.
The above method still can work with by NamespaceURL(xpath v1.2.4).
In the latest commit, changedaxioms, err := xmlquery.QueryAll(source, "rdf:RDF/owl:Axiom/owl:annotatedSource[@rdf:resource='http://www.my-company.io/ontologies#MyEntity']/parent::owl:Axiom")
to
axioms, err := xmlquery.QueryAll(source, "rdf:RDF/Axiom/annotatedSource[@rdf:resource='http://www.my-company.io/ontologies#MyEntity']/parent::Axiom")
if your XML file include prefix like this
<owl:Axiom>
<owl:annotatedSource rdf:resource="http://www.my-company.io/ontologies#MyEntity"/>
</owl:Axiom>
yes ,you can use rdf:RDF/owl:Axiom/owl:annotatedSource[@rdf:resource='http://www.my-company.io/ontologies#MyEntity']/parent::owl:Axiom
The function prints a different result length (
1
) vs (0
), depending on the version ofxmlquery
I apologize for the messy look - I tried to strip most unnecessary from a rather huge rdf file but keep some essential information to give an idea about the xml type.
I've also noticed there's another issue about a breaking change, but your recommended commit 0f42df8 doesn't fix the behavior I've observed here.