/** * 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; }
/** * 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; }
/** * Main method for testing only * @param args not used * @throws Exception */ public static void main(String[] args) throws Exception { Configuration config = new Configuration(); DocumentInfo doc = config.buildDocument(new StreamSource(new File("c:/MyJava/samples/data/books.xml"))); PipelineConfiguration pipe = config.makePipelineConfiguration(); pipe.setHostLanguage(Configuration.XQUERY); EventIterator e = new Decomposer(new SingletonEventIterator(doc), pipe); SequenceIterator iter = new SequenceComposer(e, pipe); while (true) { NodeInfo item = (NodeInfo)iter.next(); if (item == null) { break; } System.out.println(QueryResult.serialize(item)); } } }
/** * Main method for testing only * @param args not used * @throws Exception */ public static void main(String[] args) throws Exception { Configuration config = new Configuration(); DocumentInfo doc = config.buildDocument(new StreamSource(new File("c:/MyJava/samples/data/books.xml"))); PipelineConfiguration pipe = config.makePipelineConfiguration(); pipe.setHostLanguage(Configuration.XQUERY); EventIterator e = new Decomposer(new SingletonEventIterator(doc), pipe); e = EventStackIterator.flatten(e); e = new PullEventTracer(e, config); while (true) { PullEvent pe = e.next(); if (pe == null) { break; } } } }
/** * Make a PipelineConfiguration based on the properties of this Controller. * <p>This interface is intended primarily for internal use, although it may be necessary * for applications to call it directly if they construct pull or push pipelines.</p> * * @return a newly constructed PipelineConfiguration holding a reference to this * Controller as well as other configuration information. */ /*@NotNull*/ public PipelineConfiguration makePipelineConfiguration() { PipelineConfiguration pipe = config.makePipelineConfiguration(); pipe.setURIResolver(userURIResolver == null ? standardURIResolver : userURIResolver); pipe.getParseOptions().setSchemaValidationMode(validationMode); // added in 9.7 pipe.getParseOptions().setErrorListener(errorListener); // added in 9.7.0.4 pipe.setController(this); final Executable executable = getExecutable(); if (executable != null) { // can be null for an IdentityTransformer pipe.setHostLanguage(executable.getHostLanguage()); } return pipe; }
/** * Make a PipelineConfiguration based on the properties of this Controller. * <p>This interface is intended primarily for internal use, although it may be necessary * for applications to call it directly if they construct pull or push pipelines.</p> * * @return a newly constructed PipelineConfiguration holding a reference to this * Controller as well as other configuration information. */ /*@NotNull*/ public PipelineConfiguration makePipelineConfiguration() { PipelineConfiguration pipe = config.makePipelineConfiguration(); pipe.setURIResolver(userURIResolver == null ? standardURIResolver : userURIResolver); pipe.getParseOptions().setSchemaValidationMode(validationMode); // added in 9.7 pipe.getParseOptions().setErrorListener(errorListener); // added in 9.7.0.4 pipe.setController(this); final Executable executable = getExecutable(); if (executable != null) { // can be null for an IdentityTransformer pipe.setHostLanguage(executable.getHostLanguage()); } return pipe; }
/** * Make a PipelineConfiguration from the properties of this Configuration * @return a new PipelineConfiguration * @since 8.4 */ public PipelineConfiguration makePipelineConfiguration() { PipelineConfiguration pipe = new PipelineConfiguration(); pipe.setConfiguration(this); pipe.setErrorListener(getErrorListener()); pipe.setURIResolver(getURIResolver()); pipe.setSchemaURIResolver(getSchemaURIResolver()); pipe.setHostLanguage(getHostLanguage()); pipe.setExpandAttributeDefaults(isExpandAttributeDefaults()); return pipe; }
@Override public Sequence<?> evaluate(Expression expr, XPathContext context) throws XPathException { Controller controller = context.getController(); Receiver saved = context.getReceiver(); SequenceOutputter seq = controller.allocateSequenceOutputter(20); seq.getPipelineConfiguration().setHostLanguage(expr.getPackageData().getHostLanguage()); context.setReceiver(seq); seq.open(); expr.process(context); seq.close(); context.setReceiver(saved); Sequence<?> val = seq.getSequence(); seq.reset(); return val; }
/** * Helper method to construct an iterator over the results of the expression when all that * the expression itself offers is a process() method. This builds the entire results of the * expression as a sequence in memory and then iterates over it. * * @param context the dynamic evaluation context * @return an iterator over the results of the expression * @throws XPathException if a dynamic error occurs */ public static SequenceIterator<?> getIteratorFromProcessMethod( Expression exp, XPathContext context) throws XPathException { Controller controller = context.getController(); assert controller != null; Receiver saved = context.getReceiver(); SequenceOutputter seq = controller.allocateSequenceOutputter(20); seq.getPipelineConfiguration().setHostLanguage(exp.getPackageData().getHostLanguage()); context.setReceiver(seq); exp.process(context); context.setReceiver(saved); seq.close(); return seq.iterate(); }
/** * Make a PipelineConfiguration from the properties of this Configuration * * @return a new PipelineConfiguration * @since 8.4 */ public PipelineConfiguration makePipelineConfiguration() { PipelineConfiguration pipe = new PipelineConfiguration(); pipe.setConfiguration(this); pipe.setErrorListener(getErrorListener()); pipe.setURIResolver(getURIResolver()); pipe.setSchemaURIResolver(getSchemaURIResolver()); pipe.setHostLanguage(getHostLanguage()); pipe.setExpandAttributeDefaults(isExpandAttributeDefaults()); pipe.setUseXsiSchemaLocation(useXsiSchemaLocation); return pipe; }
/** * 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(); Receiver saved = context.getReceiver(); SequenceOutputter seq = controller.allocateSequenceOutputter(1); seq.getPipelineConfiguration().setHostLanguage(getPackageData().getHostLanguage()); context.setReceiver(seq); process(context); seq.close(); context.setReceiver(saved); Item item = seq.getFirstItem(); seq.reset(); return item; }
@Override public Sequence<?> evaluate(Expression expr, XPathContext context) throws XPathException { Controller controller = context.getController(); Receiver saved = context.getReceiver(); SequenceOutputter seq = controller.allocateSequenceOutputter(20); seq.getPipelineConfiguration().setHostLanguage(expr.getPackageData().getHostLanguage()); context.setReceiver(seq); seq.open(); expr.process(context); seq.close(); context.setReceiver(saved); Sequence<?> val = seq.getSequence(); seq.reset(); return val; }
/** * Helper method to construct an iterator over the results of the expression when all that * the expression itself offers is a process() method. This builds the entire results of the * expression as a sequence in memory and then iterates over it. * * @param context the dynamic evaluation context * @return an iterator over the results of the expression * @throws XPathException if a dynamic error occurs */ public static SequenceIterator<?> getIteratorFromProcessMethod( Expression exp, XPathContext context) throws XPathException { Controller controller = context.getController(); assert controller != null; Receiver saved = context.getReceiver(); SequenceOutputter seq = controller.allocateSequenceOutputter(20); seq.getPipelineConfiguration().setHostLanguage(exp.getPackageData().getHostLanguage()); context.setReceiver(seq); exp.process(context); context.setReceiver(saved); seq.close(); return seq.iterate(); }
/** * 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(); Receiver saved = context.getReceiver(); SequenceOutputter seq = controller.allocateSequenceOutputter(1); seq.getPipelineConfiguration().setHostLanguage(getPackageData().getHostLanguage()); context.setReceiver(seq); process(context); seq.close(); context.setReceiver(saved); Item item = seq.getFirstItem(); seq.reset(); return item; }
/** * 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; }
/** * 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; }
/** * 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; }
/** * Helper method to construct an item representing the results of the expression when all that * the expression itself offers is a process() method. * * @param context the dynamic evaluation context * @return an iterator over the results of the expression * @throws XPathException if a dynamic error occurs */ public static Item getItemFromProcessMethod(Expression exp, XPathContext context) throws XPathException { Controller controller = context.getController(); assert controller != null; Receiver saved = context.getReceiver(); SequenceOutputter seq = controller.allocateSequenceOutputter(1); seq.getPipelineConfiguration().setHostLanguage(exp.getPackageData().getHostLanguage()); context.setReceiver(seq); exp.process(context); context.setReceiver(saved); seq.close(); Item result = seq.getFirstItem(); seq.reset(); return result; }
/** * Helper method to construct an item representing the results of the expression when all that * the expression itself offers is a process() method. * * @param context the dynamic evaluation context * @return an iterator over the results of the expression * @throws XPathException if a dynamic error occurs */ public static Item getItemFromProcessMethod(Expression exp, XPathContext context) throws XPathException { Controller controller = context.getController(); assert controller != null; Receiver saved = context.getReceiver(); SequenceOutputter seq = controller.allocateSequenceOutputter(1); seq.getPipelineConfiguration().setHostLanguage(exp.getPackageData().getHostLanguage()); context.setReceiver(seq); exp.process(context); context.setReceiver(saved); seq.close(); Item result = seq.getFirstItem(); seq.reset(); return result; }
/** * Make a PipelineConfiguration based on the properties of this Controller. * <p> * This interface is intended primarily for internal use, although it may be necessary * for applications to call it directly if they construct pull or push pipelines * @return a newly constructed PipelineConfiguration holding a reference to this * Controller as well as other configuration information. */ public PipelineConfiguration makePipelineConfiguration() { PipelineConfiguration pipe = new PipelineConfiguration(); pipe.setConfiguration(getConfiguration()); pipe.setErrorListener(getErrorListener()); pipe.setURIResolver(userURIResolver==null ? standardURIResolver : userURIResolver); pipe.setSchemaURIResolver(schemaURIResolver); pipe.setExpandAttributeDefaults(getConfiguration().isExpandAttributeDefaults()); pipe.setController(this); final Executable executable = getExecutable(); if (executable != null) { // can be null for an IdentityTransformer pipe.setLocationProvider(executable.getLocationMap()); pipe.setHostLanguage(executable.getHostLanguage()); } return pipe; }