This Example gives you a way to transform an XML File with XSL in a DOM document. JAXP (Java API for XML Processing) is an interface which provides parsing of xml documents. Here the Document BuilderFactory is used to create new DOM parsers. Some of the methods used in code given below for Transforming are:-
TransformerFactory factory = TransformerFactory.newInstance():-TransformerFactory is a class that is used to create Transformer objects. A TransformerFactory instance can be used to create Transformer and Templates objects.
Templates template = factory.newTemplates(new StreamSource(new FileInputStream(xslFilename))):-Creates a Template.Template is an Interface which may be used multiple times in a given session.
Xsl code for the program generated is:-
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
XMLtoXSL.java
/*
|
Output of the program:-
<html>
|
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.
Ask Questions? Discuss: Transforming an XML File with XSL
Post your Comment