/** * Creates a new {@code RootNode} instance. * * @param detailAst reference to {@code DetailAST} */ public RootNode(DetailAST detailAst) { super(new GenericTreeInfo(Configuration.newConfiguration())); this.detailAst = detailAst; if (detailAst != null) { createChildren(); } }
@Override public ValidationResult validate(final String subject, final String input, final ValidationContext validationContext) { final Tuple<String, ValidationResult> lastResult = this.cachedResult; if (lastResult != null && lastResult.getKey().equals(input)) { return lastResult.getValue(); } else { String error = null; final File stylesheet = new File(input); final TransformerFactory tFactory = new net.sf.saxon.TransformerFactoryImpl(); final StreamSource styleSource = new StreamSource(stylesheet); try { tFactory.newTransformer(styleSource); } catch (final Exception e) { error = e.toString(); } this.cachedResult = new Tuple<>(input, new ValidationResult.Builder() .input(input) .subject(subject) .valid(error == null) .explanation(error) .build()); return this.cachedResult.getValue(); } } }
public static String saxonTransform(String source, String xslt) throws TransformerException, FileNotFoundException { TransformerFactoryImpl f = new net.sf.saxon.TransformerFactoryImpl(); f.setAttribute("http://saxon.sf.net/feature/version-warning", Boolean.FALSE); StreamSource xsrc = new StreamSource(new FileInputStream(xslt)); Transformer t = f.newTransformer(xsrc); StreamSource src = new StreamSource(new FileInputStream(source)); StreamResult res = new StreamResult(new ByteArrayOutputStream()); t.transform(src, res); return res.getOutputStream().toString(); }
public static void saxonTransform(String xsltDir, String source, String xslt, String dest, URIResolver alt, Map<String, String> params) throws FileNotFoundException, TransformerException { TransformerFactoryImpl f = new net.sf.saxon.TransformerFactoryImpl(); f.setAttribute("http://saxon.sf.net/feature/version-warning", Boolean.FALSE); StreamSource xsrc = new StreamSource(new FileInputStream(xslt)); f.setURIResolver(new MyURIResolver(xsltDir, alt)); Transformer t = f.newTransformer(xsrc); if (params != null) { for (Map.Entry<String, String> entry : params.entrySet()) { t.setParameter(entry.getKey(), entry.getValue()); } } t.setURIResolver(new MyURIResolver(xsltDir, alt)); StreamSource src = new StreamSource(new FileInputStream(source)); StreamResult res = new StreamResult(new FileOutputStream(dest)); t.transform(src, res); }
/** * Get the Name Pool */ public final NamePool getNamePool() { return controller.getConfiguration().getNamePool(); }
public BasicTransformerFactory() { Configuration config = new Configuration(); config.setProcessor(this); setConfiguration(config); }
/** * Get a message used to identify this product when a transformation is run using the -t option * * @return A string containing both the product name and the product * version * @since 8.4 */ public String getProductTitle() { return "Saxon-" + getEditionCode() + " " + Version.getProductVersion() + Version.platform.getPlatformSuffix() + " from Saxonica"; }
/** * Get a message used to identify this product when a transformation is run using the -t option * * @return A string containing both the product name and the product * version */ public static String getProductTitle() { return getProductName() + '-' + softwareEdition + ' ' + getProductVersion() + (platform.isJava() ? 'J' : 'N') + " from Saxonica"; }
/** * Get the name of the default collection. Defaults to the default collection * name registered with the Configuration. * * @return the collection URI of the default collection. If no value has been * set explicitly, the collection URI registered with the Configuration is returned * @since 9.4 */ public String getDefaultCollection() { return defaultCollectionURI == null ? getConfiguration().getDefaultCollection() : defaultCollectionURI; }
/** * Create a IdentityTransformerHandler and initialise variables. The constructor is protected, because * the Filter should be created using newTransformerHandler() in the SAXTransformerFactory * class * @param controller the Controller for this transformation */ protected IdentityTransformerHandler(Controller controller) { this.controller = controller; setPipelineConfiguration(controller.makePipelineConfiguration()); }
/** * Get the Rule Manager. * <p>This method is intended for internal use only.</p> * * @return the Rule Manager, used to hold details of template rules for * all modes; or null in the case of a non-XSLT controller */ public RuleManager getRuleManager() { Executable exec = getExecutable(); return exec instanceof PreparedStylesheet ? ((PreparedStylesheet) getExecutable()).getRuleManager() : null; }
/** * Get a message used to identify this product when a transformation is run using the -t option * @return A string containing both the product name and the product * version * @since 8.4 */ public String getProductTitle() { return "Saxon " + Version.getProductVersion() + platform.getPlatformSuffix() + " from Saxonica"; }
/** * Set the URIResolver to a URI resolver that allows query parameters after the URI, * and in the case of Saxon-SA, that inteprets the file extension .ptree */ public void setParameterizedURIResolver() { getSystemURIResolver().setRecognizeQueryParameters(true); }
/** * Declare a URI that maps to a Java class containing extension functions * @param uri the namespace uri used in the function names * @param theClass the Java class containing methods accessible using this URI */ protected void declareJavaClass(String uri, Class theClass) { Configuration.getPlatform().declareJavaClass(javaFunctions, uri, theClass); }
factory = new net.sf.saxon.TransformerFactoryImpl();
/** * Get a message used to identify this product when a transformation is run using the -t option * * @return A string containing both the product name and the product * version * @since 8.4 */ public String getProductTitle() { return "Saxon-" + getEditionCode() + " " + Version.getProductVersion() + Version.platform.getPlatformSuffix() + " from Saxonica"; }
/** * Get the Rule Manager. * <p>This method is intended for internal use only.</p> * * @return the Rule Manager, used to hold details of template rules for * all modes; or null in the case of a non-XSLT controller */ public RuleManager getRuleManager() { Executable exec = getExecutable(); return exec instanceof PreparedStylesheet ? ((PreparedStylesheet) getExecutable()).getRuleManager() : null; }
public static byte[] saxonTransform(Map<String, byte[]> files, byte[] source, byte[] xslt) throws TransformerException { TransformerFactory f = new net.sf.saxon.TransformerFactoryImpl(); f.setAttribute("http://saxon.sf.net/feature/version-warning", Boolean.FALSE); StreamSource xsrc = new StreamSource(new ByteArrayInputStream(xslt)); f.setURIResolver(new ZipURIResolver(files)); Transformer t = f.newTransformer(xsrc); t.setURIResolver(new ZipURIResolver(files)); StreamSource src = new StreamSource(new ByteArrayInputStream(source)); ByteArrayOutputStream out = new ByteArrayOutputStream(); StreamResult res = new StreamResult(out); t.transform(src, res); return out.toByteArray(); }
public static byte[] saxonTransform(Map<String, byte[]> files, byte[] source, byte[] xslt) throws Exception { TransformerFactory f = new net.sf.saxon.TransformerFactoryImpl(); f.setAttribute("http://saxon.sf.net/feature/version-warning", Boolean.FALSE); StreamSource xsrc = new StreamSource(new ByteArrayInputStream(xslt)); f.setURIResolver(new ZipURIResolver(files)); Transformer t = f.newTransformer(xsrc); t.setURIResolver(new ZipURIResolver(files)); StreamSource src = new StreamSource(new ByteArrayInputStream(source)); ByteArrayOutputStream out = new ByteArrayOutputStream(); StreamResult res = new StreamResult(out); t.transform(src, res); return out.toByteArray(); }
data.factory = new net.sf.saxon.TransformerFactoryImpl();