From: Matthew F. <ma...@ag...> - 2003-04-10 23:17:03
|
I am currently using eXist9.1 and am pretty new to the program. I have embedded it into a java application that I am writing and am trying to use XPathAPI to get the values of the element. What I want is the value only. The problem is that XPathAPI.eval(node, string) seems to hang. It does not throw an exception, yet it will not move on from this call. When I print out the node, everything seems to be ok. I am on a severe time crunch, so any immediate ideas will be extremly helpful. If anyone has ANY ideas, please post them immediatly. Thanks for your help.... -- Matt Example: <canal> <canal_name>Canal1</canal_name> <canal_resource>canal_1</canal_resource> </canal> The Code: //<imports> import java.util.Vector; import java.util.Hashtable; import org.xmldb.api.base.*; import org.xmldb.api.modules.*; import org.w3c.dom.*; import org.apache.xpath.*; import org.apache.xpath.objects.*; //<method> public void addResults(ResourceIterator results) { System.out.println("ADDING RESULTS"); try { System.out.println("TRYING"); while (results.hasMoreResources()) { System.out.println("WHILE..."); // Create a new canal instance to add to Group Canal c = new Canal(); // Retrieve the next node XMLResource resource = (XMLResource) results.nextResource(); // Cast to Dom Node Node originalnode = resource.getContentAsDOM(); System.out.println(originalnode.toString()); // Get the document key for this node for later use String dockey = resource.getDocumentId(); c.setDocKey(dockey); // Use Xalan xpath parser to extract data, store into hastable XObject xo = new XObject(); XPathAPI xp = new XPathAPI(); xo = xp.eval(originalnode, "/canal/canal_name"); System.out.println(xo.toString()); c.setName(xo.toString()); xo = XPathAPI.eval(originalnode, "/canal/canal_resource"); c.setResource(xo.toString()); // Add person to group this.add(c); } } catch (Exception e) { e.printStackTrace(); } System.out.println("OUT OF WHILE"); } |