public static String getTextOf(String xsl) throws Exception {
DocXHandler docxh1 = new DocXHandler(ACE.getInputFilePath());
InputStream inputDocumentXMLStream = docxh1.getInputDocumentXMLZERO();
return new Cache().getXSLOutput(inputDocumentXMLStream, xsl);
}
The above method will be called more than 100 times with different xsl arguments. Now each time InputStream inputDocumentXMLStream has been assigned value( yeah more than 100 times). As i am trying to refactor this code, in such a way that only one time InputStream will be assigned value.My code became like this now,
public static String getTextOf(String xsl) throws Exception {
return new Cache().getXSLOutput(inputDocumentXMLStream, xsl);
}
by changing inputDocumentXMLStream as global property. First time i am getting the correct result BUT for the second time i get the below error,
Unexpected end of ZLIB input stream
so tel me how to read it again?
You can’t restart reading the input stream after reach to the end of the steam as it moves in single direction only.
I think the best idea to solve your problem is to fully parse your XML file once and place the values in the some java objects. Once done, you can simply use the map to to retrieve the required values. This will be much efficient too.
e.g.
Assuming
xslis a path expression, you may want to apply the path on Java collection created in above step. You may use libraries such asJXPathas :Hope this helps.