XPATH evaluate method closing the input stream - Unable to reuse
843834May 11 2008 — edited Apr 30 2010XPath xpath = XPathFactory.newInstance().newXPath();
String expressionYear = "/birthdate/year";
InputSource inputSource = new InputSource("myXMLDocument.xml");
NodeSet nodes = (NodeSet) xpath.evaluate(expressionYear, inputSource,
XpathConstants.NODESET);
String expressionMonth = "/birthdate/month";
NodeSet nodes = (NodeSet) xpath.evaluate(expressionMonth, inputSource, //Exception stream closed
XpathConstants.NODESET);
Where If we use Document object, it lets u re-use - Is this a bug or feature?
Document doc = ...
NodeSet nodes = (NodeSet) xpath.evaluate(expressionYear, doc,
XpathConstants.NODESET);
String expressionMonth = "/birthdate/month";
NodeSet nodes = (NodeSet) xpath.evaluate(expressionMonth, doc, //Exception stream closed
XpathConstants.NODESET);
Why is inconsistency ? I feel Programmer should be able to close "inputsource" when it is appropriate , evaluate method should not close.