[XML learning notes] [3.3] XSLT using JAXP

xiaoxiao2021-03-06  43

Finally, let's see how to call XSLT through JAXP, the same simple:

/ ** /

/ * * CREATED ON 2005-2-24 * All rights reserved. * * /

package sean.home.test; import java.io.File; import javax.xml.transform.Source; import javax.xml.transform.Transformer; import javax.xml.transform.TransformerFactory; import javax.xml.transform.stream. StreamResult; import javax.xml.transform.stream.streamsource;

/ ** /

/ ** * @Author sean gao *

* gaoyuxiang@gmail.com * * * /

public

Class

Xsltest

{Public static void main (String [] args) throws Exception {TransformerFactory factory = TransformerFactory.newInstance (); Source xmlSource = new StreamSource (new File (args [0])); Source xlsSource = new StreamSource (new File (args [ 1])); Transformer Transformer = Factory.NewTransformer (Xlssource); Transformer.Transform (Xmlsource, New StreamResult (New File (Args [3]));}}

Is it true that the interface of SAX, DOM? It is also obtained by the factory method to obtain a Transformer instance and then provide input and output file paths, use it to TRANSFORM.

转载请注明原文地址:https://www.9cbs.com/read-53970.html

New Post(0)