[每日一学]apache camel|XSLT|SAXON
最近工作中,用到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)
// 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|XSLT|SAXON的更多相关文章
- [每日一学]apache camel简介
apache camel 是轻量级esb框架.如下是它的架构图: 它有几个比较重要的概念就是: 1.endpoint,所谓的endpoint,就是一种可以接收或发送数据的组件.可以支持多种协议,如jm ...
- [每日一学]apache camel|BDD方式开发apache camel|Groovy|Spock
开发apache camel应用,最好的方式就是tdd,因为camel的每个组件都是相互独立并可测试的. 现在有很多好的测试框架,用groovy的Spock框架的BDD(行为测试驱动)是比较优秀和好用 ...
- [每日一学]apache camel|IBMWebsphere MQ header issue|MQRFH2 |MQSTR
最近工作中,遇到一个很奇怪的问题: 现象:在camel开发中,通过 IBM Websphere MQ 给assasin 发送xml的message时,会多出<mcd>等这样的header出 ...
- Apache Camel
Apache Camel 1 import org.apache.camel.CamelContext; import org.apache.camel.builder.RouteBuilder; i ...
- Apache Camel之FTP组件学习
写在最前面 哎,最近提了离职,手头的活也基本上清理的差不多了.想着这个把月可以舒服的晃悠晃悠的离开,但是运维的小伙伴总是不架势,走之前还是提了个新需求. 先说下需求吧,我们的系统概括的讲就是一个接口系 ...
- spring boot + apache camel 传输文件
一 sftp搭建略 这里简单说一下为什么使用sftp.ftp和sftp各有优点,差别并不是太大.sftp安全性好,性能比ftp低.ftp对于java来说并不复杂,效率也高.之所以使用sftp主要是可以 ...
- Apache Camel继承Spring Boot 实现文件远程复制和转移
pom.xml <dependency> <groupId>org.apache.camel</groupId> <artifactId>camel-f ...
- Apache Camel,Spring Boot 实现文件复制,转移 (转)
基本框架 Apache Camel Spring Boot Maven 开发过程 1.新建一个POM(quickstart)项目,在POM文件中添加Camel和Spring Boot的依赖 <p ...
- Apache Camel 与 Spring Boot 集成,通过FTP定时采集、处理文件 (转)
1.概要: 本项目主要是通过在Spring平台上配置Camel.FTP,实现定时从FTP服务器下载文件到本地.解析文件.存入数据库等功能. 2.搭建空项目: Spring Boot有几种自动生成空项目 ...
随机推荐
- HDU6623 思维题(n分解成质因子的形式,问最小的幂是多少)
题目大意:给你一个数n,把它分解为素数的幂次的乘积的形式:n=p1^e1 * p2^e2 * .......pk^ek 求最小的幂次是多少 n=le18 分析: 首先我们肯定是不可以枚举1e18的因 ...
- legend3---Homestead中Laravel项目502 Bad Gateway
legend3---Homestead中Laravel项目502 Bad Gateway 一.总结 一句话总结: 用查看错误日志的方法解决错误:(/var/log/nginx/.log) 1.home ...
- Make jQuery throw error when it doesn't match an element
Make jQuery throw error when it doesn't match an element 解答1 You could make a plugin to use to ensur ...
- leetcode-mid-backtracking -22. Generate Parentheses-79 Word Search -NO
mycode 错误,因为借鉴了Number of Islands问题中的方法,导致在for循环中即使已经出现了答案,也还会继续遍历.但是两个题目的不同时,island需要找出所有的情况,这个题只需 ...
- leetcode-mid-backtracking -22. Generate Parentheses-NO
mycode 没有思路,大早上就有些萎靡,其实和上一个电话号码的题如出一辙啦 参考: class Solution(object): def generateParenthesis(self, ...
- mysql数据库连接错误10060
今天在使用mysql数据库的时候,出现错误ERROR 2003 (HY000): Can't connect to MySQL server on 'localhost' (10060) 我在网上一顿 ...
- Django 优秀资源大全
版权: https://github.com/haiiiiiyun/awesome-django-cn 转自:https://www.jianshu.com/p/38c4dd6d8e28 Awesom ...
- 【ABAP系列】SAP ABAP SY-SUBRC的含义解析
公众号:SAP Technical 本文作者:matinal 原文出处:http://www.cnblogs.com/SAPmatinal/ 原文链接:[ABAP系列]SAP ABAP SY-SUBR ...
- Java多线程学习——任务定时调度
Timer 本身就是一个线程,最主要的方法就是schedule(). schedule()的参数介绍: schedule(TimerTask task, long delay) //延迟delay毫秒 ...
- Java回调机制的理解
用一句话讲明回调机制就是,在A类里面拥有一个类B的对象,调用B类的某个方法并把自身引用传入,在B类的这个方法里面又通过传进来的A的引用来调用A类的某个方法(这个最后调用的A类的方法就叫做回调方法). ...