I am trying to extract information from a XML file and able to extract values without its properties.
Code:
public class NRusEntity { private String code; private String name; private String saltForm; getters and setters ... Parser Class:
... String filePath = FileUtility.getOwlFilePath(); try { Digester digester = new Digester(); digester.setValidating(false); //digester.setNamespaceAware(true); digester.addObjectCreate("rdf:RDF", NRus.class); digester.addObjectCreate("rdf:RDF/owl:Class", NRusEntity.class); digester.addCallMethod("rdf:RDF/owl:Class/Preferred_Name", "setName", 0); digester.addCallMethod("rdf:RDF/owl:Class/code", "setCode", 0); /**This commented part creates exception*/ //digester.addCallMethod("rdf:RDF/owl:Class/Has_Salt_Form", "setSaltForm", 2); //digester.addCallParam("rdf:RDF/owl:Class/Has_Salt_Form", 0); //digester.addCallParam("rdf:RDF/owl:Class/Has_Salt_Form", 1, "rdf:resource"); digester.addSetNext("rdf:RDF/owl:Class", "addEntry"); File input = new File(filePath); digester.parse(input); } ... XML Looks like this:
<?xml version="1.0"?> <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:owl="http://www.w3.org/2002/07/owl#"> <owl:Class rdf:about="#z"> <Preferred_Name rdf:datatype="http://www.w3.org/2001/XMLSchema#string">von</Preferred_Name> <code rdf:datatype="http://www.w3.org/2001/XMLSchema#string">XY221</code> <Has_Format rdf:resource="http://zlib.com#Ni_Hydro"/> </owl:Class> ... </rdf:RDF> How can I extract the URI value
"http://zlib.com#Ni_Hydro" from that XML line
<Has_Format rdf:resource="http://zlib.com#Ni_Hydro"/>
No comments:
Post a Comment