This Example shows you how to Transform XML with the XSLT 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:-
Source source = new StreamSource("Document2.xml"):-creates a Streamsource.StreamSource is a class that acts as an holder for a transformation Source in the form of a stream of XML markup.
Result result = new StreamResult(System.out):- creates a result.StreamResult class acts as an holder for a transformation result.
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.
Xsl code for the program generated is:-
<?xml version="1.0" encoding="UTF-8"?>
|
Xml code for the program generated is:-
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
XMLwithXSLT.java
/*
|
Output of the program:-
Roseindia.net
|
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 XML with XSLT View All Comments
Post your Comment