/** * Save this compiled package to filestore for a particular target environment * * @param file the file to which the compiled package should be saved * @param target the target environment. The only values currently recognized are "JS" and "JS2, * which export the package for running under Saxon-JS 1.0 or 2.0 respectively. * @throws SaxonApiException if the compiled package cannot be saved to the specified * location, or if the package was compiled with just-in-time * compilation enabled. * @since 9.7.0.5 */ public void save(File file, String target) throws SaxonApiException { try { if (!file.exists()) { File directory = file.getParentFile(); if (directory != null && !directory.exists()) { directory.mkdirs(); } file.createNewFile(); } ExpressionPresenter presenter = getProcessor().getUnderlyingConfiguration() .newExpressionExporter(target, new FileOutputStream(file), stylesheetPackage); presenter.setRelocatable(stylesheetPackage.isRelocatable()); stylesheetPackage.export(presenter); } catch (XPathException | IOException e) { throw new SaxonApiException(e); } }
/** * Save this compiled package to filestore for a particular target environment * * @param file the file to which the compiled package should be saved * @param target the target environment. The only values currently recognized are "JS" and "JS2, * which export the package for running under Saxon-JS 1.0 or 2.0 respectively. * @throws SaxonApiException if the compiled package cannot be saved to the specified * location, or if the package was compiled with just-in-time * compilation enabled. * @since 9.7.0.5 */ public void save(File file, String target) throws SaxonApiException { try { Query.createFileIfNecessary(file); ExpressionPresenter presenter = getProcessor().getUnderlyingConfiguration() .newExpressionExporter(target, new FileOutputStream(file), stylesheetPackage); presenter.setRelocatable(stylesheetPackage.isRelocatable()); stylesheetPackage.export(presenter); } catch (XPathException | IOException e) { throw new SaxonApiException(e); } }
/** * Produce a representation of the compiled stylesheet for a particular target environment, in XML form, suitable for * distribution and reloading. If the configuration under which the export takes place * is suitably licensed, then license information will be included in the export file * allowing execution of the stylesheet without any additional license. * <p><i>The detailed form of the output representation is not documented.</i></p> * * @param destination the destination for the XML document containing the diagnostic representation * of the compiled stylesheet. The stream will be closed when writing has finished. * @param target the target environment. The only values currently recognized are "JS" and "JS2, * which export the package for running under Saxon-JS 1.0 or 2.0 respectively. * @since 9.7 */ public void export(OutputStream destination, String target) throws SaxonApiException { Configuration config = processor.getUnderlyingConfiguration(); try { StylesheetPackage topLevelPackage = preparedStylesheet.getTopLevelPackage(); ExpressionPresenter presenter = config.newExpressionExporter(target, destination, topLevelPackage); presenter.setRelocatable(topLevelPackage.isRelocatable()); topLevelPackage.export(presenter); } catch (XPathException e) { throw new SaxonApiException(e); } try { destination.close(); } catch (IOException e) { throw new SaxonApiException(e); } }
/** * Produce a representation of the compiled stylesheet for a particular target environment, in XML form, suitable for * distribution and reloading. If the configuration under which the export takes place * is suitably licensed, then license information will be included in the export file * allowing execution of the stylesheet without any additional license. * <p><i>The detailed form of the output representation is not documented.</i></p> * * @param destination the destination for the XML document containing the diagnostic representation * of the compiled stylesheet. The stream will be closed when writing has finished. * @param target the target environment. The only values currently recognized are "JS" and "JS2, * which export the package for running under Saxon-JS 1.0 or 2.0 respectively. * @since 9.7 */ public void export(OutputStream destination, String target) throws SaxonApiException { Configuration config = processor.getUnderlyingConfiguration(); try { StylesheetPackage topLevelPackage = preparedStylesheet.getTopLevelPackage(); ExpressionPresenter presenter = config.newExpressionExporter(target, destination, topLevelPackage); presenter.setRelocatable(topLevelPackage.isRelocatable()); topLevelPackage.export(presenter); } catch (XPathException e) { throw new SaxonApiException(e); } try { destination.close(); } catch (IOException e) { throw new SaxonApiException(e); } }