public Source getAssociatedStylesheet(Source source, String media, String title, String charset) throws TransformerConfigurationException { return actual.getAssociatedStylesheet(source, media, title, charset); }
/** * Retrieve a stylesheet from this XML (throws an exception if * no stylesheet is attached). * @param factory Transformer factory * @param xml The XML * @return Stylesheet found * @throws TransformerConfigurationException If fails */ private static Source stylesheet(final TransformerFactory factory, final Source xml) throws TransformerConfigurationException { final Source stylesheet = factory.getAssociatedStylesheet( xml, null, null, null ); if (stylesheet == null) { throw new IllegalArgumentException( "no associated stylesheet found in XML" ); } return stylesheet; }
/** * Retrieve a stylesheet from this XML (throws an exception if * no stylesheet is attached). * @param factory Transformer factory * @param xml The XML * @return Stylesheet found * @throws TransformerConfigurationException If fails */ private static Source stylesheet(final TransformerFactory factory, final Source xml) throws TransformerConfigurationException { final Source stylesheet = factory.getAssociatedStylesheet( xml, null, null, null ); if (stylesheet == null) { throw new IllegalArgumentException( "no associated stylesheet found in XML" ); } return stylesheet; }
System.setProperty("javax.xml.transform.TransformerFactory", "net.sf.saxon.TransformerFactoryImpl"); StreamSource xmlSource = new StreamSource(xml); TransformerFactory factory = TransformerFactory.newInstance(); Source xslSource = factory.getAssociatedStylesheet(xmlSource, null, null, null); Transformer transformer = factory.newTransformer(xslSource); transformer.transform(xmlSource, new StreamResult(xhtml));
public Source getAssociatedStylesheet(Source source, String media, String title, String charset) throws TransformerConfigurationException { if (_currFactory == null) { createXSLTCTransformerFactory(); } return _currFactory.getAssociatedStylesheet(source, media, title, charset); }
public Source getAssociatedStylesheet(Source source, String media, String title, String charset) throws TransformerConfigurationException { if (_currFactory == null) { createXSLTCTransformerFactory(); } return _currFactory.getAssociatedStylesheet(source, media, title, charset); }
TransformerFactory factory = TransformerFactory.newInstance(); StreamSource xml = new StreamSource("input.xml"); Source xsl = factory.getAssociatedStylesheet(xml, null, null, null); System.out.println(new File(xsl.getSystemId()).getName());
/** * Generates an XML file. Uses a ProcessDescription file and a XSLT file to generate an * AlgorithmDescription. * * @param xmlFile - the ProcessDescription in XML * @param xsltFile - the transformation rules in XSLT * @throws Exception - the exceptions */ private static StringReader generateAlgorithmDescription(File xmlFile) { Source xmlSource = new StreamSource(xmlFile); TransformerFactory transFact = TransformerFactory.newInstance(); StringWriter sw = new StringWriter(); StreamResult transformResult = new StreamResult(sw); try { Source xsltSource = transFact.getAssociatedStylesheet(xmlSource, null, null, null); Transformer trans = transFact.newTransformer(xsltSource); trans.transform(xmlSource, transformResult); StringReader sr = new StringReader(sw.toString()); return sr; } catch (TransformerException e) { LOGGER.error("Error evaluating ProcessDescription XML."); e.printStackTrace(); } return null; }
final Source stylesheet; try { stylesheet = this.tfactory.getAssociatedStylesheet( this.source(xml), null, null, null );
stf.getAssociatedStylesheet(new StreamSource(inFileName), media, null, null);
stf.getAssociatedStylesheet(new StreamSource(inFileName), media, null, null);