packageblog.youkuaiyun.com.arui;importjava.io.*;importjavax.xml.transform.*;importjavax.xml.transform.stream.*;publicclassBasicXsl...{/***//***Thismethodappliesthexslfiletoinfile,andwritestheoutputtoout*file.**@paraminFilename*infilepath*@paramoutFilename*outfilepath*@paramxslFilename*xslfilepath*/publicstaticvoidxsl(StringinFilename,StringoutFilename,StringxslFilename)...{try...{//CreatetransformerfactoryTransformerFactoryfactory=TransformerFactory.newInstance();//UsethefactorytocreateatemplatecontainingthexslfileTemplatestemplate=factory.newTemplates(newStreamSource(newFileInputStream(xslFilename)));//UsethetemplatetocreateatransformerTransformerxformer=template.newTransformer();//PreparetheinputandoutputfilesSourcesource=newStreamSource(newFileInputStream(inFilename));Resultresult=newStreamResult(newFileOutputStream(outFilename));//Applythexslfiletothesourcefileandwritetheresulttothe//outputfilexformer.transform(source,result);}catch(FileNotFoundExceptione)...{//Filenotfound}catch(TransformerConfigurationExceptione)...{//AnerroroccurredintheXSLfile}catch(TransformerExceptione)...{//AnerroroccurredwhileapplyingtheXSLfile//Getlocationoferrorininputfile}}}