Search...
FAQs
Subscribe
Pie
FAQs
Recent topics
Flagged topics
Hot topics
Best topics
Search...
Search within XML
Search Coderanch
Advance search
Google search
Register / Login
Win a copy of
OCP Oracle Certified Professional Java SE 21 Developer Study Guide: Exam 1Z0-830
this week in the
Programmer Certification
forum!
Post Reply
Bookmark Topic
Watch Topic
New Topic
programming forums
Java
Mobile
Certification
Databases
Caching
Books
Engineering
Micro Controllers
OS
Languages
Paradigms
IDEs
Build Tools
Frameworks
Application Servers
Open Source
This Site
Careers
Other
Pie Elite
all forums
this forum made possible by our volunteer staff, including ...
Marshals:
Campbell Ritchie
Tim Cooke
Liutauras Vilda
Jeanne Boyarsky
paul wheaton
Sheriffs:
Ron McLeod
Devaka Cooray
Henry Wong
Saloon Keepers:
Tim Holloway
Stephan van Hulst
Carey Brown
Tim Moores
Mikalai Zaikin
Bartenders:
Frits Walraven
Forum:
XML and Related Technologies
Parsing Error
yekkala krishna
Ranch Hand
Posts: 105
posted 13 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Hi,
I am not able to parse xml using xpath i am getting following exception.could you please what i need to do to solve this exception.
//exception: javax.xml.transform.TransformerException: Empty expression! at com.sun.org.apache.xpath.internal.compiler.XPathParser.error(Unknown Source) at com.sun.org.apache.xpath.internal.compiler.Lexer.tokenize(Unknown Source)
XPathFactory xpf = XPathFactory.newInstance(); XPath xPath = xpf.newXPath(); String xpPersp = "//perspective[@id='" + id + "']"; // Construct base xpath expression String dispName = xPath.evaluate(xpPersp + "/perspective", defs); String xpcontractName=xPath.evaluate(xpPersp+"/contractname",defs); System.out.println("xpPersp:::"+xpPersp); System.out.println("dispName:::"+dispName); System.out.println("xpcontractName:::"+xpcontractName); contractList = new ArrayList<PerspectiveMap>(); NodeList xmlcontractNameList = (NodeList) xPath.evaluate(xpcontractName, defs,XPathConstants.NODESET); for(int j=0;j<xmlcontractNameList.getLength();j++) { PerspectiveMap perspectivemap=new PerspectiveMap(); perspectivemap.setId(id); Node xmlcontractName=xmlcontractNameList.item(j); String contractName=xPath.evaluate("/contractname/name", xmlcontractName); System.out.println("contract name is ::"+contractName); perspectivemap.setContractName(contractName); String gsamName=xPath.evaluate("/contractname/gsam", xmlcontractName); System.out.println("gsam name is ::"+gsamName); perspectivemap.setGsamName(gsamName); String fileName=xPath.evaluate("/contractname/fileprefix", xmlcontractName); System.out.println("file prefix name is ::"+fileName); perspectivemap.setFileName(fileName); contractList.add(perspectivemap); System.err.println("PerspectiveMapDaoXmlImpl Found Perspective Id: "+ id+ " name: " + dispName); // XXX: remove after debuggin }
//XML FILE ><perspective id="opts029"> <name>Contract1</name> <contractname> <name>AAN</name> <ic-server>SAM-GSAM1</ic-server> <fileprefix>AAN</fileprefix> </contractname> <contractname> <name>PGL</name> <ic-server>SAM-GSAM1</ic-server> <fileprefix>PGL</fileprefix> </contractname> <contractname> <name>GSK</name> <ic-server>SAM-GSAM1</ic-server> <fileprefix>GSK</fileprefix> </contractname> </perspective>
Regards,
Rama
Jimmy Clark
Ranch Hand
Posts: 2187
posted 13 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
String gsamName=xPath.evaluate("/contractname/gsam", xmlcontractName);
Where is the gsam element in the Perspective document?
yekkala krishna
Ranch Hand
Posts: 105
posted 13 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Hi Clark,
Thanks for your suggestion.
Now my problem solves.
Regards,
Rama
My honeysuckle is blooming this year! Now to fertilize this tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
reply
Bookmark Topic
Watch Topic
New Topic
Boost this thread!
Similar Threads
Regarding xml Data
Regarding reading a file in a jsp
Showing Exception Message in client side
Problem in XPath
Loading a file content in dropdown list
More...