You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ws.apache.org by Amila Suriarachchi <am...@gmail.com> on 2012/09/05 08:25:54 UTC
Axiom Reads the whole input stream when applying the xpaths
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/
Re: Axiom Reads the whole input stream when applying the xpaths
Posted by Andreas Veithen <an...@gmail.com>.
On Wed, Sep 5, 2012 at 8:25 AM, Amila Suriarachchi
<am...@gmail.com> wrote:
> 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?
No. Since we use Jaxen as XPath implementation and Jaxen has not been
designed for this, it won't be possible.
> thanks,
> Amila.
>
>
> --
> Amila Suriarachchi
> WSO2 Inc.
> blog: http://amilachinthaka.blogspot.com/
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@ws.apache.org
> For additional commands, e-mail: dev-help@ws.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@ws.apache.org
For additional commands, e-mail: dev-help@ws.apache.org