I have an exception with the following code
public calculWeightdoc(OWLOntology onto, String xml) {
for(OWLClass cls: onto.getClassesInSignature()){
freqConcept(xml, cls);
System.out.println("la taille de liste : "+list.getLength());
if(list.getLength()!=0){
listConceptRetenus.put(cls, list.getLength());
}
else
{
listConceptRetenus.put(cls, 0);
}
}
}
This is the function FreqConcept
public void freqConcept(String xmldoc,OWLClass node){
try {
String filepath = xmldoc;
DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance();
DocumentBuilder docBuilder = docFactory.newDocumentBuilder();
Document doc = docBuilder.parse(filepath);
list = doc.getElementsByTagName(node.getIRI().getFragment());
} catch (ParserConfigurationException pce) {
pce.printStackTrace();
} catch (IOException ioe) {
ioe.printStackTrace();
} catch (SAXException sae) {
sae.printStackTrace();
}
}
And this is the exception:
Exception in thread "main" java.lang.NullPointerException
at com.sun.org.apache.xerces.internal.dom.DeepNodeListImpl.nextMatchingElementAfter(DeepNodeListImpl.java:199)
at com.sun.org.apache.xerces.internal.dom.DeepNodeListImpl.item(DeepNodeListImpl.java:146)
at com.sun.org.apache.xerces.internal.dom.DeepNodeListImpl.getLength(DeepNodeListImpl.java:117)
at com.onto.weight.document.calculWeightdoc.<init>(calculWeightdoc.java:59)
at com.onto.weight.document.Main_Class_une_seule_onto.main(Main_Class_une_seule_onto.java:70)
Actually, the same code works perfectly for some ontologies like people with 60 classes, but for the others with an important number of classes like Dbpedia with 1173 classes it doesn't work, I'm not sure if that is the problem or something else...
The exception is about that line list.getLength()
in that function calculWeightdoc(OWLOntology onto, String xml)
.
Thank you for sharing any idea that may hepl me ti fix the problem.