/** * Load the stylesheet to prepare it for execution. This version of the load() method * creates an <code>Xslt30Transformer</code> which offers interfaces for stylesheet * invocation corresponding to those described in the XSLT 3.0 specification. It can be used * with XSLT 2.0 or XSLT 3.0 stylesheets, and in both cases it offers new XSLT 3.0 functionality such * as the ability to supply parameters to the initial template, or the ability to invoke * stylesheet-defined functions, or the ability to return an arbitrary sequence as a result * without wrapping it in a document node. * * @return An Xslt30Transformer. The returned Xslt30Transformer can be used to set up the * dynamic context for stylesheet evaluation, and to run the stylesheet. */ public Xslt30Transformer load30() { return new Xslt30Transformer(processor, preparedStylesheet.newController(), preparedStylesheet.getCompileTimeParams()); }
/** * Invoke the stylesheet by applying templates to a supplied input sequence, returning the raw results. * as an {@link XdmValue}. The invocation uses any initial mode set using {@link #setInitialMode(QName)}, * and any template parameters set using {@link #setInitialTemplateParameters(java.util.Map, boolean)}. * * @param selection the initial value to which templates are to be applied (equivalent to the <code>select</code> * attribute of <code>xsl:apply-templates</code>) * @return the raw result of applying templates to the supplied selection value, without wrapping in * a document node or serializing the result. If there is more that one item in the selection, the result * is the concatenation of the results of applying templates to each item in turn. * @throws SaxonApiException if the transformation fails */ public XdmValue applyTemplates(XdmValue selection) throws SaxonApiException { Objects.requireNonNull(selection); RawDestination raw = new RawDestination(); applyTemplates(selection, raw); return raw.getXdmValue(); }
throw new SaxonApiException(err); prime(); try { Receiver sOut = getDestinationReceiver(controller, destination); applyTemplatesToSource(source, sOut); destination.closeAndNotify(); } catch (XPathException e) { if (!e.hasBeenReported()) { try { getErrorListener().fatalError(e); } catch (TransformerException e1) {
Objects.requireNonNull(selection); Objects.requireNonNull(destination); prime(); try { Receiver sOut = getDestinationReceiver(controller, destination); if (baseOutputUriWasSet) { sOut.setSystemId(getBaseOutputURI()); if (!e.hasBeenReported()) { try { getErrorListener().fatalError(e); } catch (TransformerException e1) {
XsltController controller = transformer.getUnderlyingController(); controller.setResultDocumentResolver(deliverer); Sequence<?> result; try { transformer.setStylesheetParameters(stylesheetParams); transformer.setBaseOutputURI(baseOutputUri); transformer.setInitialTemplateParameters(templateParams, false); transformer.setInitialTemplateParameters(tunnelParams, true); transformer.setGlobalContextItem(new XdmNode(sourceNode.getRoot())); transformer.setGlobalContextItem(globalContextItem); transformer.callTemplate(initialTemplate, destination); result = deliverer.getPrimaryResult(); } else if (initialFunction != null) { transformer.callFunction(initialFunction, functionParams, destination); result = deliverer.getPrimaryResult(); } else { if (initialMode != null) { transformer.setInitialMode(initialMode); if (transformer.getUnderlyingController().getInitialMode().isDeclaredStreamable()) { transformer.applyTemplates(stream, destination); } else { transformer.transform(stream,destination); transformer.applyTemplates(initialMatchSelection, destination);
Serializer serializer; if (outputFile == null) { transformer.setBaseOutputURI(new File(System.getProperty("user.dir")).toURI().toASCIIString()); serializer = transformer.newSerializer(System.out); }else { serializer = transformer.newSerializer(outputFile); if (requirement == null) { buildSourceTree = initialTemplate != null || !transformer.getUnderlyingController().getInitialMode().isDeclaredStreamable(); } else { buildSourceTree = !requirement.isAbsentFocus(); transformer.setGlobalContextItem(node, true); source = node.asSource(); transformer.callTemplate(initialTemplateName, serializer); } else { XdmValue result = transformer.callTemplate(initialTemplateName); serializer.serializeXdmValue(result); transformer.applyTemplates(source, serializer); } else { XdmValue result = transformer.applyTemplates(source); serializer.serializeXdmValue(result);
Objects.requireNonNull(function); Objects.requireNonNull(arguments); prime(); try { Component f = getFunctionComponent(function, arguments); UserFunction uf = (UserFunction) f.getActor(); Sequence[] vr = typeCheckFunctionArguments(uf, arguments); if (!e.hasBeenReported()) { try { getErrorListener().fatalError(e); } catch (TransformerException e1) {
throw new SaxonApiException("Cannot use the transform() method when the initial mode is streamable"); prime(); try { NodeInfo sourceNode; controller.setGlobalContextItem(sourceNode); } else { sourceNode = controller.makeSourceTree(source, getSchemaValidationMode().getNumber()); controller.setGlobalContextItem(sourceNode); Receiver sOut = getDestinationReceiver(controller, destination); controller.applyTemplates(sourceNode, sOut); destination.closeAndNotify(); if (!e.hasBeenReported()) { try { getErrorListener().fatalError(e); } catch (TransformerException e1) {
public void transform(Source xmlSource, final Result outputTarget) throws XPathException { try { xsltTransformer.setStylesheetParameters(convertedParameters); if (outputTarget.getSystemId() != null) { //bug 2214 xsltTransformer.setBaseOutputURI(outputTarget.getSystemId()); xsltTransformer.applyTemplates(xmlSource, destination);
transformer.newSerializer(System.out) : transformer.newSerializer(outFile); try { options.setSerializationProperties(serializer); transformer.setGlobalContextItem(sourceDoc); transformer.applyTemplates(sourceDoc, serializer);
@Override public Receiver getReceiver(PipelineConfiguration pipe, SerializationProperties params) throws SaxonApiException { Receiver rt = getReceivingTransformer(controller, globalParameterSet, finalDestination); rt = new SequenceNormalizerWithSpaceSeparator(rt); rt.setPipelineConfiguration(pipe); return r =rt; }
/** * Invoke a transformation by calling a named template. The results of calling * the template are returned as a raw value, without wrapping in a document node * or serializing. * * @param templateName the name of the initial template. This must match the name of a * public named template in the stylesheet. If the value is null, * the QName <code>xsl:initial-template</code> is used. * @return the raw results of the called template, without wrapping in a document node * or serialization. * @throws SaxonApiException if there is no named template with this name, or if any dynamic * error occurs during the transformation */ public XdmValue callTemplate(QName templateName) throws SaxonApiException { RawDestination dest = new RawDestination(); callTemplate(templateName, dest); return dest.getXdmValue(); }
XsltController controller = transformer.getUnderlyingController(); controller.setResultDocumentResolver(deliverer); Sequence<?> result; try { transformer.setStylesheetParameters(stylesheetParams); transformer.setBaseOutputURI(baseOutputUri); transformer.setInitialTemplateParameters(templateParams, false); transformer.setInitialTemplateParameters(tunnelParams, true); transformer.setGlobalContextItem(new XdmNode(sourceNode.getRoot())); transformer.setGlobalContextItem(globalContextItem); transformer.callTemplate(initialTemplate, destination); result = deliverer.getPrimaryResult(); } else if (initialFunction != null) { transformer.callFunction(initialFunction, functionParams, destination); result = deliverer.getPrimaryResult(); } else { if (initialMode != null) { transformer.setInitialMode(initialMode); if (transformer.getUnderlyingController().getInitialMode().isDeclaredStreamable()) { transformer.applyTemplates(stream, destination); } else { transformer.transform(stream,destination); transformer.applyTemplates(initialMatchSelection, destination);
Serializer serializer; if (outputFile == null) { transformer.setBaseOutputURI(new File(System.getProperty("user.dir")).toURI().toASCIIString()); serializer = transformer.newSerializer(System.out); }else { serializer = transformer.newSerializer(outputFile); if (requirement == null) { buildSourceTree = initialTemplate != null || !transformer.getUnderlyingController().getInitialMode().isDeclaredStreamable(); } else { buildSourceTree = !requirement.isAbsentFocus(); transformer.setGlobalContextItem(node, true); source = node.asSource(); transformer.callTemplate(initialTemplateName, serializer); } else { XdmValue result = transformer.callTemplate(initialTemplateName); serializer.serializeXdmValue(result); transformer.applyTemplates(source, serializer); } else { XdmValue result = transformer.applyTemplates(source); serializer.serializeXdmValue(result);
Objects.requireNonNull(selection); Objects.requireNonNull(destination); prime(); try { Receiver sOut = getDestinationReceiver(controller, destination); if (baseOutputUriWasSet) { sOut.setSystemId(getBaseOutputURI()); if (!e.hasBeenReported()) { try { getErrorListener().fatalError(e); } catch (TransformerException e1) {
Objects.requireNonNull(function); Objects.requireNonNull(arguments); prime(); try { Component f = getFunctionComponent(function, arguments); UserFunction uf = (UserFunction) f.getActor(); Sequence[] vr = typeCheckFunctionArguments(uf, arguments); if (!e.hasBeenReported()) { try { getErrorListener().fatalError(e); } catch (TransformerException e1) {
throw new SaxonApiException("Cannot use the transform() method when the initial mode is streamable"); prime(); try { NodeInfo sourceNode; controller.setGlobalContextItem(sourceNode); } else { sourceNode = controller.makeSourceTree(source, getSchemaValidationMode().getNumber()); controller.setGlobalContextItem(sourceNode); Receiver sOut = getDestinationReceiver(controller, destination); controller.applyTemplates(sourceNode, sOut); destination.closeAndNotify(); if (!e.hasBeenReported()) { try { getErrorListener().fatalError(e); } catch (TransformerException e1) {
public void transform(Source xmlSource, final Result outputTarget) throws XPathException { try { xsltTransformer.setStylesheetParameters(convertedParameters); if (outputTarget.getSystemId() != null) { //bug 2214 xsltTransformer.setBaseOutputURI(outputTarget.getSystemId()); xsltTransformer.applyTemplates(xmlSource, destination);
transformer.newSerializer(System.out) : transformer.newSerializer(outFile); try { options.setSerializationProperties(serializer); transformer.setGlobalContextItem(sourceDoc); transformer.applyTemplates(sourceDoc, serializer);
@Override public Receiver getReceiver(PipelineConfiguration pipe, SerializationProperties params) throws SaxonApiException { Receiver rt = getReceivingTransformer(controller, globalParameterSet, finalDestination); rt = new SequenceNormalizerWithSpaceSeparator(rt); rt.setPipelineConfiguration(pipe); return r =rt; }