/** * Get the Configuration */ public final Configuration getConfiguration() { return controller.getConfiguration(); }
private XPathContext makeDynamicContext(UseWhenStaticContext staticContext) throws XPathException { Controller controller = new Controller(getConfiguration()); controller.getExecutable().setFunctionLibrary((FunctionLibraryList) staticContext.getFunctionLibrary()); if (staticContext.getXPathVersion() < 30) { controller.setURIResolver(new URIPreventer()); } controller.setCurrentDateTime(currentDateTime); // this is to ensure that all use-when expressions in a module use the same date and time XPathContext dynamicContext = controller.newXPathContext(); dynamicContext = dynamicContext.newCleanContext(); return dynamicContext; }
/** * Allocate a SequenceOutputter for a new output destination. * * @param size the estimated size of the output sequence * @return SequenceOutputter the allocated SequenceOutputter */ /*@NotNull*/ public synchronized SequenceOutputter allocateSequenceOutputter(int size) { PipelineConfiguration pipe = makePipelineConfiguration(); return new SequenceOutputter(pipe, size); }
/** * Construct a new context as a copy of another. The new context is effectively added * to the top of a stack, and contains a pointer to the previous context */ public XPathContextMajor newContext() { Controller controller = new Controller(config); return controller.newXPathContext(); // notAllowed(); // return null; }
/** * Make a Transformer from this Templates object. * * @return the new Transformer (always a Controller) * @see net.sf.saxon.Controller */ public Transformer newTransformer() { Controller c = new Controller(config, executable); c.setPreparedStylesheet(this); return c; }
/** * Called at start */ public void open(/*@NotNull*/ Controller controller) { config = controller.getConfiguration(); lang = controller.getExecutable().getHostLanguage(); t_total = System.nanoTime(); }
pipe = c.getController().makePipelineConfiguration(); out.setPipelineConfiguration(pipe); DocumentInfo doc = controller.getDocumentPool().find(documentKey); Source source = null; if (doc != null) { URIResolver r = controller.getURIResolver(); if (r != null) { source = r.resolve(href, baseURL); r = controller.getStandardURIResolver(); source = r.resolve(href, baseURL); NodeInfo startNode = controller.prepareInputTree(source); source = startNode.getDocumentRoot(); ((AugmentedSource)source).setStripSpace(Whitespace.XSLT); if (controller.getExecutable().stripsInputTypeAnnotations()) { out = controller.getConfiguration().getAnnotationStripper(out);
URIResolver resolver = controller.getURIResolver(); if (resolver == null) { resolver = controller.getStandardURIResolver(); doc = controller.getDocumentPool().find(documentKey); if (doc != null) { return getFragment(doc, fragmentId, c); if (!controller.checkUniqueOutputDestination(documentKey)) { XPathException err = new XPathException( "Cannot read a document that was written during the same transformation: " + documentKey); } catch (Exception ex) { XPathException de = new XPathException("Exception thrown by URIResolver", ex); if (controller.getConfiguration().isTraceExternalFunctions()) { ex.printStackTrace(); } catch (Exception ex) { XPathException de = new XPathException("Exception thrown by URIResolver", ex); if (controller.getConfiguration().isTraceExternalFunctions()) { ex.printStackTrace(); resolver = controller.getStandardURIResolver(); if (resolver instanceof RelativeURIResolver) { source = ((RelativeURIResolver)resolver).dereference(documentKey); NodeInfo startNode = controller.prepareInputTree(source); newdoc = startNode.getDocumentRoot(); } else {
/** * Start of event stream */ public void open() throws XPathException { builder = controller.makeBuilder(); setPipelineConfiguration(builder.getPipelineConfiguration()); builder.setSystemId(systemId); Receiver stripper = controller.makeStripper(builder); if (controller.getExecutable().stripsInputTypeAnnotations()) { stripper = controller.getConfiguration().getAnnotationStripper(stripper); } setUnderlyingReceiver(stripper); nextReceiver.open(); }
/** * Evaluate in a general context */ public Item evaluateItem(XPathContext c) throws XPathException { Controller controller = c.getController(); AtomicValue content = (AtomicValue)argument[0].evaluateItem(c); StringReader sr = new StringReader(content.getStringValue()); InputSource is = new InputSource(sr); is.setSystemId(baseURI); Source source = new SAXSource(is); source.setSystemId(baseURI); Builder b = controller.makeBuilder(); Receiver s = b; source = AugmentedSource.makeAugmentedSource(source); ((AugmentedSource)source).setStripSpace(Whitespace.XSLT); if (controller.getExecutable().stripsInputTypeAnnotations()) { s = controller.getConfiguration().getAnnotationStripper(s); } try { new Sender(controller.makePipelineConfiguration()).send(source, s); return b.getCurrentRoot(); } catch (XPathException err) { throw new XPathException(err); } }
/** * Evaluate as an expression. We rely on the fact that when these instructions * are generated by XQuery, there will always be a valueExpression to evaluate * the content */ public Item evaluateItem(XPathContext context) throws XPathException { Controller controller = context.getController(); XPathContext c2 = context.newMinorContext(); c2.setOrigin(this); SequenceOutputter seq = controller.allocateSequenceOutputter(1); PipelineConfiguration pipe = controller.makePipelineConfiguration(); pipe.setHostLanguage(getHostLanguage()); seq.setPipelineConfiguration(pipe); c2.setTemporaryReceiver(seq); process(c2); seq.close(); Item item = seq.getFirstItem(); seq.reset(); return item; }
/** * Get the error listener. If no ErrorListener * has been set locally, the ErrorListener in the Controller is returned; this in turn defaults * to the ErrorListener set in the Configuration. * * @return the ErrorListener in use. Note that this is not necessarily the ErrorListener that was supplied * to the {@link #setErrorListener(ErrorListener)} method; if that was not an {@link UnfailingErrorListener}, * it will have been wrapped in a {@link DelegatingErrorListener}, and it is the DelegatingErrorListener * that this method returns. * @since 9.6 */ public UnfailingErrorListener getErrorListener() { return errorListener == null ? controller.getErrorListener() : errorListener; }
Configuration config = getConfiguration(); SequenceIterator iter = val.iterate(); Item next; try { if (systemId != null && new URI(systemId).isAbsolute()) { DocumentPool pool = getDocumentPool(); if (pool.find(systemId) == null) { pool.add(((NodeInfo) val).getTreeInfo(), systemId);
public TreeWriter(Processor proc) { pool = proc.getUnderlyingConfiguration().getNamePool(); controller = new Controller(proc.getUnderlyingConfiguration()); }
/** * Get the current date and time for this query or transformation. * All calls during one transformation return the same answer. * * @return Get the current date and time. This will deliver the same value * for repeated calls within the same transformation */ public DateTimeValue getCurrentDateTime() { return controller.getCurrentDateTime(); }
/** * Compute a document key */ protected static DocumentURI computeDocumentKey(String href, String baseURI, PackageData packageData, XPathContext c) throws XPathException { // Resolve relative URI Controller controller = c.getController(); URIResolver resolver = controller.getURIResolver(); if (resolver == null) { resolver = controller.getStandardURIResolver(); } return computeDocumentKey(href, baseURI, packageData, resolver, true); }
public static void main(String[] args) throws Exception { Controller controller = new Controller(new Configuration()); TinyBuilder tb = (TinyBuilder)controller.makeBuilder(); tb.open(); NamePool p = tb.getConfiguration().getNamePool(); int code = p.allocate("a", "b", "c"); tb.startElement(code, -1, -1, -1); tb.endElement(); tb.startDocument(-1); tb.startElement(code, -1, -1, -1); tb.endElement(); tb.endDocument(); tb.close(); TinyTree tt = tb.getTree(); NodeInfo node = tb.getCurrentRoot(); TinyTreeWalker walker = new TinyTreeWalker((TinyNodeImpl)node); System.out.println(walker.next()); System.out.println(walker.next()); System.out.println(walker.next()); System.out.println(walker.next()); System.out.println(walker.next()); } }
protected XPathContextMajor initialContext(DynamicQueryContext dynamicEnv, Controller controller) throws XPathException { Item<?> contextItem = controller.getGlobalContextItem(); XPathContextMajor context = controller.newXPathContext(); if (contextItem != null) { ManualIterator<Item<?>> single = new ManualIterator<>(contextItem); context.setCurrentIterator(single); controller.setGlobalContextItem(contextItem); } return context; }
/** * Remove a document from the document pool. The effect is that the document becomes eligible for * garbage collection, allowing memory to be released when processing of the document has finished. * The downside is that a subsequent call on document() with the same URI causes the document to be * reloaded and reparsed, and the new nodes will have different node identity from the old. * * @param context the evaluation context (supplied implicitly by the call mechanism) * @param doc the document to be released from the document pool * @return the document that was released. This allows a call such as * select="saxon:discard-document(document('a.xml'))" */ public static DocumentInfo discardDocument(XPathContext context, DocumentInfo doc) { if (doc == null) { return null; } Controller c = context.getController(); String uri = c.getDocumentPool().getDocumentURI(doc); if (uri != null) { c.removeUnavailableOutputDestination(uri); } return c.getDocumentPool().discard(doc); }
/** * Allocate a SequenceOutputter. Used from generated bytecode. * * @param context dynamic XPath context * @param hostLang host language (XSLT/XQuery) * @return the allocated SequenceOutputter * @see com.saxonica.ee.bytecode.util.CompilerService */ /*@Nullable*/ public static SequenceOutputter allocateSequenceOutputter(XPathContext context, int hostLang) { Controller controller = context.getController(); SequenceOutputter seq = controller.allocateSequenceOutputter(20); seq.getPipelineConfiguration().setHostLanguage(hostLang); return seq; }