BizTalk Utilities CV ,   Jobs ,   Code library  
 
Home Page
XALAN
Overview of XALAN - Java
<< WCF, WS, SOAP
XHTML >>

By :Mark Wilson
I am the creator of TopXML. I am available for international and local (Australia) contracts. I am a Solution Architect/Business Analyst. I have worked in IT in several countries (NZ, Australia, South Africa, UK) building and training teams for government and very large non-governmental organizations. I am ex-Microsoft Consulting Services. I wrote the first book on Microsoft XML published in 2000 called XML Programming with VB and ASP. Most recently I have been building tools for the SEO industry. Ask me for a 37 point SEO health-checkup for your website.
First posted :03/24/2008
Times viewed :1144

 

The Usage of XALAN

The basic steps required to use XALAN are below:

  1. Instantiate javax.xml.transform.TransformerFactory

TransformerFactory is an abstract class. It has a static method netInstance() to create an instance of TransformerFactory. This method instantiates the concrete subclass designated by the javax.xml.transform.TransformerFactory system property.

The default setting for this system property is org.apache.xalan.processor.TransformerFactoryImpl.

TransformerFactory tFactory = TransformerFactory.newInstance();

  1. Use instance of TransformerFactory to get an instance of javax.xml.transform.Transformer from your stylesheet source.

The TransformerFactory’s newTransformer(Source xslSource) method processes the stylesheet Source into a Templates object and returns a Transformer that you can use to perform a transformation. You can provide different input sources to this method.

    • You can provide a DOMSource
    • You can provide  a StreamSource
    • You can also provide a SAXSource

StreamSource source = new StreamSource(stylesheetURI);

  1. Perform the transformation using javax.xml.transform.Transformer instance.

Use the Transformer transform(Source xmlSource, Result transformResult) method to transform the XML Source and place the transformation output in a Result object.

Like Step2, you can supply the XML Source in the form of a StreamSource, DOMSource, or SAXSource. Likewise, the Result may be a StreamResult, DOMResult, or SAXResult.

Transformer transformer = tFactory.newTransformer(source);

            StreamSource sourceXML = new StreamSource(xmlfileURI);

            StreamResult result = new StreamResult(outURI);

            transformer.transform(sourceXML, result);

Note: If you plan to use the stylesheet Source to transform multiple XML Sources, you should use the TransformerFactory newTemplates(Source xslSource) method to explicitly generate a Templates object. For each transformation, use the Templates object to generate a new Transformer.

                  TransformerFactory tFactory = TransformerFactoryImpl.newInstance();

            StreamSource source = new StreamSource(stylesheetURI);

            Templates templates = tFactory.newTemplates(source);

            Transformer transformer = templates.newTransformer();

            StreamSource sourceXML = new StreamSource(xmlfileURI);

            StreamResult result = new StreamResult(outURI);

            transformer.transform(sourceXML, result);


Rate this article on a scale of 1 to 10

Your vote :  


 

Recent Jobs

Integration Specialist Needed - Wor
Virtualization Server Infrastructur
A great opportunity to Digital Vide
here is a greate opportunity as a S
A great opportunity as a Network En

View all Jobs (Add yours)
View all CV (Add yours)



Information Online

swimming pool builder
chicago web site design
spfxmasks
Cheap Web Hosting
conference calling
Prada sunglasses
answering service


    Email TopXML  

Front Page Daily Stuff TopXML Forum XML blogs XML Newsgroups BizTalk Biztalk Utilities Biztalk Utilities Tutorial B2B SAP XML Microsoft .NET Dotnet System XML Soapformatter SQLXML XMLserializer XQuery PHP PHP SimpleXML PHP XML Dom PHP XML RPC PHP XSLT Java Java Java XML Xalan Microsoft ASP ASP Schemas XML SQL Server XML XMLDom XSL XSL Tutorial XSLT Stylesheets General Javascript CSS XHTML WAP