private void doXPathRes ( final String resource , final Long revision , final OutputStream output , final boolean nodeid , final String xpath ) throws TTException { // Storage connection to treetank ISession session = null ; INodeReadTrx rtx = null ; try { if ( mDatabase . existsResource ( resource ) ) { session = mDatabase . getSession ( new SessionConfiguration ( resource , StandardSettings . KEY ) ) ; // Creating a transaction if ( revision == null ) { rtx = new NodeReadTrx ( session . beginBucketRtx ( session . getMostRecentVersion ( ) ) ) ; } else { rtx = new NodeReadTrx ( session . beginBucketRtx ( revision ) ) ; } final AbsAxis axis = new XPathAxis ( rtx , xpath ) ; for ( final long key : axis ) { WorkerHelper . serializeXML ( session , output , false , nodeid , key , revision ) . call ( ) ; } } } catch ( final Exception globExcep ) { throw new WebApplicationException ( globExcep , Response . Status . INTERNAL_SERVER_ERROR ) ; } finally { WorkerHelper . closeRTX ( rtx , session ) ; } }
This method performs an XPath evaluation and writes it to a given output stream .