ws-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Amila Suriarachchi <amilasuriarach...@gmail.com>
Subject Axiom Reads the whole input stream when applying the xpaths
Date Wed, 05 Sep 2012 06:25:54 GMT
hi all,

I tested the $subject with the following code. Although we try to execute
an xpath for a small part it reads all the input stream.

System.out.println("Running Axiom perf test...");

        FileInputStreamWrapper fileInputStream = new
FileInputStreamWrapper("request_100.xml");

        System.out.println("Number of bytes read ==> " +
fileInputStream.getNumberOfBytesRead());

        XMLStreamReader xmlStreamReader =
StAXUtils.createXMLStreamReader(fileInputStream);

        System.out.println("Number of bytes read ==> " +
fileInputStream.getNumberOfBytesRead());

        StAXOMBuilder stAXOMBuilder = new StAXOMBuilder(xmlStreamReader);

        OMElement omElement = stAXOMBuilder.getDocumentElement();

        AXIOMXPath axiomxPath = new
AXIOMXPath("//ns1:echo/ns1:param0[1]/ns1:param1");
        axiomxPath.addNamespace("ns1","http://service.perf.test.com");

        OMElement resultOMElement = (OMElement)
axiomxPath.selectSingleNode(omElement);

        System.out.println("Result OMElement ==> " +
resultOMElement.toString());

        System.out.println("Number of bytes read ==> " +
fileInputStream.getNumberOfBytesRead());

And got the following.

Number of bytes read ==> 0
Number of bytes read ==> 32
Result OMElement ==> <ns1:param1 xmlns:ns1="http://service.perf.test.com
">5</ns1:param1>
Number of bytes read ==> 102511

Is it possible to stop this and have the differed building with the xpath
as well?

thanks,
Amila.


-- 
Amila Suriarachchi
WSO2 Inc.
blog: http://amilachinthaka.blogspot.com/

Mime
View raw message