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); }
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); }
factory.setAttribute(FeatureKeys.COLLECTION_URI_RESOLVER, resolver); } else if (option.equals("ds")) { factory.setAttribute(FeatureKeys.TREE_MODEL, new Integer(Builder.LINKED_TREE)); i++; } else if (option.equals("dt")) { factory.setAttribute(FeatureKeys.TREE_MODEL, new Integer(Builder.TINY_TREE)); i++; factory.setAttribute(FeatureKeys.DTD_VALIDATION, Boolean.valueOf("on".equals(value))); i++; factory.setAttribute(FeatureKeys.EXPAND_ATTRIBUTE_DEFAULTS, Boolean.valueOf("on".equals(value))); i++; factory.setAttribute(FeatureKeys.TRACE_OPTIMIZER_DECISIONS, Boolean.TRUE); i++; } else if (option.equals("ext")) { factory.setAttribute(FeatureKeys.ALLOW_EXTERNAL_FUNCTIONS, Boolean.valueOf("on".equals(value))); i++; factory.setAttribute(FeatureKeys.LINE_NUMBERING, Boolean.valueOf(!"off".equals(value))); i++;
factory.setAttribute(FeatureKeys.COLLECTION_URI_RESOLVER, resolver); } else if (option.equals("ds")) { factory.setAttribute(FeatureKeys.TREE_MODEL, new Integer(Builder.LINKED_TREE)); i++; } else if (option.equals("dt")) { factory.setAttribute(FeatureKeys.TREE_MODEL, new Integer(Builder.TINY_TREE)); i++; factory.setAttribute(FeatureKeys.DTD_VALIDATION, Boolean.valueOf("on".equals(value))); i++; factory.setAttribute(FeatureKeys.EXPAND_ATTRIBUTE_DEFAULTS, Boolean.valueOf("on".equals(value))); i++; factory.setAttribute(FeatureKeys.TRACE_OPTIMIZER_DECISIONS, Boolean.TRUE); i++; } else if (option.equals("ext")) { factory.setAttribute(FeatureKeys.ALLOW_EXTERNAL_FUNCTIONS, Boolean.valueOf("on".equals(value))); i++; factory.setAttribute(FeatureKeys.LINE_NUMBERING, Boolean.valueOf(!"off".equals(value))); i++;
factory.setAttribute( FeatureKeys.TIMING, Boolean.TRUE); if (args.length < i+2) badUsage("No style parser class"); String styleParserName = args[i++]; factory.setAttribute( FeatureKeys.STYLE_PARSER_CLASS, styleParserName); factory.setAttribute(FeatureKeys.XML_VERSION, "1.1");
factory.setAttribute( FeatureKeys.TIMING, Boolean.TRUE); if (args.length < i+2) badUsage("No style parser class"); String styleParserName = args[i++]; factory.setAttribute( FeatureKeys.STYLE_PARSER_CLASS, styleParserName); factory.setAttribute(FeatureKeys.XML_VERSION, "1.1");