AbstractXQueryExpressionEngine.java

  1. /*
  2.  * GovWay - A customizable API Gateway
  3.  * https://govway.org
  4.  *
  5.  * Copyright (c) 2005-2025 Link.it srl (https://link.it).
  6.  *
  7.  * This program is free software: you can redistribute it and/or modify
  8.  * it under the terms of the GNU General Public License version 3, as published by
  9.  * the Free Software Foundation.
  10.  *
  11.  * This program is distributed in the hope that it will be useful,
  12.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  14.  * GNU General Public License for more details.
  15.  *
  16.  * You should have received a copy of the GNU General Public License
  17.  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  18.  *
  19.  */


  20. package org.openspcoop2.utils.xml;

  21. import java.io.ByteArrayOutputStream;
  22. import java.io.File;
  23. import java.io.FileInputStream;
  24. import java.io.InputStream;
  25. import java.io.OutputStream;
  26. import java.io.Reader;
  27. import java.io.Writer;

  28. import javax.xml.transform.Source;
  29. import javax.xml.transform.dom.DOMSource;
  30. import javax.xml.transform.sax.SAXSource;
  31. import javax.xml.transform.stream.StreamSource;

  32. import org.apache.commons.io.output.CountingOutputStream;
  33. import org.openspcoop2.utils.LoggerWrapperFactory;
  34. import org.slf4j.Logger;
  35. import org.w3c.dom.Document;
  36. import org.w3c.dom.Element;
  37. import org.w3c.dom.Node;
  38. import org.xml.sax.InputSource;

  39. import net.sf.saxon.Configuration;
  40. import net.sf.saxon.s9api.DOMDestination;
  41. import net.sf.saxon.s9api.Destination;
  42. import net.sf.saxon.s9api.DocumentBuilder;
  43. import net.sf.saxon.s9api.Processor;
  44. import net.sf.saxon.s9api.Serializer;
  45. import net.sf.saxon.s9api.XQueryCompiler;
  46. import net.sf.saxon.s9api.XQueryEvaluator;
  47. import net.sf.saxon.s9api.XQueryExecutable;
  48. import net.sf.saxon.s9api.XdmNode;

  49. /**
  50.  * Classe utilizzabile per ricerche effettuate tramite espressioni XQuery
  51.  *
  52.  * @author Andrea Poli (apoli@link.it)
  53.  * @author $Author$
  54.  * @version $Rev$, $Date$
  55.  */

  56. public abstract class AbstractXQueryExpressionEngine {

  57.     private static final boolean DEFAULT_RESULT_AS_XML = false;
  58.    
  59.    
  60.     /* ***** CONFIG ***** */
  61.    
  62.     private static Configuration saxonConfig = null;
  63.     public static void initXQueryConfiguration() throws XQueryException{
  64.         AbstractXQueryExpressionEngine._initXQueryConfiguration(null);
  65.     }
  66.     public static void initXQueryConfiguration(String fileConfig) throws XQueryException{
  67.         if(fileConfig==null){
  68.             throw new XQueryException("Configuration file is null");
  69.         }
  70.         AbstractXQueryExpressionEngine.initXQueryConfiguration(new File(fileConfig));
  71.     }
  72.     public static void initXQueryConfiguration(File fileConfig) throws XQueryException{
  73.         if(fileConfig==null){
  74.             throw new XQueryException("Configuration file is null");
  75.         }
  76.         if(fileConfig.exists()==false){
  77.             throw new XQueryException("Configuration file ["+fileConfig.getAbsolutePath()+"] not exists");
  78.         }
  79.         if(fileConfig.canRead()==false){
  80.             throw new XQueryException("Configuration file ["+fileConfig.getAbsolutePath()+"] cannot read");
  81.         }
  82.         FileInputStream fin = null;
  83.         try{
  84.             fin = new FileInputStream(fileConfig);
  85.             AbstractXQueryExpressionEngine._initXQueryConfiguration(fin);
  86.         }
  87.         catch(XQueryException e){
  88.             throw e;
  89.         }
  90.         catch(Exception e){
  91.             throw new XQueryException(e.getMessage(),e);
  92.         }
  93.         finally{
  94.             try{
  95.                 if(fin!=null) {
  96.                     fin.close();
  97.                 }
  98.             }catch(Exception eClose){
  99.                 // close
  100.             }
  101.         }
  102.     }
  103.     public static void initXQueryConfiguration(InputStream isConfig) throws XQueryException{
  104.         if(isConfig==null){
  105.             throw new XQueryException("Configuration stream is null");
  106.         }
  107.         AbstractXQueryExpressionEngine._initXQueryConfiguration(isConfig);
  108.     }
  109.     private static synchronized void _initXQueryConfiguration(InputStream isConfig) throws XQueryException{
  110.         try{
  111.             if(AbstractXQueryExpressionEngine.saxonConfig==null){
  112.                 if(isConfig==null){
  113.                     AbstractXQueryExpressionEngine.saxonConfig = Configuration.newConfiguration();
  114.                 }
  115.                 else{
  116.                     StreamSource s = new StreamSource(isConfig);
  117.                     AbstractXQueryExpressionEngine.saxonConfig = Configuration.readConfiguration(s);
  118.                 }
  119.             }
  120.         }catch(Exception e){
  121.             throw new XQueryException("Inizializzazione XQueryConfiguration non riuscita",e);
  122.         }
  123.     }
  124.    
  125.    
  126.     /* ***** PROCESSOR ***** */
  127.    
  128.     private static Processor saxonProcessor = null;
  129.     // An XQueryCompiler may be used repeatedly to compile multiple queries. Any changes made to the XQueryCompiler (that is, to the static context)
  130.     // do not affect queries that have already been compiled. An XQueryCompiler may be used concurrently in multiple threads,
  131.     // but it should not then be modified once initialized.
  132.     private static XQueryCompiler saxonCompiler = null;
  133.     public static Processor getXQueryProcessor() throws XQueryException{
  134.         if(AbstractXQueryExpressionEngine.saxonProcessor==null){
  135.             AbstractXQueryExpressionEngine.initXQueryProcessor();
  136.         }
  137.         return AbstractXQueryExpressionEngine.saxonProcessor;
  138.     }
  139.     public static XQueryCompiler getXQueryCompiler() throws XQueryException{
  140.         if(AbstractXQueryExpressionEngine.saxonProcessor==null){
  141.             AbstractXQueryExpressionEngine.initXQueryProcessor();
  142.         }
  143.         return AbstractXQueryExpressionEngine.saxonCompiler;
  144.     }
  145.    
  146.     public static synchronized void initXQueryProcessor() throws XQueryException{
  147.         try{
  148.             if(AbstractXQueryExpressionEngine.saxonProcessor==null){
  149.                 if(AbstractXQueryExpressionEngine.saxonConfig==null){
  150.                     AbstractXQueryExpressionEngine.initXQueryConfiguration();
  151.                 }
  152.                 AbstractXQueryExpressionEngine.saxonProcessor = new Processor(AbstractXQueryExpressionEngine.saxonConfig);
  153.                 AbstractXQueryExpressionEngine.saxonCompiler = AbstractXQueryExpressionEngine.saxonProcessor.newXQueryCompiler();
  154.             }
  155.         }catch(Exception e){
  156.             throw new XQueryException("Inizializzazione XQueryFactory non riuscita",e);
  157.         }
  158.     }
  159.    
  160.    
  161.    
  162.     @SuppressWarnings("unused")
  163.     private static Logger logger = LoggerWrapperFactory.getLogger(AbstractXQueryExpressionEngine.class);
  164.     public static void setLogger(Logger logger) {
  165.         AbstractXQueryExpressionEngine.logger = logger;
  166.     }
  167.    
  168.    
  169.    
  170.     /* ***** ABSTRACT METHOD ***** */
  171.    
  172.     public abstract AbstractXMLUtils getXMLUtils();
  173.     public abstract Element readXPathElement(Element contenutoAsElement);
  174.    

  175.    
  176.        
  177.    
  178.     /* ***** ENGINE ***** */
  179.    
  180.     private XdmNode _buildXdmNode(Object xdmNodeParam) throws XQueryException{
  181.         if(xdmNodeParam==null){
  182.             throw new XQueryException("Parameter xdmNodeParam is null");
  183.         }
  184.         Source source = null;
  185.         InputStream isFile = null;
  186.         try{
  187.             if(xdmNodeParam instanceof Element){
  188.                 source = new DOMSource((this.readXPathElement((Element)xdmNodeParam)).getOwnerDocument()); // il builder sotto necessita di un document
  189.             }
  190.             else if(xdmNodeParam instanceof Document){
  191.                 source = new DOMSource((Document)xdmNodeParam);
  192.             }
  193.             else if(xdmNodeParam instanceof Node){
  194.                 source = new DOMSource(((Node)xdmNodeParam).getOwnerDocument()); // il builder sotto necessita di un document
  195.             }
  196.             else if(xdmNodeParam instanceof File){
  197.                 isFile = new FileInputStream((File)xdmNodeParam);
  198.                 InputSource eis = new InputSource(isFile);
  199.                 source = new SAXSource(eis);
  200.             }
  201.             else if(xdmNodeParam instanceof InputStream){
  202.                 InputSource eis = new InputSource((InputStream)xdmNodeParam);
  203.                 source = new SAXSource(eis);
  204.             }
  205.             else if(xdmNodeParam instanceof Reader){
  206.                 InputSource eis = new InputSource((Reader)xdmNodeParam);
  207.                 source = new SAXSource(eis);
  208.             }
  209.             else if(xdmNodeParam instanceof String){
  210.                 source = new DOMSource(this.getXMLUtils().newDocument(((String)xdmNodeParam).getBytes()));
  211.             }
  212.             else{
  213.                 throw new XQueryException("Type Parameter '"+xdmNodeParam.getClass().getName()+"' not supported");
  214.             }
  215.            
  216.             // Sharing of a DocumentBuilder across multiple threads is not recommended
  217.             DocumentBuilder builder = AbstractXQueryExpressionEngine.getXQueryProcessor().newDocumentBuilder();
  218.            
  219.             if(isFile!=null){
  220.                 return new WrapperFileXdmNode(builder.build(source), isFile);
  221.             }
  222.             else{
  223.                 return builder.build(source);
  224.             }
  225.         }
  226.         catch(Exception e){
  227.             throw new XQueryException(e.getMessage(),e);
  228.         }
  229.     }
  230.    
  231.     private WrapperDestination _buildDestination(Object destinationParam, boolean xml) throws XQueryException{
  232.         if(destinationParam==null){
  233.             throw new XQueryException("Parameter destination is null");
  234.         }
  235.         WrapperDestination wrapper = new WrapperDestination();
  236.         Destination destination = null;
  237.         try{
  238.             if(destinationParam instanceof Node){
  239.                 wrapper.node = (Node)destinationParam;
  240.                 destination =  new DOMDestination(wrapper.node);
  241.             }
  242.             else if(destinationParam instanceof File){
  243.                 wrapper.file = (File)destinationParam;
  244.                 destination = AbstractXQueryExpressionEngine.getXQueryProcessor().newSerializer(wrapper.file);
  245.             }
  246.             else if(destinationParam instanceof OutputStream){
  247.                 wrapper.cout = new CountingOutputStream((OutputStream)destinationParam);
  248.                 destination = AbstractXQueryExpressionEngine.getXQueryProcessor().newSerializer(wrapper.cout);
  249.             }
  250.             else if(destinationParam instanceof Writer){
  251.                 wrapper.writer = (Writer)destinationParam;
  252.                 destination = AbstractXQueryExpressionEngine.getXQueryProcessor().newSerializer(wrapper.writer);
  253.             }
  254.             else{
  255.                 throw new XQueryException("Type Parameter '"+destinationParam.getClass().getName()+"' not supported");
  256.             }
  257.             if(destination instanceof Serializer){
  258.                 if(xml){
  259.                     ((Serializer)destination).setOutputProperty(Serializer.Property.METHOD, "xml");
  260.                     ((Serializer)destination).setOutputProperty(Serializer.Property.INDENT, "yes");
  261.                     ((Serializer)destination).setOutputProperty(Serializer.Property.OMIT_XML_DECLARATION, "yes");
  262.                     //((Serializer)destination).setOutputProperty(Serializer.Property.SAXON_INDENT_SPACES, "2");
  263.                 }
  264.             }
  265.             wrapper.destination = destination;
  266.             return wrapper;
  267.         }
  268.         catch(Exception e){
  269.             throw new XQueryException(e.getMessage(),e);
  270.         }
  271.     }
  272.    
  273.     private XQueryEvaluator _buildEvaluator(Object xquery) throws XQueryException, XQueryNotValidException{
  274.         if(xquery==null){
  275.             throw new XQueryException("Parameter xquery is null");
  276.         }
  277.         XQueryExecutable exp = null;
  278.         try{
  279.             if(xquery instanceof String){
  280.                 exp = AbstractXQueryExpressionEngine.getXQueryCompiler().compile((String)xquery);
  281.             }
  282.             else if(xquery instanceof File){
  283.                 exp = AbstractXQueryExpressionEngine.getXQueryCompiler().compile((File)xquery);
  284.             }
  285.             else if(xquery instanceof InputStream){
  286.                 exp = AbstractXQueryExpressionEngine.getXQueryCompiler().compile((InputStream)xquery);
  287.             }
  288.             else if(xquery instanceof Reader){
  289.                 exp = AbstractXQueryExpressionEngine.getXQueryCompiler().compile((Reader)xquery);
  290.             }
  291.             else{
  292.                 throw new XQueryException("Type Parameter '"+xquery.getClass().getName()+"' not supported");
  293.             }
  294.             return exp.load();
  295.         }
  296.         catch(XQueryException e){
  297.             throw e;
  298.         }
  299.         catch(Exception e){
  300.             throw new XQueryNotValidException(e.getMessage(),e);
  301.         }
  302.     }
  303.    
  304.    
  305.     private void _evaluate(XdmNode doc, XQueryEvaluator evaluator,WrapperDestination destination) throws XQueryException, XQueryEvaluateException, XQueryEvaluateNotFoundException{
  306.         try{
  307.             evaluator.setContextItem(doc);
  308.         }catch(Exception e){
  309.             throw new XQueryException(e.getMessage(),e);
  310.         }
  311.         try{
  312.             evaluator.setContextItem(doc);
  313.             evaluator.run(destination.destination);
  314.            
  315.             if(destination.cout!=null){
  316.                 destination.cout.flush();
  317.                 destination.cout.close();
  318.                 if(destination.cout.getByteCount()<=0){
  319.                     throw new XQueryEvaluateNotFoundException("Not write bytes in output stream destination");
  320.                 }
  321.             }
  322.             else if(destination.file!=null){
  323.                 if(destination.file.length()<=0){
  324.                     throw new XQueryEvaluateNotFoundException("File destination is empty");
  325.                 }
  326.             }
  327.             else if(destination.node!=null){
  328.                 if( (destination.node.getChildNodes()==null || destination.node.getChildNodes().getLength()<=0) && destination.node.hasAttributes()==false ){
  329.                     throw new XQueryEvaluateNotFoundException("Node destination is empty");
  330.                 }
  331.             }
  332.             else if(destination.writer!=null){
  333.                 // not implemented check
  334.             }
  335.         }
  336.         catch(XQueryEvaluateNotFoundException notFound){
  337.             throw notFound;
  338.         }
  339.         catch(Exception e){
  340.             throw new XQueryEvaluateException(e.getMessage(),e);
  341.         }
  342.         finally{
  343.             try{
  344.                 if(doc instanceof WrapperFileXdmNode){
  345.                     ((WrapperFileXdmNode)doc).is.close();
  346.                 }
  347.             }catch(Exception eClose){}
  348.         }
  349.     }
  350.    
  351.    
  352.    
  353.     /* ***** PUBLIC METHOD ***** */
  354.    
  355.     public void validate(Object xquery) throws XQueryException, XQueryNotValidException{
  356.         this._buildEvaluator(xquery);
  357.     }
  358.    
  359.    
  360.    
  361.     /* ***** PUBLIC METHOD (SRC as Node) ***** */
  362.    
  363.     // Destination: String
  364.     public String evaluate(Node source, String xquery) throws XQueryException, XQueryNotValidException, XQueryEvaluateException, XQueryEvaluateNotFoundException{
  365.         return this.evaluate(source, xquery, AbstractXQueryExpressionEngine.DEFAULT_RESULT_AS_XML);
  366.     }
  367.     public String evaluate(Node source, String xquery, boolean resultAsXml) throws XQueryException, XQueryNotValidException, XQueryEvaluateException, XQueryEvaluateNotFoundException{
  368.         try{
  369.             ByteArrayOutputStream bout = new ByteArrayOutputStream();
  370.             this.evaluate(source, xquery, bout,resultAsXml);
  371.             bout.flush();
  372.             bout.close();
  373.             return bout.toString();
  374.         }catch(XQueryException e){
  375.             throw e;
  376.         }catch(XQueryNotValidException e){
  377.             throw e;
  378.         }catch(XQueryEvaluateException e){
  379.             throw e;
  380.         }catch(XQueryEvaluateNotFoundException e){
  381.             throw e;
  382.         }catch(Exception e){
  383.             throw new XQueryException(e.getMessage(),e);
  384.         }
  385.     }
  386.     public String evaluate(Node source, File xquery) throws XQueryException, XQueryNotValidException, XQueryEvaluateException, XQueryEvaluateNotFoundException{
  387.         return this.evaluate(source, xquery, AbstractXQueryExpressionEngine.DEFAULT_RESULT_AS_XML);
  388.     }
  389.     public String evaluate(Node source, File xquery, boolean resultAsXml) throws XQueryException, XQueryNotValidException, XQueryEvaluateException, XQueryEvaluateNotFoundException{
  390.         try{
  391.             ByteArrayOutputStream bout = new ByteArrayOutputStream();
  392.             this.evaluate(source, xquery, bout, resultAsXml);
  393.             bout.flush();
  394.             bout.close();
  395.             return bout.toString();
  396.         }catch(XQueryException e){
  397.             throw e;
  398.         }catch(XQueryNotValidException e){
  399.             throw e;
  400.         }catch(XQueryEvaluateException e){
  401.             throw e;
  402.         }catch(XQueryEvaluateNotFoundException e){
  403.             throw e;
  404.         }catch(Exception e){
  405.             throw new XQueryException(e.getMessage(),e);
  406.         }
  407.     }
  408.     public String evaluate(Node source, InputStream xquery) throws XQueryException, XQueryNotValidException, XQueryEvaluateException, XQueryEvaluateNotFoundException{
  409.         return this.evaluate(source, xquery, AbstractXQueryExpressionEngine.DEFAULT_RESULT_AS_XML);
  410.     }
  411.     public String evaluate(Node source, InputStream xquery, boolean resultAsXml) throws XQueryException, XQueryNotValidException, XQueryEvaluateException, XQueryEvaluateNotFoundException{
  412.         try{
  413.             ByteArrayOutputStream bout = new ByteArrayOutputStream();
  414.             this.evaluate(source, xquery, bout, resultAsXml);
  415.             bout.flush();
  416.             bout.close();
  417.             return bout.toString();
  418.         }catch(XQueryException e){
  419.             throw e;
  420.         }catch(XQueryNotValidException e){
  421.             throw e;
  422.         }catch(XQueryEvaluateException e){
  423.             throw e;
  424.         }catch(XQueryEvaluateNotFoundException e){
  425.             throw e;
  426.         }catch(Exception e){
  427.             throw new XQueryException(e.getMessage(),e);
  428.         }
  429.     }
  430.     public String evaluate(Node source, Reader xquery) throws XQueryException, XQueryNotValidException, XQueryEvaluateException, XQueryEvaluateNotFoundException{
  431.         return this.evaluate(source, xquery, AbstractXQueryExpressionEngine.DEFAULT_RESULT_AS_XML);
  432.     }
  433.     public String evaluate(Node source, Reader xquery, boolean resultAsXml) throws XQueryException, XQueryNotValidException, XQueryEvaluateException, XQueryEvaluateNotFoundException{
  434.         try{
  435.             ByteArrayOutputStream bout = new ByteArrayOutputStream();
  436.             this.evaluate(source, xquery, bout, resultAsXml);
  437.             bout.flush();
  438.             bout.close();
  439.             return bout.toString();
  440.         }catch(XQueryException e){
  441.             throw e;
  442.         }catch(XQueryNotValidException e){
  443.             throw e;
  444.         }catch(XQueryEvaluateException e){
  445.             throw e;
  446.         }catch(XQueryEvaluateNotFoundException e){
  447.             throw e;
  448.         }catch(Exception e){
  449.             throw new XQueryException(e.getMessage(),e);
  450.         }
  451.     }
  452.    
  453.     // Destination: OutputStream
  454.     public void evaluate(Node source, String xquery, OutputStream out) throws XQueryException, XQueryNotValidException, XQueryEvaluateException, XQueryEvaluateNotFoundException{
  455.         this._evaluate(this._buildXdmNode(source), this._buildEvaluator(xquery), this._buildDestination(out, AbstractXQueryExpressionEngine.DEFAULT_RESULT_AS_XML));
  456.     }
  457.     public void evaluate(Node source, String xquery, OutputStream out, boolean resultAsXml) throws XQueryException, XQueryNotValidException, XQueryEvaluateException, XQueryEvaluateNotFoundException{
  458.         this._evaluate(this._buildXdmNode(source), this._buildEvaluator(xquery), this._buildDestination(out, resultAsXml));
  459.     }
  460.     public void evaluate(Node source, File xquery, OutputStream out) throws XQueryException, XQueryNotValidException, XQueryEvaluateException, XQueryEvaluateNotFoundException{
  461.         this._evaluate(this._buildXdmNode(source), this._buildEvaluator(xquery), this._buildDestination(out, AbstractXQueryExpressionEngine.DEFAULT_RESULT_AS_XML));
  462.     }
  463.     public void evaluate(Node source, File xquery, OutputStream out, boolean resultAsXml) throws XQueryException, XQueryNotValidException, XQueryEvaluateException, XQueryEvaluateNotFoundException{
  464.         this._evaluate(this._buildXdmNode(source), this._buildEvaluator(xquery), this._buildDestination(out, resultAsXml));
  465.     }
  466.     public void evaluate(Node source, InputStream xquery, OutputStream out) throws XQueryException, XQueryNotValidException, XQueryEvaluateException, XQueryEvaluateNotFoundException{
  467.         this._evaluate(this._buildXdmNode(source), this._buildEvaluator(xquery), this._buildDestination(out, AbstractXQueryExpressionEngine.DEFAULT_RESULT_AS_XML));
  468.     }
  469.     public void evaluate(Node source, InputStream xquery, OutputStream out, boolean resultAsXml) throws XQueryException, XQueryNotValidException, XQueryEvaluateException, XQueryEvaluateNotFoundException{
  470.         this._evaluate(this._buildXdmNode(source), this._buildEvaluator(xquery), this._buildDestination(out, resultAsXml));
  471.     }
  472.     public void evaluate(Node source, Reader xquery, OutputStream out) throws XQueryException, XQueryNotValidException, XQueryEvaluateException, XQueryEvaluateNotFoundException{
  473.         this._evaluate(this._buildXdmNode(source), this._buildEvaluator(xquery), this._buildDestination(out, AbstractXQueryExpressionEngine.DEFAULT_RESULT_AS_XML));
  474.     }
  475.     public void evaluate(Node source, Reader xquery, OutputStream out, boolean resultAsXml) throws XQueryException, XQueryNotValidException, XQueryEvaluateException, XQueryEvaluateNotFoundException{
  476.         this._evaluate(this._buildXdmNode(source), this._buildEvaluator(xquery), this._buildDestination(out, resultAsXml));
  477.     }
  478.    
  479.     // Destination: Writer
  480.     public void evaluate(Node source, String xquery, Writer out) throws XQueryException, XQueryNotValidException, XQueryEvaluateException, XQueryEvaluateNotFoundException{
  481.         this._evaluate(this._buildXdmNode(source), this._buildEvaluator(xquery), this._buildDestination(out, AbstractXQueryExpressionEngine.DEFAULT_RESULT_AS_XML));
  482.     }
  483.     public void evaluate(Node source, String xquery, Writer out, boolean resultAsXml) throws XQueryException, XQueryNotValidException, XQueryEvaluateException, XQueryEvaluateNotFoundException{
  484.         this._evaluate(this._buildXdmNode(source), this._buildEvaluator(xquery), this._buildDestination(out, resultAsXml));
  485.     }
  486.     public void evaluate(Node source, File xquery, Writer out) throws XQueryException, XQueryNotValidException, XQueryEvaluateException, XQueryEvaluateNotFoundException{
  487.         this._evaluate(this._buildXdmNode(source), this._buildEvaluator(xquery), this._buildDestination(out, AbstractXQueryExpressionEngine.DEFAULT_RESULT_AS_XML));
  488.     }
  489.     public void evaluate(Node source, File xquery, Writer out, boolean resultAsXml) throws XQueryException, XQueryNotValidException, XQueryEvaluateException, XQueryEvaluateNotFoundException{
  490.         this._evaluate(this._buildXdmNode(source), this._buildEvaluator(xquery), this._buildDestination(out, resultAsXml));
  491.     }
  492.     public void evaluate(Node source, InputStream xquery, Writer out) throws XQueryException, XQueryNotValidException, XQueryEvaluateException, XQueryEvaluateNotFoundException{
  493.         this._evaluate(this._buildXdmNode(source), this._buildEvaluator(xquery), this._buildDestination(out, AbstractXQueryExpressionEngine.DEFAULT_RESULT_AS_XML));
  494.     }
  495.     public void evaluate(Node source, InputStream xquery, Writer out, boolean resultAsXml) throws XQueryException, XQueryNotValidException, XQueryEvaluateException, XQueryEvaluateNotFoundException{
  496.         this._evaluate(this._buildXdmNode(source), this._buildEvaluator(xquery), this._buildDestination(out, resultAsXml));
  497.     }
  498.     public void evaluate(Node source, Reader xquery, Writer out) throws XQueryException, XQueryNotValidException, XQueryEvaluateException, XQueryEvaluateNotFoundException{
  499.         this._evaluate(this._buildXdmNode(source), this._buildEvaluator(xquery), this._buildDestination(out, AbstractXQueryExpressionEngine.DEFAULT_RESULT_AS_XML));
  500.     }
  501.     public void evaluate(Node source, Reader xquery, Writer out, boolean resultAsXml) throws XQueryException, XQueryNotValidException, XQueryEvaluateException, XQueryEvaluateNotFoundException{
  502.         this._evaluate(this._buildXdmNode(source), this._buildEvaluator(xquery), this._buildDestination(out, resultAsXml));
  503.     }
  504.    
  505.     // Destination: File
  506.     public void evaluate(Node source, String xquery, File out) throws XQueryException, XQueryNotValidException, XQueryEvaluateException, XQueryEvaluateNotFoundException{
  507.         this._evaluate(this._buildXdmNode(source), this._buildEvaluator(xquery), this._buildDestination(out, AbstractXQueryExpressionEngine.DEFAULT_RESULT_AS_XML));
  508.     }
  509.     public void evaluate(Node source, String xquery, File out, boolean resultAsXml) throws XQueryException, XQueryNotValidException, XQueryEvaluateException, XQueryEvaluateNotFoundException{
  510.         this._evaluate(this._buildXdmNode(source), this._buildEvaluator(xquery), this._buildDestination(out, resultAsXml));
  511.     }
  512.     public void evaluate(Node source, File xquery, File out) throws XQueryException, XQueryNotValidException, XQueryEvaluateException, XQueryEvaluateNotFoundException{
  513.         this._evaluate(this._buildXdmNode(source), this._buildEvaluator(xquery), this._buildDestination(out, AbstractXQueryExpressionEngine.DEFAULT_RESULT_AS_XML));
  514.     }
  515.     public void evaluate(Node source, File xquery, File out, boolean resultAsXml) throws XQueryException, XQueryNotValidException, XQueryEvaluateException, XQueryEvaluateNotFoundException{
  516.         this._evaluate(this._buildXdmNode(source), this._buildEvaluator(xquery), this._buildDestination(out, resultAsXml));
  517.     }
  518.     public void evaluate(Node source, InputStream xquery, File out) throws XQueryException, XQueryNotValidException, XQueryEvaluateException, XQueryEvaluateNotFoundException{
  519.         this._evaluate(this._buildXdmNode(source), this._buildEvaluator(xquery), this._buildDestination(out, AbstractXQueryExpressionEngine.DEFAULT_RESULT_AS_XML));
  520.     }
  521.     public void evaluate(Node source, InputStream xquery, File out, boolean resultAsXml) throws XQueryException, XQueryNotValidException, XQueryEvaluateException, XQueryEvaluateNotFoundException{
  522.         this._evaluate(this._buildXdmNode(source), this._buildEvaluator(xquery), this._buildDestination(out, resultAsXml));
  523.     }
  524.     public void evaluate(Node source, Reader xquery, File out) throws XQueryException, XQueryNotValidException, XQueryEvaluateException, XQueryEvaluateNotFoundException{
  525.         this._evaluate(this._buildXdmNode(source), this._buildEvaluator(xquery), this._buildDestination(out, AbstractXQueryExpressionEngine.DEFAULT_RESULT_AS_XML));
  526.     }
  527.     public void evaluate(Node source, Reader xquery, File out, boolean resultAsXml) throws XQueryException, XQueryNotValidException, XQueryEvaluateException, XQueryEvaluateNotFoundException{
  528.         this._evaluate(this._buildXdmNode(source), this._buildEvaluator(xquery), this._buildDestination(out, resultAsXml));
  529.     }
  530.    
  531.     // Destination: Node
  532.     public void evaluate(Node source, String xquery, Node out) throws XQueryException, XQueryNotValidException, XQueryEvaluateException, XQueryEvaluateNotFoundException{
  533.         this._evaluate(this._buildXdmNode(source), this._buildEvaluator(xquery), this._buildDestination(out, AbstractXQueryExpressionEngine.DEFAULT_RESULT_AS_XML));
  534.     }
  535.     public void evaluate(Node source, String xquery, Node out, boolean resultAsXml) throws XQueryException, XQueryNotValidException, XQueryEvaluateException, XQueryEvaluateNotFoundException{
  536.         this._evaluate(this._buildXdmNode(source), this._buildEvaluator(xquery), this._buildDestination(out, resultAsXml));
  537.     }
  538.     public void evaluate(Node source, File xquery, Node out) throws XQueryException, XQueryNotValidException, XQueryEvaluateException, XQueryEvaluateNotFoundException{
  539.         this._evaluate(this._buildXdmNode(source), this._buildEvaluator(xquery), this._buildDestination(out, AbstractXQueryExpressionEngine.DEFAULT_RESULT_AS_XML));
  540.     }
  541.     public void evaluate(Node source, File xquery, Node out, boolean resultAsXml) throws XQueryException, XQueryNotValidException, XQueryEvaluateException, XQueryEvaluateNotFoundException{
  542.         this._evaluate(this._buildXdmNode(source), this._buildEvaluator(xquery), this._buildDestination(out, resultAsXml));
  543.     }
  544.     public void evaluate(Node source, InputStream xquery, Node out) throws XQueryException, XQueryNotValidException, XQueryEvaluateException, XQueryEvaluateNotFoundException{
  545.         this._evaluate(this._buildXdmNode(source), this._buildEvaluator(xquery), this._buildDestination(out, AbstractXQueryExpressionEngine.DEFAULT_RESULT_AS_XML));
  546.     }
  547.     public void evaluate(Node source, InputStream xquery, Node out, boolean resultAsXml) throws XQueryException, XQueryNotValidException, XQueryEvaluateException, XQueryEvaluateNotFoundException{
  548.         this._evaluate(this._buildXdmNode(source), this._buildEvaluator(xquery), this._buildDestination(out, resultAsXml));
  549.     }
  550.     public void evaluate(Node source, Reader xquery, Node out) throws XQueryException, XQueryNotValidException, XQueryEvaluateException, XQueryEvaluateNotFoundException{
  551.         this._evaluate(this._buildXdmNode(source), this._buildEvaluator(xquery), this._buildDestination(out, AbstractXQueryExpressionEngine.DEFAULT_RESULT_AS_XML));
  552.     }
  553.     public void evaluate(Node source, Reader xquery, Node out, boolean resultAsXml) throws XQueryException, XQueryNotValidException, XQueryEvaluateException, XQueryEvaluateNotFoundException{
  554.         this._evaluate(this._buildXdmNode(source), this._buildEvaluator(xquery), this._buildDestination(out, resultAsXml));
  555.     }
  556.    
  557.    
  558.    
  559.    
  560.     /* ***** PUBLIC METHOD (SRC as Document) ***** */
  561.    
  562.     // Destination: String
  563.     public String evaluate(Document source, String xquery) throws XQueryException, XQueryNotValidException, XQueryEvaluateException, XQueryEvaluateNotFoundException{
  564.         return this.evaluate(source, xquery, AbstractXQueryExpressionEngine.DEFAULT_RESULT_AS_XML);
  565.     }
  566.     public String evaluate(Document source, String xquery, boolean resultAsXml) throws XQueryException, XQueryNotValidException, XQueryEvaluateException, XQueryEvaluateNotFoundException{
  567.         try{
  568.             ByteArrayOutputStream bout = new ByteArrayOutputStream();
  569.             this.evaluate(source, xquery, bout,resultAsXml);
  570.             bout.flush();
  571.             bout.close();
  572.             return bout.toString();
  573.         }catch(XQueryException e){
  574.             throw e;
  575.         }catch(XQueryNotValidException e){
  576.             throw e;
  577.         }catch(XQueryEvaluateException e){
  578.             throw e;
  579.         }catch(XQueryEvaluateNotFoundException e){
  580.             throw e;
  581.         }catch(Exception e){
  582.             throw new XQueryException(e.getMessage(),e);
  583.         }
  584.     }
  585.     public String evaluate(Document source, File xquery) throws XQueryException, XQueryNotValidException, XQueryEvaluateException, XQueryEvaluateNotFoundException{
  586.         return this.evaluate(source, xquery, AbstractXQueryExpressionEngine.DEFAULT_RESULT_AS_XML);
  587.     }
  588.     public String evaluate(Document source, File xquery, boolean resultAsXml) throws XQueryException, XQueryNotValidException, XQueryEvaluateException, XQueryEvaluateNotFoundException{
  589.         try{
  590.             ByteArrayOutputStream bout = new ByteArrayOutputStream();
  591.             this.evaluate(source, xquery, bout, resultAsXml);
  592.             bout.flush();
  593.             bout.close();
  594.             return bout.toString();
  595.         }catch(XQueryException e){
  596.             throw e;
  597.         }catch(XQueryNotValidException e){
  598.             throw e;
  599.         }catch(XQueryEvaluateException e){
  600.             throw e;
  601.         }catch(XQueryEvaluateNotFoundException e){
  602.             throw e;
  603.         }catch(Exception e){
  604.             throw new XQueryException(e.getMessage(),e);
  605.         }
  606.     }
  607.     public String evaluate(Document source, InputStream xquery) throws XQueryException, XQueryNotValidException, XQueryEvaluateException, XQueryEvaluateNotFoundException{
  608.         return this.evaluate(source, xquery, AbstractXQueryExpressionEngine.DEFAULT_RESULT_AS_XML);
  609.     }
  610.     public String evaluate(Document source, InputStream xquery, boolean resultAsXml) throws XQueryException, XQueryNotValidException, XQueryEvaluateException, XQueryEvaluateNotFoundException{
  611.         try{
  612.             ByteArrayOutputStream bout = new ByteArrayOutputStream();
  613.             this.evaluate(source, xquery, bout, resultAsXml);
  614.             bout.flush();
  615.             bout.close();
  616.             return bout.toString();
  617.         }catch(XQueryException e){
  618.             throw e;
  619.         }catch(XQueryNotValidException e){
  620.             throw e;
  621.         }catch(XQueryEvaluateException e){
  622.             throw e;
  623.         }catch(XQueryEvaluateNotFoundException e){
  624.             throw e;
  625.         }catch(Exception e){
  626.             throw new XQueryException(e.getMessage(),e);
  627.         }
  628.     }
  629.     public String evaluate(Document source, Reader xquery) throws XQueryException, XQueryNotValidException, XQueryEvaluateException, XQueryEvaluateNotFoundException{
  630.         return this.evaluate(source, xquery, AbstractXQueryExpressionEngine.DEFAULT_RESULT_AS_XML);
  631.     }
  632.     public String evaluate(Document source, Reader xquery, boolean resultAsXml) throws XQueryException, XQueryNotValidException, XQueryEvaluateException, XQueryEvaluateNotFoundException{
  633.         try{
  634.             ByteArrayOutputStream bout = new ByteArrayOutputStream();
  635.             this.evaluate(source, xquery, bout, resultAsXml);
  636.             bout.flush();
  637.             bout.close();
  638.             return bout.toString();
  639.         }catch(XQueryException e){
  640.             throw e;
  641.         }catch(XQueryNotValidException e){
  642.             throw e;
  643.         }catch(XQueryEvaluateException e){
  644.             throw e;
  645.         }catch(XQueryEvaluateNotFoundException e){
  646.             throw e;
  647.         }catch(Exception e){
  648.             throw new XQueryException(e.getMessage(),e);
  649.         }
  650.     }
  651.    
  652.     // Destination: OutputStream
  653.     public void evaluate(Document source, String xquery, OutputStream out) throws XQueryException, XQueryNotValidException, XQueryEvaluateException, XQueryEvaluateNotFoundException{
  654.         this._evaluate(this._buildXdmNode(source), this._buildEvaluator(xquery), this._buildDestination(out, AbstractXQueryExpressionEngine.DEFAULT_RESULT_AS_XML));
  655.     }
  656.     public void evaluate(Document source, String xquery, OutputStream out, boolean resultAsXml) throws XQueryException, XQueryNotValidException, XQueryEvaluateException, XQueryEvaluateNotFoundException{
  657.         this._evaluate(this._buildXdmNode(source), this._buildEvaluator(xquery), this._buildDestination(out, resultAsXml));
  658.     }
  659.     public void evaluate(Document source, File xquery, OutputStream out) throws XQueryException, XQueryNotValidException, XQueryEvaluateException, XQueryEvaluateNotFoundException{
  660.         this._evaluate(this._buildXdmNode(source), this._buildEvaluator(xquery), this._buildDestination(out, AbstractXQueryExpressionEngine.DEFAULT_RESULT_AS_XML));
  661.     }
  662.     public void evaluate(Document source, File xquery, OutputStream out, boolean resultAsXml) throws XQueryException, XQueryNotValidException, XQueryEvaluateException, XQueryEvaluateNotFoundException{
  663.         this._evaluate(this._buildXdmNode(source), this._buildEvaluator(xquery), this._buildDestination(out, resultAsXml));
  664.     }
  665.     public void evaluate(Document source, InputStream xquery, OutputStream out) throws XQueryException, XQueryNotValidException, XQueryEvaluateException, XQueryEvaluateNotFoundException{
  666.         this._evaluate(this._buildXdmNode(source), this._buildEvaluator(xquery), this._buildDestination(out, AbstractXQueryExpressionEngine.DEFAULT_RESULT_AS_XML));
  667.     }
  668.     public void evaluate(Document source, InputStream xquery, OutputStream out, boolean resultAsXml) throws XQueryException, XQueryNotValidException, XQueryEvaluateException, XQueryEvaluateNotFoundException{
  669.         this._evaluate(this._buildXdmNode(source), this._buildEvaluator(xquery), this._buildDestination(out, resultAsXml));
  670.     }
  671.     public void evaluate(Document source, Reader xquery, OutputStream out) throws XQueryException, XQueryNotValidException, XQueryEvaluateException, XQueryEvaluateNotFoundException{
  672.         this._evaluate(this._buildXdmNode(source), this._buildEvaluator(xquery), this._buildDestination(out, AbstractXQueryExpressionEngine.DEFAULT_RESULT_AS_XML));
  673.     }
  674.     public void evaluate(Document source, Reader xquery, OutputStream out, boolean resultAsXml) throws XQueryException, XQueryNotValidException, XQueryEvaluateException, XQueryEvaluateNotFoundException{
  675.         this._evaluate(this._buildXdmNode(source), this._buildEvaluator(xquery), this._buildDestination(out, resultAsXml));
  676.     }
  677.    
  678.     // Destination: Writer
  679.     public void evaluate(Document source, String xquery, Writer out) throws XQueryException, XQueryNotValidException, XQueryEvaluateException, XQueryEvaluateNotFoundException{
  680.         this._evaluate(this._buildXdmNode(source), this._buildEvaluator(xquery), this._buildDestination(out, AbstractXQueryExpressionEngine.DEFAULT_RESULT_AS_XML));
  681.     }
  682.     public void evaluate(Document source, String xquery, Writer out, boolean resultAsXml) throws XQueryException, XQueryNotValidException, XQueryEvaluateException, XQueryEvaluateNotFoundException{
  683.         this._evaluate(this._buildXdmNode(source), this._buildEvaluator(xquery), this._buildDestination(out, resultAsXml));
  684.     }
  685.     public void evaluate(Document source, File xquery, Writer out) throws XQueryException, XQueryNotValidException, XQueryEvaluateException, XQueryEvaluateNotFoundException{
  686.         this._evaluate(this._buildXdmNode(source), this._buildEvaluator(xquery), this._buildDestination(out, AbstractXQueryExpressionEngine.DEFAULT_RESULT_AS_XML));
  687.     }
  688.     public void evaluate(Document source, File xquery, Writer out, boolean resultAsXml) throws XQueryException, XQueryNotValidException, XQueryEvaluateException, XQueryEvaluateNotFoundException{
  689.         this._evaluate(this._buildXdmNode(source), this._buildEvaluator(xquery), this._buildDestination(out, resultAsXml));
  690.     }
  691.     public void evaluate(Document source, InputStream xquery, Writer out) throws XQueryException, XQueryNotValidException, XQueryEvaluateException, XQueryEvaluateNotFoundException{
  692.         this._evaluate(this._buildXdmNode(source), this._buildEvaluator(xquery), this._buildDestination(out, AbstractXQueryExpressionEngine.DEFAULT_RESULT_AS_XML));
  693.     }
  694.     public void evaluate(Document source, InputStream xquery, Writer out, boolean resultAsXml) throws XQueryException, XQueryNotValidException, XQueryEvaluateException, XQueryEvaluateNotFoundException{
  695.         this._evaluate(this._buildXdmNode(source), this._buildEvaluator(xquery), this._buildDestination(out, resultAsXml));
  696.     }
  697.     public void evaluate(Document source, Reader xquery, Writer out) throws XQueryException, XQueryNotValidException, XQueryEvaluateException, XQueryEvaluateNotFoundException{
  698.         this._evaluate(this._buildXdmNode(source), this._buildEvaluator(xquery), this._buildDestination(out, AbstractXQueryExpressionEngine.DEFAULT_RESULT_AS_XML));
  699.     }
  700.     public void evaluate(Document source, Reader xquery, Writer out, boolean resultAsXml) throws XQueryException, XQueryNotValidException, XQueryEvaluateException, XQueryEvaluateNotFoundException{
  701.         this._evaluate(this._buildXdmNode(source), this._buildEvaluator(xquery), this._buildDestination(out, resultAsXml));
  702.     }
  703.    
  704.     // Destination: File
  705.     public void evaluate(Document source, String xquery, File out) throws XQueryException, XQueryNotValidException, XQueryEvaluateException, XQueryEvaluateNotFoundException{
  706.         this._evaluate(this._buildXdmNode(source), this._buildEvaluator(xquery), this._buildDestination(out, AbstractXQueryExpressionEngine.DEFAULT_RESULT_AS_XML));
  707.     }
  708.     public void evaluate(Document source, String xquery, File out, boolean resultAsXml) throws XQueryException, XQueryNotValidException, XQueryEvaluateException, XQueryEvaluateNotFoundException{
  709.         this._evaluate(this._buildXdmNode(source), this._buildEvaluator(xquery), this._buildDestination(out, resultAsXml));
  710.     }
  711.     public void evaluate(Document source, File xquery, File out) throws XQueryException, XQueryNotValidException, XQueryEvaluateException, XQueryEvaluateNotFoundException{
  712.         this._evaluate(this._buildXdmNode(source), this._buildEvaluator(xquery), this._buildDestination(out, AbstractXQueryExpressionEngine.DEFAULT_RESULT_AS_XML));
  713.     }
  714.     public void evaluate(Document source, File xquery, File out, boolean resultAsXml) throws XQueryException, XQueryNotValidException, XQueryEvaluateException, XQueryEvaluateNotFoundException{
  715.         this._evaluate(this._buildXdmNode(source), this._buildEvaluator(xquery), this._buildDestination(out, resultAsXml));
  716.     }
  717.     public void evaluate(Document source, InputStream xquery, File out) throws XQueryException, XQueryNotValidException, XQueryEvaluateException, XQueryEvaluateNotFoundException{
  718.         this._evaluate(this._buildXdmNode(source), this._buildEvaluator(xquery), this._buildDestination(out, AbstractXQueryExpressionEngine.DEFAULT_RESULT_AS_XML));
  719.     }
  720.     public void evaluate(Document source, InputStream xquery, File out, boolean resultAsXml) throws XQueryException, XQueryNotValidException, XQueryEvaluateException, XQueryEvaluateNotFoundException{
  721.         this._evaluate(this._buildXdmNode(source), this._buildEvaluator(xquery), this._buildDestination(out, resultAsXml));
  722.     }
  723.     public void evaluate(Document source, Reader xquery, File out) throws XQueryException, XQueryNotValidException, XQueryEvaluateException, XQueryEvaluateNotFoundException{
  724.         this._evaluate(this._buildXdmNode(source), this._buildEvaluator(xquery), this._buildDestination(out, AbstractXQueryExpressionEngine.DEFAULT_RESULT_AS_XML));
  725.     }
  726.     public void evaluate(Document source, Reader xquery, File out, boolean resultAsXml) throws XQueryException, XQueryNotValidException, XQueryEvaluateException, XQueryEvaluateNotFoundException{
  727.         this._evaluate(this._buildXdmNode(source), this._buildEvaluator(xquery), this._buildDestination(out, resultAsXml));
  728.     }
  729.    
  730.     // Destination: Node
  731.     public void evaluate(Document source, String xquery, Node out) throws XQueryException, XQueryNotValidException, XQueryEvaluateException, XQueryEvaluateNotFoundException{
  732.         this._evaluate(this._buildXdmNode(source), this._buildEvaluator(xquery), this._buildDestination(out, AbstractXQueryExpressionEngine.DEFAULT_RESULT_AS_XML));
  733.     }
  734.     public void evaluate(Document source, String xquery, Node out, boolean resultAsXml) throws XQueryException, XQueryNotValidException, XQueryEvaluateException, XQueryEvaluateNotFoundException{
  735.         this._evaluate(this._buildXdmNode(source), this._buildEvaluator(xquery), this._buildDestination(out, resultAsXml));
  736.     }
  737.     public void evaluate(Document source, File xquery, Node out) throws XQueryException, XQueryNotValidException, XQueryEvaluateException, XQueryEvaluateNotFoundException{
  738.         this._evaluate(this._buildXdmNode(source), this._buildEvaluator(xquery), this._buildDestination(out, AbstractXQueryExpressionEngine.DEFAULT_RESULT_AS_XML));
  739.     }
  740.     public void evaluate(Document source, File xquery, Node out, boolean resultAsXml) throws XQueryException, XQueryNotValidException, XQueryEvaluateException, XQueryEvaluateNotFoundException{
  741.         this._evaluate(this._buildXdmNode(source), this._buildEvaluator(xquery), this._buildDestination(out, resultAsXml));
  742.     }
  743.     public void evaluate(Document source, InputStream xquery, Node out) throws XQueryException, XQueryNotValidException, XQueryEvaluateException, XQueryEvaluateNotFoundException{
  744.         this._evaluate(this._buildXdmNode(source), this._buildEvaluator(xquery), this._buildDestination(out, AbstractXQueryExpressionEngine.DEFAULT_RESULT_AS_XML));
  745.     }
  746.     public void evaluate(Document source, InputStream xquery, Node out, boolean resultAsXml) throws XQueryException, XQueryNotValidException, XQueryEvaluateException, XQueryEvaluateNotFoundException{
  747.         this._evaluate(this._buildXdmNode(source), this._buildEvaluator(xquery), this._buildDestination(out, resultAsXml));
  748.     }
  749.     public void evaluate(Document source, Reader xquery, Node out) throws XQueryException, XQueryNotValidException, XQueryEvaluateException, XQueryEvaluateNotFoundException{
  750.         this._evaluate(this._buildXdmNode(source), this._buildEvaluator(xquery), this._buildDestination(out, AbstractXQueryExpressionEngine.DEFAULT_RESULT_AS_XML));
  751.     }
  752.     public void evaluate(Document source, Reader xquery, Node out, boolean resultAsXml) throws XQueryException, XQueryNotValidException, XQueryEvaluateException, XQueryEvaluateNotFoundException{
  753.         this._evaluate(this._buildXdmNode(source), this._buildEvaluator(xquery), this._buildDestination(out, resultAsXml));
  754.     }
  755.    
  756.    
  757.    
  758.     /* ***** PUBLIC METHOD (SRC as InputStream) ***** */
  759.    
  760.     // Destination: String
  761.     public String evaluate(InputStream source, String xquery) throws XQueryException, XQueryNotValidException, XQueryEvaluateException, XQueryEvaluateNotFoundException{
  762.         return this.evaluate(source, xquery, AbstractXQueryExpressionEngine.DEFAULT_RESULT_AS_XML);
  763.     }
  764.     public String evaluate(InputStream source, String xquery, boolean resultAsXml) throws XQueryException, XQueryNotValidException, XQueryEvaluateException, XQueryEvaluateNotFoundException{
  765.         try{
  766.             ByteArrayOutputStream bout = new ByteArrayOutputStream();
  767.             this.evaluate(source, xquery, bout,resultAsXml);
  768.             bout.flush();
  769.             bout.close();
  770.             return bout.toString();
  771.         }catch(XQueryException e){
  772.             throw e;
  773.         }catch(XQueryNotValidException e){
  774.             throw e;
  775.         }catch(XQueryEvaluateException e){
  776.             throw e;
  777.         }catch(XQueryEvaluateNotFoundException e){
  778.             throw e;
  779.         }catch(Exception e){
  780.             throw new XQueryException(e.getMessage(),e);
  781.         }
  782.     }
  783.     public String evaluate(InputStream source, File xquery) throws XQueryException, XQueryNotValidException, XQueryEvaluateException, XQueryEvaluateNotFoundException{
  784.         return this.evaluate(source, xquery, AbstractXQueryExpressionEngine.DEFAULT_RESULT_AS_XML);
  785.     }
  786.     public String evaluate(InputStream source, File xquery, boolean resultAsXml) throws XQueryException, XQueryNotValidException, XQueryEvaluateException, XQueryEvaluateNotFoundException{
  787.         try{
  788.             ByteArrayOutputStream bout = new ByteArrayOutputStream();
  789.             this.evaluate(source, xquery, bout, resultAsXml);
  790.             bout.flush();
  791.             bout.close();
  792.             return bout.toString();
  793.         }catch(XQueryException e){
  794.             throw e;
  795.         }catch(XQueryNotValidException e){
  796.             throw e;
  797.         }catch(XQueryEvaluateException e){
  798.             throw e;
  799.         }catch(XQueryEvaluateNotFoundException e){
  800.             throw e;
  801.         }catch(Exception e){
  802.             throw new XQueryException(e.getMessage(),e);
  803.         }
  804.     }
  805.     public String evaluate(InputStream source, InputStream xquery) throws XQueryException, XQueryNotValidException, XQueryEvaluateException, XQueryEvaluateNotFoundException{
  806.         return this.evaluate(source, xquery, AbstractXQueryExpressionEngine.DEFAULT_RESULT_AS_XML);
  807.     }
  808.     public String evaluate(InputStream source, InputStream xquery, boolean resultAsXml) throws XQueryException, XQueryNotValidException, XQueryEvaluateException, XQueryEvaluateNotFoundException{
  809.         try{
  810.             ByteArrayOutputStream bout = new ByteArrayOutputStream();
  811.             this.evaluate(source, xquery, bout, resultAsXml);
  812.             bout.flush();
  813.             bout.close();
  814.             return bout.toString();
  815.         }catch(XQueryException e){
  816.             throw e;
  817.         }catch(XQueryNotValidException e){
  818.             throw e;
  819.         }catch(XQueryEvaluateException e){
  820.             throw e;
  821.         }catch(XQueryEvaluateNotFoundException e){
  822.             throw e;
  823.         }catch(Exception e){
  824.             throw new XQueryException(e.getMessage(),e);
  825.         }
  826.     }
  827.     public String evaluate(InputStream source, Reader xquery) throws XQueryException, XQueryNotValidException, XQueryEvaluateException, XQueryEvaluateNotFoundException{
  828.         return this.evaluate(source, xquery, AbstractXQueryExpressionEngine.DEFAULT_RESULT_AS_XML);
  829.     }
  830.     public String evaluate(InputStream source, Reader xquery, boolean resultAsXml) throws XQueryException, XQueryNotValidException, XQueryEvaluateException, XQueryEvaluateNotFoundException{
  831.         try{
  832.             ByteArrayOutputStream bout = new ByteArrayOutputStream();
  833.             this.evaluate(source, xquery, bout, resultAsXml);
  834.             bout.flush();
  835.             bout.close();
  836.             return bout.toString();
  837.         }catch(XQueryException e){
  838.             throw e;
  839.         }catch(XQueryNotValidException e){
  840.             throw e;
  841.         }catch(XQueryEvaluateException e){
  842.             throw e;
  843.         }catch(XQueryEvaluateNotFoundException e){
  844.             throw e;
  845.         }catch(Exception e){
  846.             throw new XQueryException(e.getMessage(),e);
  847.         }
  848.     }
  849.    
  850.     // Destination: OutputStream
  851.     public void evaluate(InputStream source, String xquery, OutputStream out) throws XQueryException, XQueryNotValidException, XQueryEvaluateException, XQueryEvaluateNotFoundException{
  852.         this._evaluate(this._buildXdmNode(source), this._buildEvaluator(xquery), this._buildDestination(out, AbstractXQueryExpressionEngine.DEFAULT_RESULT_AS_XML));
  853.     }
  854.     public void evaluate(InputStream source, String xquery, OutputStream out, boolean resultAsXml) throws XQueryException, XQueryNotValidException, XQueryEvaluateException, XQueryEvaluateNotFoundException{
  855.         this._evaluate(this._buildXdmNode(source), this._buildEvaluator(xquery), this._buildDestination(out, resultAsXml));
  856.     }
  857.     public void evaluate(InputStream source, File xquery, OutputStream out) throws XQueryException, XQueryNotValidException, XQueryEvaluateException, XQueryEvaluateNotFoundException{
  858.         this._evaluate(this._buildXdmNode(source), this._buildEvaluator(xquery), this._buildDestination(out, AbstractXQueryExpressionEngine.DEFAULT_RESULT_AS_XML));
  859.     }
  860.     public void evaluate(InputStream source, File xquery, OutputStream out, boolean resultAsXml) throws XQueryException, XQueryNotValidException, XQueryEvaluateException, XQueryEvaluateNotFoundException{
  861.         this._evaluate(this._buildXdmNode(source), this._buildEvaluator(xquery), this._buildDestination(out, resultAsXml));
  862.     }
  863.     public void evaluate(InputStream source, InputStream xquery, OutputStream out) throws XQueryException, XQueryNotValidException, XQueryEvaluateException, XQueryEvaluateNotFoundException{
  864.         this._evaluate(this._buildXdmNode(source), this._buildEvaluator(xquery), this._buildDestination(out, AbstractXQueryExpressionEngine.DEFAULT_RESULT_AS_XML));
  865.     }
  866.     public void evaluate(InputStream source, InputStream xquery, OutputStream out, boolean resultAsXml) throws XQueryException, XQueryNotValidException, XQueryEvaluateException, XQueryEvaluateNotFoundException{
  867.         this._evaluate(this._buildXdmNode(source), this._buildEvaluator(xquery), this._buildDestination(out, resultAsXml));
  868.     }
  869.     public void evaluate(InputStream source, Reader xquery, OutputStream out) throws XQueryException, XQueryNotValidException, XQueryEvaluateException, XQueryEvaluateNotFoundException{
  870.         this._evaluate(this._buildXdmNode(source), this._buildEvaluator(xquery), this._buildDestination(out, AbstractXQueryExpressionEngine.DEFAULT_RESULT_AS_XML));
  871.     }
  872.     public void evaluate(InputStream source, Reader xquery, OutputStream out, boolean resultAsXml) throws XQueryException, XQueryNotValidException, XQueryEvaluateException, XQueryEvaluateNotFoundException{
  873.         this._evaluate(this._buildXdmNode(source), this._buildEvaluator(xquery), this._buildDestination(out, resultAsXml));
  874.     }
  875.    
  876.     // Destination: Writer
  877.     public void evaluate(InputStream source, String xquery, Writer out) throws XQueryException, XQueryNotValidException, XQueryEvaluateException, XQueryEvaluateNotFoundException{
  878.         this._evaluate(this._buildXdmNode(source), this._buildEvaluator(xquery), this._buildDestination(out, AbstractXQueryExpressionEngine.DEFAULT_RESULT_AS_XML));
  879.     }
  880.     public void evaluate(InputStream source, String xquery, Writer out, boolean resultAsXml) throws XQueryException, XQueryNotValidException, XQueryEvaluateException, XQueryEvaluateNotFoundException{
  881.         this._evaluate(this._buildXdmNode(source), this._buildEvaluator(xquery), this._buildDestination(out, resultAsXml));
  882.     }
  883.     public void evaluate(InputStream source, File xquery, Writer out) throws XQueryException, XQueryNotValidException, XQueryEvaluateException, XQueryEvaluateNotFoundException{
  884.         this._evaluate(this._buildXdmNode(source), this._buildEvaluator(xquery), this._buildDestination(out, AbstractXQueryExpressionEngine.DEFAULT_RESULT_AS_XML));
  885.     }
  886.     public void evaluate(InputStream source, File xquery, Writer out, boolean resultAsXml) throws XQueryException, XQueryNotValidException, XQueryEvaluateException, XQueryEvaluateNotFoundException{
  887.         this._evaluate(this._buildXdmNode(source), this._buildEvaluator(xquery), this._buildDestination(out, resultAsXml));
  888.     }
  889.     public void evaluate(InputStream source, InputStream xquery, Writer out) throws XQueryException, XQueryNotValidException, XQueryEvaluateException, XQueryEvaluateNotFoundException{
  890.         this._evaluate(this._buildXdmNode(source), this._buildEvaluator(xquery), this._buildDestination(out, AbstractXQueryExpressionEngine.DEFAULT_RESULT_AS_XML));
  891.     }
  892.     public void evaluate(InputStream source, InputStream xquery, Writer out, boolean resultAsXml) throws XQueryException, XQueryNotValidException, XQueryEvaluateException, XQueryEvaluateNotFoundException{
  893.         this._evaluate(this._buildXdmNode(source), this._buildEvaluator(xquery), this._buildDestination(out, resultAsXml));
  894.     }
  895.     public void evaluate(InputStream source, Reader xquery, Writer out) throws XQueryException, XQueryNotValidException, XQueryEvaluateException, XQueryEvaluateNotFoundException{
  896.         this._evaluate(this._buildXdmNode(source), this._buildEvaluator(xquery), this._buildDestination(out, AbstractXQueryExpressionEngine.DEFAULT_RESULT_AS_XML));
  897.     }
  898.     public void evaluate(InputStream source, Reader xquery, Writer out, boolean resultAsXml) throws XQueryException, XQueryNotValidException, XQueryEvaluateException, XQueryEvaluateNotFoundException{
  899.         this._evaluate(this._buildXdmNode(source), this._buildEvaluator(xquery), this._buildDestination(out, resultAsXml));
  900.     }
  901.    
  902.     // Destination: File
  903.     public void evaluate(InputStream source, String xquery, File out) throws XQueryException, XQueryNotValidException, XQueryEvaluateException, XQueryEvaluateNotFoundException{
  904.         this._evaluate(this._buildXdmNode(source), this._buildEvaluator(xquery), this._buildDestination(out, AbstractXQueryExpressionEngine.DEFAULT_RESULT_AS_XML));
  905.     }
  906.     public void evaluate(InputStream source, String xquery, File out, boolean resultAsXml) throws XQueryException, XQueryNotValidException, XQueryEvaluateException, XQueryEvaluateNotFoundException{
  907.         this._evaluate(this._buildXdmNode(source), this._buildEvaluator(xquery), this._buildDestination(out, resultAsXml));
  908.     }
  909.     public void evaluate(InputStream source, File xquery, File out) throws XQueryException, XQueryNotValidException, XQueryEvaluateException, XQueryEvaluateNotFoundException{
  910.         this._evaluate(this._buildXdmNode(source), this._buildEvaluator(xquery), this._buildDestination(out, AbstractXQueryExpressionEngine.DEFAULT_RESULT_AS_XML));
  911.     }
  912.     public void evaluate(InputStream source, File xquery, File out, boolean resultAsXml) throws XQueryException, XQueryNotValidException, XQueryEvaluateException, XQueryEvaluateNotFoundException{
  913.         this._evaluate(this._buildXdmNode(source), this._buildEvaluator(xquery), this._buildDestination(out, resultAsXml));
  914.     }
  915.     public void evaluate(InputStream source, InputStream xquery, File out) throws XQueryException, XQueryNotValidException, XQueryEvaluateException, XQueryEvaluateNotFoundException{
  916.         this._evaluate(this._buildXdmNode(source), this._buildEvaluator(xquery), this._buildDestination(out, AbstractXQueryExpressionEngine.DEFAULT_RESULT_AS_XML));
  917.     }
  918.     public void evaluate(InputStream source, InputStream xquery, File out, boolean resultAsXml) throws XQueryException, XQueryNotValidException, XQueryEvaluateException, XQueryEvaluateNotFoundException{
  919.         this._evaluate(this._buildXdmNode(source), this._buildEvaluator(xquery), this._buildDestination(out, resultAsXml));
  920.     }
  921.     public void evaluate(InputStream source, Reader xquery, File out) throws XQueryException, XQueryNotValidException, XQueryEvaluateException, XQueryEvaluateNotFoundException{
  922.         this._evaluate(this._buildXdmNode(source), this._buildEvaluator(xquery), this._buildDestination(out, AbstractXQueryExpressionEngine.DEFAULT_RESULT_AS_XML));
  923.     }
  924.     public void evaluate(InputStream source, Reader xquery, File out, boolean resultAsXml) throws XQueryException, XQueryNotValidException, XQueryEvaluateException, XQueryEvaluateNotFoundException{
  925.         this._evaluate(this._buildXdmNode(source), this._buildEvaluator(xquery), this._buildDestination(out, resultAsXml));
  926.     }
  927.    
  928.     // Destination: Node
  929.     public void evaluate(InputStream source, String xquery, Node out) throws XQueryException, XQueryNotValidException, XQueryEvaluateException, XQueryEvaluateNotFoundException{
  930.         this._evaluate(this._buildXdmNode(source), this._buildEvaluator(xquery), this._buildDestination(out, AbstractXQueryExpressionEngine.DEFAULT_RESULT_AS_XML));
  931.     }
  932.     public void evaluate(InputStream source, String xquery, Node out, boolean resultAsXml) throws XQueryException, XQueryNotValidException, XQueryEvaluateException, XQueryEvaluateNotFoundException{
  933.         this._evaluate(this._buildXdmNode(source), this._buildEvaluator(xquery), this._buildDestination(out, resultAsXml));
  934.     }
  935.     public void evaluate(InputStream source, File xquery, Node out) throws XQueryException, XQueryNotValidException, XQueryEvaluateException, XQueryEvaluateNotFoundException{
  936.         this._evaluate(this._buildXdmNode(source), this._buildEvaluator(xquery), this._buildDestination(out, AbstractXQueryExpressionEngine.DEFAULT_RESULT_AS_XML));
  937.     }
  938.     public void evaluate(InputStream source, File xquery, Node out, boolean resultAsXml) throws XQueryException, XQueryNotValidException, XQueryEvaluateException, XQueryEvaluateNotFoundException{
  939.         this._evaluate(this._buildXdmNode(source), this._buildEvaluator(xquery), this._buildDestination(out, resultAsXml));
  940.     }
  941.     public void evaluate(InputStream source, InputStream xquery, Node out) throws XQueryException, XQueryNotValidException, XQueryEvaluateException, XQueryEvaluateNotFoundException{
  942.         this._evaluate(this._buildXdmNode(source), this._buildEvaluator(xquery), this._buildDestination(out, AbstractXQueryExpressionEngine.DEFAULT_RESULT_AS_XML));
  943.     }
  944.     public void evaluate(InputStream source, InputStream xquery, Node out, boolean resultAsXml) throws XQueryException, XQueryNotValidException, XQueryEvaluateException, XQueryEvaluateNotFoundException{
  945.         this._evaluate(this._buildXdmNode(source), this._buildEvaluator(xquery), this._buildDestination(out, resultAsXml));
  946.     }
  947.     public void evaluate(InputStream source, Reader xquery, Node out) throws XQueryException, XQueryNotValidException, XQueryEvaluateException, XQueryEvaluateNotFoundException{
  948.         this._evaluate(this._buildXdmNode(source), this._buildEvaluator(xquery), this._buildDestination(out, AbstractXQueryExpressionEngine.DEFAULT_RESULT_AS_XML));
  949.     }
  950.     public void evaluate(InputStream source, Reader xquery, Node out, boolean resultAsXml) throws XQueryException, XQueryNotValidException, XQueryEvaluateException, XQueryEvaluateNotFoundException{
  951.         this._evaluate(this._buildXdmNode(source), this._buildEvaluator(xquery), this._buildDestination(out, resultAsXml));
  952.     }
  953.    
  954.    
  955.    
  956.    
  957.     /* ***** PUBLIC METHOD (SRC as Reader) ***** */
  958.    
  959.     // Destination: String
  960.     public String evaluate(Reader source, String xquery) throws XQueryException, XQueryNotValidException, XQueryEvaluateException, XQueryEvaluateNotFoundException{
  961.         return this.evaluate(source, xquery, AbstractXQueryExpressionEngine.DEFAULT_RESULT_AS_XML);
  962.     }
  963.     public String evaluate(Reader source, String xquery, boolean resultAsXml) throws XQueryException, XQueryNotValidException, XQueryEvaluateException, XQueryEvaluateNotFoundException{
  964.         try{
  965.             ByteArrayOutputStream bout = new ByteArrayOutputStream();
  966.             this.evaluate(source, xquery, bout,resultAsXml);
  967.             bout.flush();
  968.             bout.close();
  969.             return bout.toString();
  970.         }catch(XQueryException e){
  971.             throw e;
  972.         }catch(XQueryNotValidException e){
  973.             throw e;
  974.         }catch(XQueryEvaluateException e){
  975.             throw e;
  976.         }catch(XQueryEvaluateNotFoundException e){
  977.             throw e;
  978.         }catch(Exception e){
  979.             throw new XQueryException(e.getMessage(),e);
  980.         }
  981.     }
  982.     public String evaluate(Reader source, File xquery) throws XQueryException, XQueryNotValidException, XQueryEvaluateException, XQueryEvaluateNotFoundException{
  983.         return this.evaluate(source, xquery, AbstractXQueryExpressionEngine.DEFAULT_RESULT_AS_XML);
  984.     }
  985.     public String evaluate(Reader source, File xquery, boolean resultAsXml) throws XQueryException, XQueryNotValidException, XQueryEvaluateException, XQueryEvaluateNotFoundException{
  986.         try{
  987.             ByteArrayOutputStream bout = new ByteArrayOutputStream();
  988.             this.evaluate(source, xquery, bout, resultAsXml);
  989.             bout.flush();
  990.             bout.close();
  991.             return bout.toString();
  992.         }catch(XQueryException e){
  993.             throw e;
  994.         }catch(XQueryNotValidException e){
  995.             throw e;
  996.         }catch(XQueryEvaluateException e){
  997.             throw e;
  998.         }catch(XQueryEvaluateNotFoundException e){
  999.             throw e;
  1000.         }catch(Exception e){
  1001.             throw new XQueryException(e.getMessage(),e);
  1002.         }
  1003.     }
  1004.     public String evaluate(Reader source, InputStream xquery) throws XQueryException, XQueryNotValidException, XQueryEvaluateException, XQueryEvaluateNotFoundException{
  1005.         return this.evaluate(source, xquery, AbstractXQueryExpressionEngine.DEFAULT_RESULT_AS_XML);
  1006.     }
  1007.     public String evaluate(Reader source, InputStream xquery, boolean resultAsXml) throws XQueryException, XQueryNotValidException, XQueryEvaluateException, XQueryEvaluateNotFoundException{
  1008.         try{
  1009.             ByteArrayOutputStream bout = new ByteArrayOutputStream();
  1010.             this.evaluate(source, xquery, bout, resultAsXml);
  1011.             bout.flush();
  1012.             bout.close();
  1013.             return bout.toString();
  1014.         }catch(XQueryException e){
  1015.             throw e;
  1016.         }catch(XQueryNotValidException e){
  1017.             throw e;
  1018.         }catch(XQueryEvaluateException e){
  1019.             throw e;
  1020.         }catch(XQueryEvaluateNotFoundException e){
  1021.             throw e;
  1022.         }catch(Exception e){
  1023.             throw new XQueryException(e.getMessage(),e);
  1024.         }
  1025.     }
  1026.     public String evaluate(Reader source, Reader xquery) throws XQueryException, XQueryNotValidException, XQueryEvaluateException, XQueryEvaluateNotFoundException{
  1027.         return this.evaluate(source, xquery, AbstractXQueryExpressionEngine.DEFAULT_RESULT_AS_XML);
  1028.     }
  1029.     public String evaluate(Reader source, Reader xquery, boolean resultAsXml) throws XQueryException, XQueryNotValidException, XQueryEvaluateException, XQueryEvaluateNotFoundException{
  1030.         try{
  1031.             ByteArrayOutputStream bout = new ByteArrayOutputStream();
  1032.             this.evaluate(source, xquery, bout, resultAsXml);
  1033.             bout.flush();
  1034.             bout.close();
  1035.             return bout.toString();
  1036.         }catch(XQueryException e){
  1037.             throw e;
  1038.         }catch(XQueryNotValidException e){
  1039.             throw e;
  1040.         }catch(XQueryEvaluateException e){
  1041.             throw e;
  1042.         }catch(XQueryEvaluateNotFoundException e){
  1043.             throw e;
  1044.         }catch(Exception e){
  1045.             throw new XQueryException(e.getMessage(),e);
  1046.         }
  1047.     }
  1048.    
  1049.     // Destination: OutputStream
  1050.     public void evaluate(Reader source, String xquery, OutputStream out) throws XQueryException, XQueryNotValidException, XQueryEvaluateException, XQueryEvaluateNotFoundException{
  1051.         this._evaluate(this._buildXdmNode(source), this._buildEvaluator(xquery), this._buildDestination(out, AbstractXQueryExpressionEngine.DEFAULT_RESULT_AS_XML));
  1052.     }
  1053.     public void evaluate(Reader source, String xquery, OutputStream out, boolean resultAsXml) throws XQueryException, XQueryNotValidException, XQueryEvaluateException, XQueryEvaluateNotFoundException{
  1054.         this._evaluate(this._buildXdmNode(source), this._buildEvaluator(xquery), this._buildDestination(out, resultAsXml));
  1055.     }
  1056.     public void evaluate(Reader source, File xquery, OutputStream out) throws XQueryException, XQueryNotValidException, XQueryEvaluateException, XQueryEvaluateNotFoundException{
  1057.         this._evaluate(this._buildXdmNode(source), this._buildEvaluator(xquery), this._buildDestination(out, AbstractXQueryExpressionEngine.DEFAULT_RESULT_AS_XML));
  1058.     }
  1059.     public void evaluate(Reader source, File xquery, OutputStream out, boolean resultAsXml) throws XQueryException, XQueryNotValidException, XQueryEvaluateException, XQueryEvaluateNotFoundException{
  1060.         this._evaluate(this._buildXdmNode(source), this._buildEvaluator(xquery), this._buildDestination(out, resultAsXml));
  1061.     }
  1062.     public void evaluate(Reader source, InputStream xquery, OutputStream out) throws XQueryException, XQueryNotValidException, XQueryEvaluateException, XQueryEvaluateNotFoundException{
  1063.         this._evaluate(this._buildXdmNode(source), this._buildEvaluator(xquery), this._buildDestination(out, AbstractXQueryExpressionEngine.DEFAULT_RESULT_AS_XML));
  1064.     }
  1065.     public void evaluate(Reader source, InputStream xquery, OutputStream out, boolean resultAsXml) throws XQueryException, XQueryNotValidException, XQueryEvaluateException, XQueryEvaluateNotFoundException{
  1066.         this._evaluate(this._buildXdmNode(source), this._buildEvaluator(xquery), this._buildDestination(out, resultAsXml));
  1067.     }
  1068.     public void evaluate(Reader source, Reader xquery, OutputStream out) throws XQueryException, XQueryNotValidException, XQueryEvaluateException, XQueryEvaluateNotFoundException{
  1069.         this._evaluate(this._buildXdmNode(source), this._buildEvaluator(xquery), this._buildDestination(out, AbstractXQueryExpressionEngine.DEFAULT_RESULT_AS_XML));
  1070.     }
  1071.     public void evaluate(Reader source, Reader xquery, OutputStream out, boolean resultAsXml) throws XQueryException, XQueryNotValidException, XQueryEvaluateException, XQueryEvaluateNotFoundException{
  1072.         this._evaluate(this._buildXdmNode(source), this._buildEvaluator(xquery), this._buildDestination(out, resultAsXml));
  1073.     }
  1074.    
  1075.     // Destination: Writer
  1076.     public void evaluate(Reader source, String xquery, Writer out) throws XQueryException, XQueryNotValidException, XQueryEvaluateException, XQueryEvaluateNotFoundException{
  1077.         this._evaluate(this._buildXdmNode(source), this._buildEvaluator(xquery), this._buildDestination(out, AbstractXQueryExpressionEngine.DEFAULT_RESULT_AS_XML));
  1078.     }
  1079.     public void evaluate(Reader source, String xquery, Writer out, boolean resultAsXml) throws XQueryException, XQueryNotValidException, XQueryEvaluateException, XQueryEvaluateNotFoundException{
  1080.         this._evaluate(this._buildXdmNode(source), this._buildEvaluator(xquery), this._buildDestination(out, resultAsXml));
  1081.     }
  1082.     public void evaluate(Reader source, File xquery, Writer out) throws XQueryException, XQueryNotValidException, XQueryEvaluateException, XQueryEvaluateNotFoundException{
  1083.         this._evaluate(this._buildXdmNode(source), this._buildEvaluator(xquery), this._buildDestination(out, AbstractXQueryExpressionEngine.DEFAULT_RESULT_AS_XML));
  1084.     }
  1085.     public void evaluate(Reader source, File xquery, Writer out, boolean resultAsXml) throws XQueryException, XQueryNotValidException, XQueryEvaluateException, XQueryEvaluateNotFoundException{
  1086.         this._evaluate(this._buildXdmNode(source), this._buildEvaluator(xquery), this._buildDestination(out, resultAsXml));
  1087.     }
  1088.     public void evaluate(Reader source, InputStream xquery, Writer out) throws XQueryException, XQueryNotValidException, XQueryEvaluateException, XQueryEvaluateNotFoundException{
  1089.         this._evaluate(this._buildXdmNode(source), this._buildEvaluator(xquery), this._buildDestination(out, AbstractXQueryExpressionEngine.DEFAULT_RESULT_AS_XML));
  1090.     }
  1091.     public void evaluate(Reader source, InputStream xquery, Writer out, boolean resultAsXml) throws XQueryException, XQueryNotValidException, XQueryEvaluateException, XQueryEvaluateNotFoundException{
  1092.         this._evaluate(this._buildXdmNode(source), this._buildEvaluator(xquery), this._buildDestination(out, resultAsXml));
  1093.     }
  1094.     public void evaluate(Reader source, Reader xquery, Writer out) throws XQueryException, XQueryNotValidException, XQueryEvaluateException, XQueryEvaluateNotFoundException{
  1095.         this._evaluate(this._buildXdmNode(source), this._buildEvaluator(xquery), this._buildDestination(out, AbstractXQueryExpressionEngine.DEFAULT_RESULT_AS_XML));
  1096.     }
  1097.     public void evaluate(Reader source, Reader xquery, Writer out, boolean resultAsXml) throws XQueryException, XQueryNotValidException, XQueryEvaluateException, XQueryEvaluateNotFoundException{
  1098.         this._evaluate(this._buildXdmNode(source), this._buildEvaluator(xquery), this._buildDestination(out, resultAsXml));
  1099.     }
  1100.    
  1101.     // Destination: File
  1102.     public void evaluate(Reader source, String xquery, File out) throws XQueryException, XQueryNotValidException, XQueryEvaluateException, XQueryEvaluateNotFoundException{
  1103.         this._evaluate(this._buildXdmNode(source), this._buildEvaluator(xquery), this._buildDestination(out, AbstractXQueryExpressionEngine.DEFAULT_RESULT_AS_XML));
  1104.     }
  1105.     public void evaluate(Reader source, String xquery, File out, boolean resultAsXml) throws XQueryException, XQueryNotValidException, XQueryEvaluateException, XQueryEvaluateNotFoundException{
  1106.         this._evaluate(this._buildXdmNode(source), this._buildEvaluator(xquery), this._buildDestination(out, resultAsXml));
  1107.     }
  1108.     public void evaluate(Reader source, File xquery, File out) throws XQueryException, XQueryNotValidException, XQueryEvaluateException, XQueryEvaluateNotFoundException{
  1109.         this._evaluate(this._buildXdmNode(source), this._buildEvaluator(xquery), this._buildDestination(out, AbstractXQueryExpressionEngine.DEFAULT_RESULT_AS_XML));
  1110.     }
  1111.     public void evaluate(Reader source, File xquery, File out, boolean resultAsXml) throws XQueryException, XQueryNotValidException, XQueryEvaluateException, XQueryEvaluateNotFoundException{
  1112.         this._evaluate(this._buildXdmNode(source), this._buildEvaluator(xquery), this._buildDestination(out, resultAsXml));
  1113.     }
  1114.     public void evaluate(Reader source, InputStream xquery, File out) throws XQueryException, XQueryNotValidException, XQueryEvaluateException, XQueryEvaluateNotFoundException{
  1115.         this._evaluate(this._buildXdmNode(source), this._buildEvaluator(xquery), this._buildDestination(out, AbstractXQueryExpressionEngine.DEFAULT_RESULT_AS_XML));
  1116.     }
  1117.     public void evaluate(Reader source, InputStream xquery, File out, boolean resultAsXml) throws XQueryException, XQueryNotValidException, XQueryEvaluateException, XQueryEvaluateNotFoundException{
  1118.         this._evaluate(this._buildXdmNode(source), this._buildEvaluator(xquery), this._buildDestination(out, resultAsXml));
  1119.     }
  1120.     public void evaluate(Reader source, Reader xquery, File out) throws XQueryException, XQueryNotValidException, XQueryEvaluateException, XQueryEvaluateNotFoundException{
  1121.         this._evaluate(this._buildXdmNode(source), this._buildEvaluator(xquery), this._buildDestination(out, AbstractXQueryExpressionEngine.DEFAULT_RESULT_AS_XML));
  1122.     }
  1123.     public void evaluate(Reader source, Reader xquery, File out, boolean resultAsXml) throws XQueryException, XQueryNotValidException, XQueryEvaluateException, XQueryEvaluateNotFoundException{
  1124.         this._evaluate(this._buildXdmNode(source), this._buildEvaluator(xquery), this._buildDestination(out, resultAsXml));
  1125.     }
  1126.    
  1127.     // Destination: Node
  1128.     public void evaluate(Reader source, String xquery, Node out) throws XQueryException, XQueryNotValidException, XQueryEvaluateException, XQueryEvaluateNotFoundException{
  1129.         this._evaluate(this._buildXdmNode(source), this._buildEvaluator(xquery), this._buildDestination(out, AbstractXQueryExpressionEngine.DEFAULT_RESULT_AS_XML));
  1130.     }
  1131.     public void evaluate(Reader source, String xquery, Node out, boolean resultAsXml) throws XQueryException, XQueryNotValidException, XQueryEvaluateException, XQueryEvaluateNotFoundException{
  1132.         this._evaluate(this._buildXdmNode(source), this._buildEvaluator(xquery), this._buildDestination(out, resultAsXml));
  1133.     }
  1134.     public void evaluate(Reader source, File xquery, Node out) throws XQueryException, XQueryNotValidException, XQueryEvaluateException, XQueryEvaluateNotFoundException{
  1135.         this._evaluate(this._buildXdmNode(source), this._buildEvaluator(xquery), this._buildDestination(out, AbstractXQueryExpressionEngine.DEFAULT_RESULT_AS_XML));
  1136.     }
  1137.     public void evaluate(Reader source, File xquery, Node out, boolean resultAsXml) throws XQueryException, XQueryNotValidException, XQueryEvaluateException, XQueryEvaluateNotFoundException{
  1138.         this._evaluate(this._buildXdmNode(source), this._buildEvaluator(xquery), this._buildDestination(out, resultAsXml));
  1139.     }
  1140.     public void evaluate(Reader source, InputStream xquery, Node out) throws XQueryException, XQueryNotValidException, XQueryEvaluateException, XQueryEvaluateNotFoundException{
  1141.         this._evaluate(this._buildXdmNode(source), this._buildEvaluator(xquery), this._buildDestination(out, AbstractXQueryExpressionEngine.DEFAULT_RESULT_AS_XML));
  1142.     }
  1143.     public void evaluate(Reader source, InputStream xquery, Node out, boolean resultAsXml) throws XQueryException, XQueryNotValidException, XQueryEvaluateException, XQueryEvaluateNotFoundException{
  1144.         this._evaluate(this._buildXdmNode(source), this._buildEvaluator(xquery), this._buildDestination(out, resultAsXml));
  1145.     }
  1146.     public void evaluate(Reader source, Reader xquery, Node out) throws XQueryException, XQueryNotValidException, XQueryEvaluateException, XQueryEvaluateNotFoundException{
  1147.         this._evaluate(this._buildXdmNode(source), this._buildEvaluator(xquery), this._buildDestination(out, AbstractXQueryExpressionEngine.DEFAULT_RESULT_AS_XML));
  1148.     }
  1149.     public void evaluate(Reader source, Reader xquery, Node out, boolean resultAsXml) throws XQueryException, XQueryNotValidException, XQueryEvaluateException, XQueryEvaluateNotFoundException{
  1150.         this._evaluate(this._buildXdmNode(source), this._buildEvaluator(xquery), this._buildDestination(out, resultAsXml));
  1151.     }
  1152.    
  1153.    
  1154.     /* ***** PUBLIC METHOD (SRC as File) ***** */
  1155.    
  1156.     // Destination: String
  1157.     public String evaluate(File source, String xquery) throws XQueryException, XQueryNotValidException, XQueryEvaluateException, XQueryEvaluateNotFoundException{
  1158.         return this.evaluate(source, xquery, AbstractXQueryExpressionEngine.DEFAULT_RESULT_AS_XML);
  1159.     }
  1160.     public String evaluate(File source, String xquery, boolean resultAsXml) throws XQueryException, XQueryNotValidException, XQueryEvaluateException, XQueryEvaluateNotFoundException{
  1161.         try{
  1162.             ByteArrayOutputStream bout = new ByteArrayOutputStream();
  1163.             this.evaluate(source, xquery, bout,resultAsXml);
  1164.             bout.flush();
  1165.             bout.close();
  1166.             return bout.toString();
  1167.         }catch(XQueryException e){
  1168.             throw e;
  1169.         }catch(XQueryNotValidException e){
  1170.             throw e;
  1171.         }catch(XQueryEvaluateException e){
  1172.             throw e;
  1173.         }catch(XQueryEvaluateNotFoundException e){
  1174.             throw e;
  1175.         }catch(Exception e){
  1176.             throw new XQueryException(e.getMessage(),e);
  1177.         }
  1178.     }
  1179.     public String evaluate(File source, File xquery) throws XQueryException, XQueryNotValidException, XQueryEvaluateException, XQueryEvaluateNotFoundException{
  1180.         return this.evaluate(source, xquery, AbstractXQueryExpressionEngine.DEFAULT_RESULT_AS_XML);
  1181.     }
  1182.     public String evaluate(File source, File xquery, boolean resultAsXml) throws XQueryException, XQueryNotValidException, XQueryEvaluateException, XQueryEvaluateNotFoundException{
  1183.         try{
  1184.             ByteArrayOutputStream bout = new ByteArrayOutputStream();
  1185.             this.evaluate(source, xquery, bout, resultAsXml);
  1186.             bout.flush();
  1187.             bout.close();
  1188.             return bout.toString();
  1189.         }catch(XQueryException e){
  1190.             throw e;
  1191.         }catch(XQueryNotValidException e){
  1192.             throw e;
  1193.         }catch(XQueryEvaluateException e){
  1194.             throw e;
  1195.         }catch(XQueryEvaluateNotFoundException e){
  1196.             throw e;
  1197.         }catch(Exception e){
  1198.             throw new XQueryException(e.getMessage(),e);
  1199.         }
  1200.     }
  1201.     public String evaluate(File source, InputStream xquery) throws XQueryException, XQueryNotValidException, XQueryEvaluateException, XQueryEvaluateNotFoundException{
  1202.         return this.evaluate(source, xquery, AbstractXQueryExpressionEngine.DEFAULT_RESULT_AS_XML);
  1203.     }
  1204.     public String evaluate(File source, InputStream xquery, boolean resultAsXml) throws XQueryException, XQueryNotValidException, XQueryEvaluateException, XQueryEvaluateNotFoundException{
  1205.         try{
  1206.             ByteArrayOutputStream bout = new ByteArrayOutputStream();
  1207.             this.evaluate(source, xquery, bout, resultAsXml);
  1208.             bout.flush();
  1209.             bout.close();
  1210.             return bout.toString();
  1211.         }catch(XQueryException e){
  1212.             throw e;
  1213.         }catch(XQueryNotValidException e){
  1214.             throw e;
  1215.         }catch(XQueryEvaluateException e){
  1216.             throw e;
  1217.         }catch(XQueryEvaluateNotFoundException e){
  1218.             throw e;
  1219.         }catch(Exception e){
  1220.             throw new XQueryException(e.getMessage(),e);
  1221.         }
  1222.     }
  1223.     public String evaluate(File source, Reader xquery) throws XQueryException, XQueryNotValidException, XQueryEvaluateException, XQueryEvaluateNotFoundException{
  1224.         return this.evaluate(source, xquery, AbstractXQueryExpressionEngine.DEFAULT_RESULT_AS_XML);
  1225.     }
  1226.     public String evaluate(File source, Reader xquery, boolean resultAsXml) throws XQueryException, XQueryNotValidException, XQueryEvaluateException, XQueryEvaluateNotFoundException{
  1227.         try{
  1228.             ByteArrayOutputStream bout = new ByteArrayOutputStream();
  1229.             this.evaluate(source, xquery, bout, resultAsXml);
  1230.             bout.flush();
  1231.             bout.close();
  1232.             return bout.toString();
  1233.         }catch(XQueryException e){
  1234.             throw e;
  1235.         }catch(XQueryNotValidException e){
  1236.             throw e;
  1237.         }catch(XQueryEvaluateException e){
  1238.             throw e;
  1239.         }catch(XQueryEvaluateNotFoundException e){
  1240.             throw e;
  1241.         }catch(Exception e){
  1242.             throw new XQueryException(e.getMessage(),e);
  1243.         }
  1244.     }
  1245.    
  1246.     // Destination: OutputStream
  1247.     public void evaluate(File source, String xquery, OutputStream out) throws XQueryException, XQueryNotValidException, XQueryEvaluateException, XQueryEvaluateNotFoundException{
  1248.         this._evaluate(this._buildXdmNode(source), this._buildEvaluator(xquery), this._buildDestination(out, AbstractXQueryExpressionEngine.DEFAULT_RESULT_AS_XML));
  1249.     }
  1250.     public void evaluate(File source, String xquery, OutputStream out, boolean resultAsXml) throws XQueryException, XQueryNotValidException, XQueryEvaluateException, XQueryEvaluateNotFoundException{
  1251.         this._evaluate(this._buildXdmNode(source), this._buildEvaluator(xquery), this._buildDestination(out, resultAsXml));
  1252.     }
  1253.     public void evaluate(File source, File xquery, OutputStream out) throws XQueryException, XQueryNotValidException, XQueryEvaluateException, XQueryEvaluateNotFoundException{
  1254.         this._evaluate(this._buildXdmNode(source), this._buildEvaluator(xquery), this._buildDestination(out, AbstractXQueryExpressionEngine.DEFAULT_RESULT_AS_XML));
  1255.     }
  1256.     public void evaluate(File source, File xquery, OutputStream out, boolean resultAsXml) throws XQueryException, XQueryNotValidException, XQueryEvaluateException, XQueryEvaluateNotFoundException{
  1257.         this._evaluate(this._buildXdmNode(source), this._buildEvaluator(xquery), this._buildDestination(out, resultAsXml));
  1258.     }
  1259.     public void evaluate(File source, InputStream xquery, OutputStream out) throws XQueryException, XQueryNotValidException, XQueryEvaluateException, XQueryEvaluateNotFoundException{
  1260.         this._evaluate(this._buildXdmNode(source), this._buildEvaluator(xquery), this._buildDestination(out, AbstractXQueryExpressionEngine.DEFAULT_RESULT_AS_XML));
  1261.     }
  1262.     public void evaluate(File source, InputStream xquery, OutputStream out, boolean resultAsXml) throws XQueryException, XQueryNotValidException, XQueryEvaluateException, XQueryEvaluateNotFoundException{
  1263.         this._evaluate(this._buildXdmNode(source), this._buildEvaluator(xquery), this._buildDestination(out, resultAsXml));
  1264.     }
  1265.     public void evaluate(File source, Reader xquery, OutputStream out) throws XQueryException, XQueryNotValidException, XQueryEvaluateException, XQueryEvaluateNotFoundException{
  1266.         this._evaluate(this._buildXdmNode(source), this._buildEvaluator(xquery), this._buildDestination(out, AbstractXQueryExpressionEngine.DEFAULT_RESULT_AS_XML));
  1267.     }
  1268.     public void evaluate(File source, Reader xquery, OutputStream out, boolean resultAsXml) throws XQueryException, XQueryNotValidException, XQueryEvaluateException, XQueryEvaluateNotFoundException{
  1269.         this._evaluate(this._buildXdmNode(source), this._buildEvaluator(xquery), this._buildDestination(out, resultAsXml));
  1270.     }
  1271.    
  1272.     // Destination: Writer
  1273.     public void evaluate(File source, String xquery, Writer out) throws XQueryException, XQueryNotValidException, XQueryEvaluateException, XQueryEvaluateNotFoundException{
  1274.         this._evaluate(this._buildXdmNode(source), this._buildEvaluator(xquery), this._buildDestination(out, AbstractXQueryExpressionEngine.DEFAULT_RESULT_AS_XML));
  1275.     }
  1276.     public void evaluate(File source, String xquery, Writer out, boolean resultAsXml) throws XQueryException, XQueryNotValidException, XQueryEvaluateException, XQueryEvaluateNotFoundException{
  1277.         this._evaluate(this._buildXdmNode(source), this._buildEvaluator(xquery), this._buildDestination(out, resultAsXml));
  1278.     }
  1279.     public void evaluate(File source, File xquery, Writer out) throws XQueryException, XQueryNotValidException, XQueryEvaluateException, XQueryEvaluateNotFoundException{
  1280.         this._evaluate(this._buildXdmNode(source), this._buildEvaluator(xquery), this._buildDestination(out, AbstractXQueryExpressionEngine.DEFAULT_RESULT_AS_XML));
  1281.     }
  1282.     public void evaluate(File source, File xquery, Writer out, boolean resultAsXml) throws XQueryException, XQueryNotValidException, XQueryEvaluateException, XQueryEvaluateNotFoundException{
  1283.         this._evaluate(this._buildXdmNode(source), this._buildEvaluator(xquery), this._buildDestination(out, resultAsXml));
  1284.     }
  1285.     public void evaluate(File source, InputStream xquery, Writer out) throws XQueryException, XQueryNotValidException, XQueryEvaluateException, XQueryEvaluateNotFoundException{
  1286.         this._evaluate(this._buildXdmNode(source), this._buildEvaluator(xquery), this._buildDestination(out, AbstractXQueryExpressionEngine.DEFAULT_RESULT_AS_XML));
  1287.     }
  1288.     public void evaluate(File source, InputStream xquery, Writer out, boolean resultAsXml) throws XQueryException, XQueryNotValidException, XQueryEvaluateException, XQueryEvaluateNotFoundException{
  1289.         this._evaluate(this._buildXdmNode(source), this._buildEvaluator(xquery), this._buildDestination(out, resultAsXml));
  1290.     }
  1291.     public void evaluate(File source, Reader xquery, Writer out) throws XQueryException, XQueryNotValidException, XQueryEvaluateException, XQueryEvaluateNotFoundException{
  1292.         this._evaluate(this._buildXdmNode(source), this._buildEvaluator(xquery), this._buildDestination(out, AbstractXQueryExpressionEngine.DEFAULT_RESULT_AS_XML));
  1293.     }
  1294.     public void evaluate(File source, Reader xquery, Writer out, boolean resultAsXml) throws XQueryException, XQueryNotValidException, XQueryEvaluateException, XQueryEvaluateNotFoundException{
  1295.         this._evaluate(this._buildXdmNode(source), this._buildEvaluator(xquery), this._buildDestination(out, resultAsXml));
  1296.     }
  1297.    
  1298.     // Destination: File
  1299.     public void evaluate(File source, String xquery, File out) throws XQueryException, XQueryNotValidException, XQueryEvaluateException, XQueryEvaluateNotFoundException{
  1300.         this._evaluate(this._buildXdmNode(source), this._buildEvaluator(xquery), this._buildDestination(out, AbstractXQueryExpressionEngine.DEFAULT_RESULT_AS_XML));
  1301.     }
  1302.     public void evaluate(File source, String xquery, File out, boolean resultAsXml) throws XQueryException, XQueryNotValidException, XQueryEvaluateException, XQueryEvaluateNotFoundException{
  1303.         this._evaluate(this._buildXdmNode(source), this._buildEvaluator(xquery), this._buildDestination(out, resultAsXml));
  1304.     }
  1305.     public void evaluate(File source, File xquery, File out) throws XQueryException, XQueryNotValidException, XQueryEvaluateException, XQueryEvaluateNotFoundException{
  1306.         this._evaluate(this._buildXdmNode(source), this._buildEvaluator(xquery), this._buildDestination(out, AbstractXQueryExpressionEngine.DEFAULT_RESULT_AS_XML));
  1307.     }
  1308.     public void evaluate(File source, File xquery, File out, boolean resultAsXml) throws XQueryException, XQueryNotValidException, XQueryEvaluateException, XQueryEvaluateNotFoundException{
  1309.         this._evaluate(this._buildXdmNode(source), this._buildEvaluator(xquery), this._buildDestination(out, resultAsXml));
  1310.     }
  1311.     public void evaluate(File source, InputStream xquery, File out) throws XQueryException, XQueryNotValidException, XQueryEvaluateException, XQueryEvaluateNotFoundException{
  1312.         this._evaluate(this._buildXdmNode(source), this._buildEvaluator(xquery), this._buildDestination(out, AbstractXQueryExpressionEngine.DEFAULT_RESULT_AS_XML));
  1313.     }
  1314.     public void evaluate(File source, InputStream xquery, File out, boolean resultAsXml) throws XQueryException, XQueryNotValidException, XQueryEvaluateException, XQueryEvaluateNotFoundException{
  1315.         this._evaluate(this._buildXdmNode(source), this._buildEvaluator(xquery), this._buildDestination(out, resultAsXml));
  1316.     }
  1317.     public void evaluate(File source, Reader xquery, File out) throws XQueryException, XQueryNotValidException, XQueryEvaluateException, XQueryEvaluateNotFoundException{
  1318.         this._evaluate(this._buildXdmNode(source), this._buildEvaluator(xquery), this._buildDestination(out, AbstractXQueryExpressionEngine.DEFAULT_RESULT_AS_XML));
  1319.     }
  1320.     public void evaluate(File source, Reader xquery, File out, boolean resultAsXml) throws XQueryException, XQueryNotValidException, XQueryEvaluateException, XQueryEvaluateNotFoundException{
  1321.         this._evaluate(this._buildXdmNode(source), this._buildEvaluator(xquery), this._buildDestination(out, resultAsXml));
  1322.     }
  1323.    
  1324.     // Destination: Node
  1325.     public void evaluate(File source, String xquery, Node out) throws XQueryException, XQueryNotValidException, XQueryEvaluateException, XQueryEvaluateNotFoundException{
  1326.         this._evaluate(this._buildXdmNode(source), this._buildEvaluator(xquery), this._buildDestination(out, AbstractXQueryExpressionEngine.DEFAULT_RESULT_AS_XML));
  1327.     }
  1328.     public void evaluate(File source, String xquery, Node out, boolean resultAsXml) throws XQueryException, XQueryNotValidException, XQueryEvaluateException, XQueryEvaluateNotFoundException{
  1329.         this._evaluate(this._buildXdmNode(source), this._buildEvaluator(xquery), this._buildDestination(out, resultAsXml));
  1330.     }
  1331.     public void evaluate(File source, File xquery, Node out) throws XQueryException, XQueryNotValidException, XQueryEvaluateException, XQueryEvaluateNotFoundException{
  1332.         this._evaluate(this._buildXdmNode(source), this._buildEvaluator(xquery), this._buildDestination(out, AbstractXQueryExpressionEngine.DEFAULT_RESULT_AS_XML));
  1333.     }
  1334.     public void evaluate(File source, File xquery, Node out, boolean resultAsXml) throws XQueryException, XQueryNotValidException, XQueryEvaluateException, XQueryEvaluateNotFoundException{
  1335.         this._evaluate(this._buildXdmNode(source), this._buildEvaluator(xquery), this._buildDestination(out, resultAsXml));
  1336.     }
  1337.     public void evaluate(File source, InputStream xquery, Node out) throws XQueryException, XQueryNotValidException, XQueryEvaluateException, XQueryEvaluateNotFoundException{
  1338.         this._evaluate(this._buildXdmNode(source), this._buildEvaluator(xquery), this._buildDestination(out, AbstractXQueryExpressionEngine.DEFAULT_RESULT_AS_XML));
  1339.     }
  1340.     public void evaluate(File source, InputStream xquery, Node out, boolean resultAsXml) throws XQueryException, XQueryNotValidException, XQueryEvaluateException, XQueryEvaluateNotFoundException{
  1341.         this._evaluate(this._buildXdmNode(source), this._buildEvaluator(xquery), this._buildDestination(out, resultAsXml));
  1342.     }
  1343.     public void evaluate(File source, Reader xquery, Node out) throws XQueryException, XQueryNotValidException, XQueryEvaluateException, XQueryEvaluateNotFoundException{
  1344.         this._evaluate(this._buildXdmNode(source), this._buildEvaluator(xquery), this._buildDestination(out, AbstractXQueryExpressionEngine.DEFAULT_RESULT_AS_XML));
  1345.     }
  1346.     public void evaluate(File source, Reader xquery, Node out, boolean resultAsXml) throws XQueryException, XQueryNotValidException, XQueryEvaluateException, XQueryEvaluateNotFoundException{
  1347.         this._evaluate(this._buildXdmNode(source), this._buildEvaluator(xquery), this._buildDestination(out, resultAsXml));
  1348.     }
  1349.    
  1350.    
  1351.    
  1352.     /* ***** PUBLIC METHOD (SRC as String) ***** */
  1353.    
  1354.     // Destination: String
  1355.     public String evaluate(String source, String xquery) throws XQueryException, XQueryNotValidException, XQueryEvaluateException, XQueryEvaluateNotFoundException{
  1356.         return this.evaluate(source, xquery, AbstractXQueryExpressionEngine.DEFAULT_RESULT_AS_XML);
  1357.     }
  1358.     public String evaluate(String source, String xquery, boolean resultAsXml) throws XQueryException, XQueryNotValidException, XQueryEvaluateException, XQueryEvaluateNotFoundException{
  1359.         try{
  1360.             ByteArrayOutputStream bout = new ByteArrayOutputStream();
  1361.             this.evaluate(source, xquery, bout,resultAsXml);
  1362.             bout.flush();
  1363.             bout.close();
  1364.             return bout.toString();
  1365.         }catch(XQueryException e){
  1366.             throw e;
  1367.         }catch(XQueryNotValidException e){
  1368.             throw e;
  1369.         }catch(XQueryEvaluateException e){
  1370.             throw e;
  1371.         }catch(XQueryEvaluateNotFoundException e){
  1372.             throw e;
  1373.         }catch(Exception e){
  1374.             throw new XQueryException(e.getMessage(),e);
  1375.         }
  1376.     }
  1377.     public String evaluate(String source, File xquery) throws XQueryException, XQueryNotValidException, XQueryEvaluateException, XQueryEvaluateNotFoundException{
  1378.         return this.evaluate(source, xquery, AbstractXQueryExpressionEngine.DEFAULT_RESULT_AS_XML);
  1379.     }
  1380.     public String evaluate(String source, File xquery, boolean resultAsXml) throws XQueryException, XQueryNotValidException, XQueryEvaluateException, XQueryEvaluateNotFoundException{
  1381.         try{
  1382.             ByteArrayOutputStream bout = new ByteArrayOutputStream();
  1383.             this.evaluate(source, xquery, bout, resultAsXml);
  1384.             bout.flush();
  1385.             bout.close();
  1386.             return bout.toString();
  1387.         }catch(XQueryException e){
  1388.             throw e;
  1389.         }catch(XQueryNotValidException e){
  1390.             throw e;
  1391.         }catch(XQueryEvaluateException e){
  1392.             throw e;
  1393.         }catch(XQueryEvaluateNotFoundException e){
  1394.             throw e;
  1395.         }catch(Exception e){
  1396.             throw new XQueryException(e.getMessage(),e);
  1397.         }
  1398.     }
  1399.     public String evaluate(String source, InputStream xquery) throws XQueryException, XQueryNotValidException, XQueryEvaluateException, XQueryEvaluateNotFoundException{
  1400.         return this.evaluate(source, xquery, AbstractXQueryExpressionEngine.DEFAULT_RESULT_AS_XML);
  1401.     }
  1402.     public String evaluate(String source, InputStream xquery, boolean resultAsXml) throws XQueryException, XQueryNotValidException, XQueryEvaluateException, XQueryEvaluateNotFoundException{
  1403.         try{
  1404.             ByteArrayOutputStream bout = new ByteArrayOutputStream();
  1405.             this.evaluate(source, xquery, bout, resultAsXml);
  1406.             bout.flush();
  1407.             bout.close();
  1408.             return bout.toString();
  1409.         }catch(XQueryException e){
  1410.             throw e;
  1411.         }catch(XQueryNotValidException e){
  1412.             throw e;
  1413.         }catch(XQueryEvaluateException e){
  1414.             throw e;
  1415.         }catch(XQueryEvaluateNotFoundException e){
  1416.             throw e;
  1417.         }catch(Exception e){
  1418.             throw new XQueryException(e.getMessage(),e);
  1419.         }
  1420.     }
  1421.     public String evaluate(String source, Reader xquery) throws XQueryException, XQueryNotValidException, XQueryEvaluateException, XQueryEvaluateNotFoundException{
  1422.         return this.evaluate(source, xquery, AbstractXQueryExpressionEngine.DEFAULT_RESULT_AS_XML);
  1423.     }
  1424.     public String evaluate(String source, Reader xquery, boolean resultAsXml) throws XQueryException, XQueryNotValidException, XQueryEvaluateException, XQueryEvaluateNotFoundException{
  1425.         try{
  1426.             ByteArrayOutputStream bout = new ByteArrayOutputStream();
  1427.             this.evaluate(source, xquery, bout, resultAsXml);
  1428.             bout.flush();
  1429.             bout.close();
  1430.             return bout.toString();
  1431.         }catch(XQueryException e){
  1432.             throw e;
  1433.         }catch(XQueryNotValidException e){
  1434.             throw e;
  1435.         }catch(XQueryEvaluateException e){
  1436.             throw e;
  1437.         }catch(XQueryEvaluateNotFoundException e){
  1438.             throw e;
  1439.         }catch(Exception e){
  1440.             throw new XQueryException(e.getMessage(),e);
  1441.         }
  1442.     }
  1443.    
  1444.     // Destination: OutputStream
  1445.     public void evaluate(String source, String xquery, OutputStream out) throws XQueryException, XQueryNotValidException, XQueryEvaluateException, XQueryEvaluateNotFoundException{
  1446.         this._evaluate(this._buildXdmNode(source), this._buildEvaluator(xquery), this._buildDestination(out, AbstractXQueryExpressionEngine.DEFAULT_RESULT_AS_XML));
  1447.     }
  1448.     public void evaluate(String source, String xquery, OutputStream out, boolean resultAsXml) throws XQueryException, XQueryNotValidException, XQueryEvaluateException, XQueryEvaluateNotFoundException{
  1449.         this._evaluate(this._buildXdmNode(source), this._buildEvaluator(xquery), this._buildDestination(out, resultAsXml));
  1450.     }
  1451.     public void evaluate(String source, File xquery, OutputStream out) throws XQueryException, XQueryNotValidException, XQueryEvaluateException, XQueryEvaluateNotFoundException{
  1452.         this._evaluate(this._buildXdmNode(source), this._buildEvaluator(xquery), this._buildDestination(out, AbstractXQueryExpressionEngine.DEFAULT_RESULT_AS_XML));
  1453.     }
  1454.     public void evaluate(String source, File xquery, OutputStream out, boolean resultAsXml) throws XQueryException, XQueryNotValidException, XQueryEvaluateException, XQueryEvaluateNotFoundException{
  1455.         this._evaluate(this._buildXdmNode(source), this._buildEvaluator(xquery), this._buildDestination(out, resultAsXml));
  1456.     }
  1457.     public void evaluate(String source, InputStream xquery, OutputStream out) throws XQueryException, XQueryNotValidException, XQueryEvaluateException, XQueryEvaluateNotFoundException{
  1458.         this._evaluate(this._buildXdmNode(source), this._buildEvaluator(xquery), this._buildDestination(out, AbstractXQueryExpressionEngine.DEFAULT_RESULT_AS_XML));
  1459.     }
  1460.     public void evaluate(String source, InputStream xquery, OutputStream out, boolean resultAsXml) throws XQueryException, XQueryNotValidException, XQueryEvaluateException, XQueryEvaluateNotFoundException{
  1461.         this._evaluate(this._buildXdmNode(source), this._buildEvaluator(xquery), this._buildDestination(out, resultAsXml));
  1462.     }
  1463.     public void evaluate(String source, Reader xquery, OutputStream out) throws XQueryException, XQueryNotValidException, XQueryEvaluateException, XQueryEvaluateNotFoundException{
  1464.         this._evaluate(this._buildXdmNode(source), this._buildEvaluator(xquery), this._buildDestination(out, AbstractXQueryExpressionEngine.DEFAULT_RESULT_AS_XML));
  1465.     }
  1466.     public void evaluate(String source, Reader xquery, OutputStream out, boolean resultAsXml) throws XQueryException, XQueryNotValidException, XQueryEvaluateException, XQueryEvaluateNotFoundException{
  1467.         this._evaluate(this._buildXdmNode(source), this._buildEvaluator(xquery), this._buildDestination(out, resultAsXml));
  1468.     }
  1469.    
  1470.     // Destination: Writer
  1471.     public void evaluate(String source, String xquery, Writer out) throws XQueryException, XQueryNotValidException, XQueryEvaluateException, XQueryEvaluateNotFoundException{
  1472.         this._evaluate(this._buildXdmNode(source), this._buildEvaluator(xquery), this._buildDestination(out, AbstractXQueryExpressionEngine.DEFAULT_RESULT_AS_XML));
  1473.     }
  1474.     public void evaluate(String source, String xquery, Writer out, boolean resultAsXml) throws XQueryException, XQueryNotValidException, XQueryEvaluateException, XQueryEvaluateNotFoundException{
  1475.         this._evaluate(this._buildXdmNode(source), this._buildEvaluator(xquery), this._buildDestination(out, resultAsXml));
  1476.     }
  1477.     public void evaluate(String source, File xquery, Writer out) throws XQueryException, XQueryNotValidException, XQueryEvaluateException, XQueryEvaluateNotFoundException{
  1478.         this._evaluate(this._buildXdmNode(source), this._buildEvaluator(xquery), this._buildDestination(out, AbstractXQueryExpressionEngine.DEFAULT_RESULT_AS_XML));
  1479.     }
  1480.     public void evaluate(String source, File xquery, Writer out, boolean resultAsXml) throws XQueryException, XQueryNotValidException, XQueryEvaluateException, XQueryEvaluateNotFoundException{
  1481.         this._evaluate(this._buildXdmNode(source), this._buildEvaluator(xquery), this._buildDestination(out, resultAsXml));
  1482.     }
  1483.     public void evaluate(String source, InputStream xquery, Writer out) throws XQueryException, XQueryNotValidException, XQueryEvaluateException, XQueryEvaluateNotFoundException{
  1484.         this._evaluate(this._buildXdmNode(source), this._buildEvaluator(xquery), this._buildDestination(out, AbstractXQueryExpressionEngine.DEFAULT_RESULT_AS_XML));
  1485.     }
  1486.     public void evaluate(String source, InputStream xquery, Writer out, boolean resultAsXml) throws XQueryException, XQueryNotValidException, XQueryEvaluateException, XQueryEvaluateNotFoundException{
  1487.         this._evaluate(this._buildXdmNode(source), this._buildEvaluator(xquery), this._buildDestination(out, resultAsXml));
  1488.     }
  1489.     public void evaluate(String source, Reader xquery, Writer out) throws XQueryException, XQueryNotValidException, XQueryEvaluateException, XQueryEvaluateNotFoundException{
  1490.         this._evaluate(this._buildXdmNode(source), this._buildEvaluator(xquery), this._buildDestination(out, AbstractXQueryExpressionEngine.DEFAULT_RESULT_AS_XML));
  1491.     }
  1492.     public void evaluate(String source, Reader xquery, Writer out, boolean resultAsXml) throws XQueryException, XQueryNotValidException, XQueryEvaluateException, XQueryEvaluateNotFoundException{
  1493.         this._evaluate(this._buildXdmNode(source), this._buildEvaluator(xquery), this._buildDestination(out, resultAsXml));
  1494.     }
  1495.    
  1496.     // Destination: File
  1497.     public void evaluate(String source, String xquery, File out) throws XQueryException, XQueryNotValidException, XQueryEvaluateException, XQueryEvaluateNotFoundException{
  1498.         this._evaluate(this._buildXdmNode(source), this._buildEvaluator(xquery), this._buildDestination(out, AbstractXQueryExpressionEngine.DEFAULT_RESULT_AS_XML));
  1499.     }
  1500.     public void evaluate(String source, String xquery, File out, boolean resultAsXml) throws XQueryException, XQueryNotValidException, XQueryEvaluateException, XQueryEvaluateNotFoundException{
  1501.         this._evaluate(this._buildXdmNode(source), this._buildEvaluator(xquery), this._buildDestination(out, resultAsXml));
  1502.     }
  1503.     public void evaluate(String source, File xquery, File out) throws XQueryException, XQueryNotValidException, XQueryEvaluateException, XQueryEvaluateNotFoundException{
  1504.         this._evaluate(this._buildXdmNode(source), this._buildEvaluator(xquery), this._buildDestination(out, AbstractXQueryExpressionEngine.DEFAULT_RESULT_AS_XML));
  1505.     }
  1506.     public void evaluate(String source, File xquery, File out, boolean resultAsXml) throws XQueryException, XQueryNotValidException, XQueryEvaluateException, XQueryEvaluateNotFoundException{
  1507.         this._evaluate(this._buildXdmNode(source), this._buildEvaluator(xquery), this._buildDestination(out, resultAsXml));
  1508.     }
  1509.     public void evaluate(String source, InputStream xquery, File out) throws XQueryException, XQueryNotValidException, XQueryEvaluateException, XQueryEvaluateNotFoundException{
  1510.         this._evaluate(this._buildXdmNode(source), this._buildEvaluator(xquery), this._buildDestination(out, AbstractXQueryExpressionEngine.DEFAULT_RESULT_AS_XML));
  1511.     }
  1512.     public void evaluate(String source, InputStream xquery, File out, boolean resultAsXml) throws XQueryException, XQueryNotValidException, XQueryEvaluateException, XQueryEvaluateNotFoundException{
  1513.         this._evaluate(this._buildXdmNode(source), this._buildEvaluator(xquery), this._buildDestination(out, resultAsXml));
  1514.     }
  1515.     public void evaluate(String source, Reader xquery, File out) throws XQueryException, XQueryNotValidException, XQueryEvaluateException, XQueryEvaluateNotFoundException{
  1516.         this._evaluate(this._buildXdmNode(source), this._buildEvaluator(xquery), this._buildDestination(out, AbstractXQueryExpressionEngine.DEFAULT_RESULT_AS_XML));
  1517.     }
  1518.     public void evaluate(String source, Reader xquery, File out, boolean resultAsXml) throws XQueryException, XQueryNotValidException, XQueryEvaluateException, XQueryEvaluateNotFoundException{
  1519.         this._evaluate(this._buildXdmNode(source), this._buildEvaluator(xquery), this._buildDestination(out, resultAsXml));
  1520.     }
  1521.    
  1522.     // Destination: Node
  1523.     public void evaluate(String source, String xquery, Node out) throws XQueryException, XQueryNotValidException, XQueryEvaluateException, XQueryEvaluateNotFoundException{
  1524.         this._evaluate(this._buildXdmNode(source), this._buildEvaluator(xquery), this._buildDestination(out, AbstractXQueryExpressionEngine.DEFAULT_RESULT_AS_XML));
  1525.     }
  1526.     public void evaluate(String source, String xquery, Node out, boolean resultAsXml) throws XQueryException, XQueryNotValidException, XQueryEvaluateException, XQueryEvaluateNotFoundException{
  1527.         this._evaluate(this._buildXdmNode(source), this._buildEvaluator(xquery), this._buildDestination(out, resultAsXml));
  1528.     }
  1529.     public void evaluate(String source, File xquery, Node out) throws XQueryException, XQueryNotValidException, XQueryEvaluateException, XQueryEvaluateNotFoundException{
  1530.         this._evaluate(this._buildXdmNode(source), this._buildEvaluator(xquery), this._buildDestination(out, AbstractXQueryExpressionEngine.DEFAULT_RESULT_AS_XML));
  1531.     }
  1532.     public void evaluate(String source, File xquery, Node out, boolean resultAsXml) throws XQueryException, XQueryNotValidException, XQueryEvaluateException, XQueryEvaluateNotFoundException{
  1533.         this._evaluate(this._buildXdmNode(source), this._buildEvaluator(xquery), this._buildDestination(out, resultAsXml));
  1534.     }
  1535.     public void evaluate(String source, InputStream xquery, Node out) throws XQueryException, XQueryNotValidException, XQueryEvaluateException, XQueryEvaluateNotFoundException{
  1536.         this._evaluate(this._buildXdmNode(source), this._buildEvaluator(xquery), this._buildDestination(out, AbstractXQueryExpressionEngine.DEFAULT_RESULT_AS_XML));
  1537.     }
  1538.     public void evaluate(String source, InputStream xquery, Node out, boolean resultAsXml) throws XQueryException, XQueryNotValidException, XQueryEvaluateException, XQueryEvaluateNotFoundException{
  1539.         this._evaluate(this._buildXdmNode(source), this._buildEvaluator(xquery), this._buildDestination(out, resultAsXml));
  1540.     }
  1541.     public void evaluate(String source, Reader xquery, Node out) throws XQueryException, XQueryNotValidException, XQueryEvaluateException, XQueryEvaluateNotFoundException{
  1542.         this._evaluate(this._buildXdmNode(source), this._buildEvaluator(xquery), this._buildDestination(out, AbstractXQueryExpressionEngine.DEFAULT_RESULT_AS_XML));
  1543.     }
  1544.     public void evaluate(String source, Reader xquery, Node out, boolean resultAsXml) throws XQueryException, XQueryNotValidException, XQueryEvaluateException, XQueryEvaluateNotFoundException{
  1545.         this._evaluate(this._buildXdmNode(source), this._buildEvaluator(xquery), this._buildDestination(out, resultAsXml));
  1546.     }
  1547. }

  1548. class WrapperFileXdmNode extends XdmNode{

  1549.     protected XdmNode original;
  1550.     protected InputStream is;
  1551.    
  1552.     public WrapperFileXdmNode(XdmNode original,InputStream is) {
  1553.         super(original.getUnderlyingNode());
  1554.         this.original = original;
  1555.         this.is = is;
  1556.     }
  1557.    
  1558. }

  1559. class WrapperDestination {
  1560.    
  1561.     protected Destination destination;
  1562.    
  1563.     protected Node node;
  1564.    
  1565.     protected CountingOutputStream cout;
  1566.    
  1567.     protected File file;
  1568.    
  1569.     protected Writer writer;
  1570. }