  | Mailing List | | Home | | Forum Home | | JBoss - Java Application Server | | Tomcat - JSP/Servlet container | | Struts - A MVC web framework | | iText - An open source PDF Java Library | | JDOM - JDOM XML Parser | | JSP - A mailing list about Java Server Pages specification and reference | | J2EE - A mailing list for Java(tm) 2 Platform, Enterprise Edition | | J2EE Pattern - An interest list for Sun Java Center J2EE Pattern Catalog | | Servlet - A mailing list for discussion about Sun Microsystem's Java Servlet API Technology | |
Struts & Hibernate
|
|
|
  | | | XML Parser : Select first node from DOM corresponding to xpath | XML Parser : Select first node from DOM corresponding to xpath 2004-04-27 - By Subrata SEN
Back Hi All,
I am new to XML Parsing. I am using xerces ( DOM ) parser and using following function to get the nodelist:
public NodeList getXpathNodeList(String p_node_path) {
try {
return (org.apache.xpath.XPathAPI.selectNodeList(xmldoc, p_node_path));
} catch (TransformerException e) {
e.printStackTrace();
return null;
}
}
selectNodeList() is taking 90% of transactions time.
Packages
Method Name
Calls
Cumulative Time
Method Time
org.apache.xpath
XPathAPI.selectNodeList
1133
13954
13954
com.iflex.fcr.infra.xml
FCRJApacheXMLParser.getXpathNodeList
1129
13854
9
Question:
1. Is there any way (API available / workaround) we can stop searching the next node after it gets first occurrence?
2. Is it logical for 1133 call XPathAPI.selectNodeList is taking 13954 ms (DOM size is less than 6kb)?
Thanks & Regards
Subrata SEN
DISCLAIMER: This message contains privileged and confidential information and is intended only for the individual named.If you are not the intended recipient you should not disseminate,distribute,store,print, copy or deliver this message.Please notify the sender immediately by e-mail if you have received this e-mail by mistake and delete this e-mail from your system.E-mail transmission cannot be guaranteed to be secure or error-free as information could be intercepted ,corrupted,lost,destroyed,arrive late or incomplete or contain viruses.The sender therefore does not accept liability for any errors or omissions in the contents of this message which arise as a result of e-mail transmission. If verification is required please request a hard-copy version.
==================================================================== Companion Site: http://www.corej2eepatterns.com J2EE BluePrints: http://java.sun.com/blueprints/corej2eepatterns List Archive: http://archives.java.sun.com/archives/j2eepatterns-interest.html Unsubscribing: email "signoff J2EEPATTERNS-INTEREST" to listserv@(protected)
<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft -com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:x="urn :schemas-microsoft-com:office:excel" xmlns="http://www.w3.org/TR/REC-html40">
<head> <META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=us-ascii">
<meta name=Generator content="Microsoft Word 11 (filtered medium)"> <style> <!-- /* Font Definitions */ @(protected) {font-family:"Book Antiqua"; panose-1 (See http://ose-1.ora-code.com):2 4 6 2 5 3 5 3 3 4;} /* Style Definitions */ p.MsoNormal, li.MsoNormal, div.MsoNormal {margin:0in; margin-bottom:.0001pt; font-size:12.0pt; font-family:"Times New Roman";} a:link, span.MsoHyperlink {color:blue; text-decoration:underline;} a:visited, span.MsoHyperlinkFollowed {color:purple; text-decoration:underline;} p.MsoPlainText, li.MsoPlainText, div.MsoPlainText {margin:0in; margin-bottom:.0001pt; font-size:10.0pt; font-family:"Courier New";} @(protected) Section1 {size:8.5in 11.0in; margin:1.0in 77.95pt 1.0in 77.95pt;} div.Section1 {page:Section1;} --> </style>
</head>
<body lang=EN-US link=blue vlink=purple>
<div class=Section1>
<p class=MsoPlainText><font size=2 face="Courier New"><span style='font-size: 10.0pt'>Hi All, <o:p></o:p></span></font></p>
<p class=MsoPlainText><font size=2 color=black face="Courier New"><span style='font-size:10.0pt;color:black'>I am new to XML Parsing. I am using xerces ( DOM ) parser and using following function to get the nodelist: <o:p></o :p></span></font></p>
<p class=MsoPlainText><font size=2 color=black face="Courier New"><span style='font-size:10.0pt;color:black'><o:p> </o:p></span></font></p>
<p class=MsoPlainText><font size=2 color=black face="Courier New"><span style='font-size:10.0pt;color:black'>public NodeList getXpathNodeList(String p_node_path) {<o:p></o:p></span></font></p>
<p class=MsoPlainText><font size=2 color=black face="Courier New"><span style='font-size:10.0pt;color:black'> try {<o:p>< /o:p></span></font></p>
<p class=MsoPlainText><font size=2 color=black face="Courier New"><span style='font-size:10.0pt;color:black'>return (org.apache.xpath.XPathAPI .selectNodeList(xmldoc, p_node_path));<o:p></o:p></span></font></p>
<p class=MsoPlainText><font size=2 color=black face="Courier New"><span style='font-size:10.0pt;color:black'> } catch (TransformerException e) {<o:p></o:p></span></font></p>
<p class=MsoPlainText><font size=2 color=black face="Courier New"><span style='font-size:10.0pt;color:black'> e.printStackTrace();<o:p></o:p></span></font></p>
<p class=MsoPlainText><font size=2 color=black face="Courier New"><span style='font-size:10.0pt;color:black'> return null;<o:p></o:p></span></font></p>
<p class=MsoPlainText><font size=2 color=black face="Courier New"><span style='font-size:10.0pt;color:black'> }<o:p></o:p ></span></font></p>
<p class=MsoPlainText><font size=2 color=black face="Courier New"><span style='font-size:10.0pt;color:black'><o:p> </o:p></span></font></p>
<p class=MsoPlainText><font size=2 color=black face="Courier New"><span style='font-size:10.0pt;color:black'>}<o:p></o:p></span></font></p>
<p class=MsoPlainText><font size=2 color=black face="Courier New"><span style='font-size:10.0pt;color:black'><o:p> </o:p></span></font></p>
<p class=MsoPlainText><font size=2 color=black face="Courier New"><span style='font-size:10.0pt;color:black'>selectNodeList() is taking 90% of transactions time. <o:p></o:p></span></font></p>
<table class=MsoNormalTable border=0 cellspacing=0 cellpadding=0 width=881 style='width:660.7pt;margin-left:5.15pt;border-collapse:collapse'> <tr height=63 style='height:47.25pt'> <td width=199 nowrap height=63 valign=bottom bgcolor=silver style='width: 149.0pt;border:solid windowtext 1.0pt;background:silver;padding:0in 5.4pt 0in 5.4pt; height:47.25pt'> <p class=MsoNormal><font size=3 color=blue face="Book Antiqua"><span style='font-size:12.0pt;font-family:"Book Antiqua";color:blue'>Packages<o:p>< /o:p></span></font></p> </td> <td width=458 nowrap height=63 valign=bottom bgcolor=silver style='width: 343.2pt;border:solid windowtext 1.0pt;border-left:none;background:silver; padding:0in 5.4pt 0in 5.4pt;height:47.25pt'> <p class=MsoNormal><font size=3 color=blue face="Book Antiqua"><span style='font-size:12.0pt;font-family:"Book Antiqua";color:blue'>Method Name<o :p></o:p></span></font></p> </td> <td width=56 nowrap height=63 valign=bottom bgcolor=silver style='width:42 .0pt; border:solid windowtext 1.0pt;border-left:none;background:silver;padding: 0in 5.4pt 0in 5.4pt;height:47.25pt'> <p class=MsoNormal><font size=3 color=blue face="Book Antiqua"><span style='font-size:12.0pt;font-family:"Book Antiqua";color:blue'>Calls<o:p></o :p></span></font></p> </td> <td width=98 height=63 valign=bottom bgcolor=silver style='width:73.8pt; border:solid windowtext 1.0pt;border-left:none;background:silver;padding: 0in 5.4pt 0in 5.4pt;height:47.25pt'> <p class=MsoNormal><font size=3 color=blue face="Book Antiqua"><span style='font-size:12.0pt;font-family:"Book Antiqua";color:blue'>Cumulative Time<o:p></o:p></span></font></p> </td> <td width=70 height=63 valign=bottom bgcolor=silver style='width:52.7pt; border:solid windowtext 1.0pt;border-left:none;background:silver;padding: 0in 5.4pt 0in 5.4pt;height:47.25pt'> <p class=MsoNormal><font size=3 color=blue face="Book Antiqua"><span style='font-size:12.0pt;font-family:"Book Antiqua";color:blue'>Method Time<o :p></o:p></span></font></p> </td> </tr> <tr height=17 style='height:12.75pt'> <td width=199 nowrap height=17 valign=bottom style='width:149.0pt;border: solid windowtext 1.0pt;border-top:none;padding:0in 5.4pt 0in 5.4pt; height:12.75pt'> <p class=MsoNormal><b><font size=2 color=red face=Arial><span style='font-size:10.0pt;font-family:Arial;color:red;font-weight:bold'>org .apache.xpath<o:p></o:p></span></font></b></p> </td> <td width=458 nowrap height=17 valign=bottom style='width:343.2pt;border-top: none;border-left:none;border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt; padding:0in 5.4pt 0in 5.4pt;height:12.75pt'> <p class=MsoNormal><b><font size=2 color=red face=Arial><span style='font-size:10.0pt;font-family:Arial;color:red;font-weight:bold' >XPathAPI.selectNodeList<o:p></o:p></span></font></b></p> </td> <td width=56 nowrap height=17 valign=bottom style='width:42.0pt;border-top: none;border-left:none;border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt; padding:0in 5.4pt 0in 5.4pt;height:12.75pt' x:num> <p class=MsoNormal align=right style='text-align:right'><b><font size=2 color=red face=Arial><span style='font-size:10.0pt;font-family:Arial; color:red;font-weight:bold'>1133<o:p></o:p></span></font></b></p> </td> <td width=98 nowrap height=17 valign=bottom style='width:73.8pt;border-top: none;border-left:none;border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt; padding:0in 5.4pt 0in 5.4pt;height:12.75pt' x:num> <p class=MsoNormal align=right style='text-align:right'><b><font size=2 color=red face=Arial><span style='font-size:10.0pt;font-family:Arial; color:red;font-weight:bold'>13954<o:p></o:p></span></font></b></p> </td> <td width=70 nowrap height=17 valign=bottom style='width:52.7pt;border-top: none;border-left:none;border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt; padding:0in 5.4pt 0in 5.4pt;height:12.75pt' x:num> <p class=MsoNormal align=right style='text-align:right'><b><font size=2 color=red face=Arial><span style='font-size:10.0pt;font-family:Arial; color:red;font-weight:bold'>13954<o:p></o:p></span></font></b></p> </td> </tr> <tr height=17 style='height:12.75pt'> <td width=199 nowrap height=17 valign=bottom style='width:149.0pt;border: solid windowtext 1.0pt;border-top:none;padding:0in 5.4pt 0in 5.4pt; height:12.75pt'> <p class=MsoNormal><b><font size=2 color=red face=Arial><span style='font-size:10.0pt;font-family:Arial;color:red;font-weight:bold'>com .iflex.fcr.infra.xml<o:p></o:p></span></font></b></p> </td> <td width=458 nowrap height=17 valign=bottom style='width:343.2pt;border-top: none;border-left:none;border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt; padding:0in 5.4pt 0in 5.4pt;height:12.75pt'> <p class=MsoNormal><b><font size=2 color=red face=Arial><span style='font-size:10.0pt;font-family:Arial;color:red;font-weight:bold' >FCRJApacheXMLParser.getXpathNodeList<o:p></o:p></span></font></b></p> </td> <td width=56 nowrap height=17 valign=bottom style='width:42.0pt;border-top: none;border-left:none;border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt; padding:0in 5.4pt 0in 5.4pt;height:12.75pt' x:num> <p class=MsoNormal align=right style='text-align:right'><b><font size=2 color=red face=Arial><span style='font-size:10.0pt;font-family:Arial; color:red;font-weight:bold'>1129<o:p></o:p></span></font></b></p> </td> <td width=98 nowrap height=17 valign=bottom style='width:73.8pt;border-top: none;border-left:none;border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt; padding:0in 5.4pt 0in 5.4pt;height:12.75pt' x:num> <p class=MsoNormal align=right style='text-align:right'><b><font size=2 color=red face=Arial><span style='font-size:10.0pt;font-family:Arial; color:red;font-weight:bold'>13854<o:p></o:p></span></font></b></p> </td> <td width=70 nowrap height=17 valign=bottom style='width:52.7pt;border-top: none;border-left:none;border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt; padding:0in 5.4pt 0in 5.4pt;height:12.75pt' x:num> <p class=MsoNormal align=right style='text-align:right'><b><font size=2 color=red face=Arial><span style='font-size:10.0pt;font-family:Arial; color:red;font-weight:bold'>9<o:p></o:p></span></font></b></p> </td> </tr> </table>
<p class=MsoPlainText><font size=2 color=black face="Courier New"><span style='font-size:10.0pt;color:black'><o:p> </o:p></span></font></p>
<p class=MsoPlainText><font size=2 color=black face="Courier New"><span style='font-size:10.0pt;color:black'><o:p> </o:p></span></font></p>
<p class=MsoPlainText><font size=2 color=black face="Courier New"><span style='font-size:10.0pt;color:black'>Question: <o:p></o:p></span></font></p>
<p class=MsoPlainText><font size=2 color=black face="Courier New"><span style='font-size:10.0pt;color:black'><o:p> </o:p></span></font></p>
<p class=MsoPlainText><font size=2 color=blue face="Book Antiqua"><span style='font-size:10.0pt;font-family:"Book Antiqua";color:blue'>1. Is there any way (API available / workaround) we can stop searching the next node after it gets first occurrence?<o:p></o:p></span></font></p>
<p class=MsoPlainText><font size=2 color=blue face="Book Antiqua"><span style='font-size:10.0pt;font-family:"Book Antiqua";color:blue'><o:p> </o:p ></span></font></p>
<p class=MsoPlainText><font size=2 color=blue face="Book Antiqua"><span style='font-size:10.0pt;font-family:"Book Antiqua";color:blue'>2. Is it logical for 1133 call </span></font><font color=blue face="Book Antiqua"><span style='font-family:"Book Antiqua";color:blue'>XPathAPI.selectNodeList is taking 13954 ms (DOM size is less than 6kb)?</span></font><font color=blue face="Book Antiqua"><span style='font-family:"Book Antiqua";color:blue'><o:p>< /o:p></span></font></p>
<p class=MsoPlainText><font size=2 color=black face="Courier New"><span style='font-size:10.0pt;color:black'><o:p> </o:p></span></font></p>
<p class=MsoPlainText><font size=2 color=black face="Courier New"><span style='font-size:10.0pt;color:black'>Thanks & Regards<o:p></o:p></span>< /font></p>
<p class=MsoPlainText><font size=2 color=black face="Courier New"><span style='font-size:10.0pt;color:black'><o:p> </o:p></span></font></p>
<p class=MsoPlainText><font size=2 color=black face="Courier New"><span style='font-size:10.0pt;color:black'>Subrata SEN <o:p></o:p></span></font></p>
<p class=MsoPlainText><font size=2 color=black face="Courier New"><span style='font-size:10.0pt;color:black'><o:p> </o:p></span></font></p>
</div>
<p></p><p>DISCLAIMER:<br>This message contains privileged and confidential information and is intended only for the individual named.If you are not the intended recipient you should not disseminate,distribute,store,print, copy or deliver this message.Please notify the sender immediately by e-mail if you have received this e-mail by mistake and delete this e-mail from your system.E-mail transmission cannot be guaranteed to be secure or error-free as information could be intercepted,corrupted,lost,destroyed,arrive late or incomplete or contain viruses.The sender therefore does not accept liability for any errors or omissions in the contents of this message which arise as a result of e-mail transmission. If verification is required please request a hard-copy version. < /body>
</html> ==================================================================== Companion Site: http://www.corej2eepatterns.com J2EE BluePrints: http://java.sun.com/blueprints/corej2eepatterns List Archive: http://archives.java.sun.com/archives/j2eepatterns-interest.html Unsubscribing: email "signoff J2EEPATTERNS-INTEREST" to listserv@(protected)
|
|
 |