Hi, We use Xpath API's to access text and attribute values based on xpath expressions. It used to run very quickly (0-10 msec for each eval) in Xalan 2.0.1. But in 2.2 it takes much longer (150-200 msec for each eval). The timing gets progressively worse as the depth of the tree increases. Here is the sample XML result coming from a database query which is being parsed. There are about 200 message nodes. I have included only a couple of message nodes here for brevity. Should we be using lower level Xpath api's ? Thanks Nathan <?xml version="1.0" encoding="UTF-8"?> <result xmlns:ino="http://namespaces.softwareag.com/tamino/response2"> <messagecatalog docType="messagecatalog" ino:id="1" lang="en" objectId="1"> <message code="000001"> <type>error</type> <text>Agreement ID Node Does Not Exist.</text> <category>system</category> <severity>30</severity> </message> <message code="000002"> <type>error</type> <text>No Agreement ID entered. Please enter Agreement ID.</text> <category>system</category> <severity>30</severity> </message> </messagacatalog> </result> Here is the code that parses each message node passed to it as the context node. /** * Gets the value from a node using XPath expression. * @param contextNode <code>Node</code> to be searched for the value * @param xpath query path to the node that has the value * @return value of the node pointed to by the xpath expression. */ public static String getValue(Node contextNode, String xpath) { if (contextNode == null) { return null; } String value = null; try { long begin = System.currentTimeMillis(); Node node = XPathAPI.selectSingleNode(contextNode,xpath); System.out.println("time=" + (System.currentTimeMillis()-begin)); if (node != null) { switch (node.getNodeType()) { case Node.TEXT_NODE : value = node.getNodeValue(); break; case Node.ATTRIBUTE_NODE : value = ((Attr)node).getValue(); break; case Node.ELEMENT_NODE : NodeList childNodes = node.getChildNodes(); for (int i = 0; i < childNodes.getLength(); i++) { Node child = childNodes.item(i); if (child != null && child.getNodeType() == Node.TEXT_NODE) { value = child.getNodeValue(); break; } } break; } } } catch(TransformerException te) { } if (value != null) { value = value.trim(); if (value.length() == 0) { value = null; } } return value; }
