Advertisement
Guest User

Untitled

a guest
Nov 15th, 2019
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.18 KB | None | 0 0
  1. package lab7;
  2.  
  3. import java.io.File;
  4. import java.io.FileOutputStream;
  5. import java.io.IOException;
  6. import java.io.OutputStream;
  7.  
  8. import javax.xml.transform.Result;
  9. import javax.xml.transform.Transformer;
  10. import javax.xml.transform.TransformerFactory;
  11. import javax.xml.transform.stream.StreamResult;
  12. import javax.xml.transform.stream.StreamSource;
  13.  
  14. import org.jdom2.Document;
  15. import org.jdom2.input.SAXBuilder;
  16. import org.jdom2.transform.JDOMSource;
  17.  
  18. public class XSLTFOParcer {
  19.  
  20. public static void main(String[] args) throws IOException {
  21. OutputStream out= null;
  22. File foFile=new File("src/lab7/ex1.fo");
  23. File xmlFile = new File("src/lab7/retete.xml");
  24. File xsltFile= new File("src/lab7/retete.xslt");
  25. try{
  26. out=new FileOutputStream(foFile);
  27. SAXBuilder sb= new SAXBuilder();
  28. Document jdoc=sb.build(xmlFile);
  29. JDOMSource src= new JDOMSource(jdoc);
  30. TransformerFactory tf = TransformerFactory.newInstance();
  31. Transformer tr= tf.newTransformer(new StreamSource(xsltFile));
  32. Result res= new StreamResult(out);
  33. tr.transform(src, res);
  34.  
  35. }catch(Exception e){
  36.  
  37. }finally {
  38. System.out.println("Sucess");
  39. out.close();
  40. }
  41. }
  42.  
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement