In some cases, it makes sense to outsource the entire handling of an XML document to an external XSL stylesheet, a process in some respects similar to the use of XPath. With XSL stylesheets, you can create an output document by selecting nodes from the input document and merging their content with stylesheet content, based on pattern rules.
If an application changes the structure and content of an XML document producing a new document, it may be better and easier to use a stylesheet to handle the work rather than writing a Java program that does the same job. The stylesheet is usually stored in an external file, allowing you to change it on the fly, without the need to recompile. Below diagram illustrates the same.
For deriving a transformation result for a given XML document and XSLT Stylesheet, J2SE includes a standard API "JAXP (Java API for XML Processing)" for processing XML. Using this allows you to easily create a program that performs XLST transformation.
If an application changes the structure and content of an XML document producing a new document, it may be better and easier to use a stylesheet to handle the work rather than writing a Java program that does the same job. The stylesheet is usually stored in an external file, allowing you to change it on the fly, without the need to recompile. Below diagram illustrates the same.
For deriving a transformation result for a given XML document and XSLT Stylesheet, J2SE includes a standard API "JAXP (Java API for XML Processing)" for processing XML. Using this allows you to easily create a program that performs XLST transformation.
As you can see, when using JAXP to perform XSLT transformation, you create an instance of class javax.xml.transform.Transformer . When creating this instance, you must first create a factory class javax.xml.transform.TransformerFactory instance.

No comments:
Post a Comment