[每日一学]apache camel|XSLT|SAXON
2016-04-01 01:19
761 查看
最近工作中,用到xslt文件来描述和配置xml文件的转换规则和业务逻辑,开始用jdk自带的TransformerFactory,
有严重的性能问题
后来用Saxon 的com.saxonica.config.ProfessionalTransformerFactory,性能提高了10以上。
example code:(from stackoverfow:http://stackoverflow.com/questions/5516580/using-saxon-and-xslt-to-transform-jdom-xml-documents)
有严重的性能问题
后来用Saxon 的com.saxonica.config.ProfessionalTransformerFactory,性能提高了10以上。
example code:(from stackoverfow:http://stackoverflow.com/questions/5516580/using-saxon-and-xslt-to-transform-jdom-xml-documents)
// Get a TransformerFactory System.setProperty("javax.xml.transform.TransformerFactory", "com.saxonica.config.ProfessionalTransformerFactory"); TransformerFactory tfactory = TransformerFactory.newInstance(); ProfessionalConfiguration config = (ProfessionalConfiguration)((TransformerFactoryImpl)tfactory).getConfiguration(); // Get a SAXBuilder SAXBuilder builder = new SAXBuilder(); //Build JDOM Document Document toTransform = builder.build(inputFileHandle); //Give it a Saxon wrapper DocumentWrapper docw = new DocumentWrapper(toTransform, inputHandle.getAbsolutePath(), config); // Compile the stylesheet Templates templates = tfactory.newTemplates(new StreamSource(styleSheet)); Transformer transformer = templates.newTransformer(); // Now do a transformation ByteArrayOutputStream outStream = new ByteArrayOutputStream(1024); transformer.transform(docw, new StreamResult(outStream)); ByteArrayInputStream inStream = new ByteArrayInputStream(outStream.toByteArray()); Document transformed = builder.build(inStream);
相关文章推荐
- [每日一学]apache camel|IBMWebsphere MQ header issue|MQRFH2 |MQSTR
- Apache+PHP+Mysql开发环境搭建
- Apache shiro登录成功后跳转到访问被拦截之前的路径
- Could not resolve archetype org.apache.maven.archetypes:maven-archetype-quickstart
- 新建maven库时,提示Could not resolve archetype org.apache.maven.archetypes:maven-archetype-quickstart:RELEA
- Svn+Apache服务器搭建指南
- Apache Hadoop2.6.2 小集群搭建
- Apache 403 Forbidden:You don't have permission to access / on this server.
- Apache 403 Forbidden:You don't have permission to access / on this server.
- 配置Apache支持PHP(附Apache和PHP下载链接)
- 安装xampp后apache不能启动解决方法
- Linux下Apache+mysql+PHP运行环境搭建教程
- mybatis报org.apache.ibatis.reflection.ReflectionException: Error instantiating null with invalid type
- Apache Cordova-Android框架原理研究笔记 I
- Apache多端口配置
- 安装apache2.2
- apache-thrift新手文档
- Apache 设置调整
- Apache Spark as a Service
- Apache服务器access_log解读和分析