关于项目自动化测试架构的改良计划 - 解析XInclude标记
发表于:2025-12-03 作者:千家信息网编辑
千家信息网最后更新 2025年12月03日,因为在test_suite.xml中,我们多处使用了XInclude标记,他们会被申明在一个叫"http://www.w3.org/2001/XInclude" 的名字空间中,并且引入部分用xi:in
千家信息网最后更新 2025年12月03日关于项目自动化测试架构的改良计划 - 解析XInclude标记
因为在test_suite.xml中,我们多处使用了XInclude标记,他们会被申明在一个叫"http://www.w3.org/2001/XInclude" 的名字空间中,并且引入部分用xi:include来声明,我们这个类的作用就是把这些所有的
/** * This class will handle converting a xinclude+xpointer marked xml file to a normal xml file * Because of the shortage of the current jdk ,it only support the xPointer with element instead of NCName *@author cwang58 *@created date: Jun 10, 2013 */public class XIncludeConverter { /** * this method will handle change the XInclude+XPointer marked xml as normal xml * @param origialXML the original xml which has the xInclude feature * @return the parsedXML without the xInclude feature */ public static String convertXInclude2NormalXML(String originalXML) throws SAXException,ParserConfigurationException,TransformerConfigurationException,IOException,TransformerException{ DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); //open up the namespace aware so that it can recognize the "xi" namespace factory.setNamespaceAware(true); //let this SAXParser support XInclude factory.setXIncludeAware(true); //factory.setValidating(true); //ignore all the comments added in the source document factory.setIgnoringComments(true); DocumentBuilder docBuilder = factory.newDocumentBuilder(); Document doc = docBuilder.parse(new InputSource(new ByteArrayInputStream(originalXML.getBytes("utf-8")))); Transformer transformer = TransformerFactory.newInstance().newTransformer(); //format the output xml string so it support indent and more readable transformer.setOutputProperty(OutputKeys.INDENT, "yes"); //initialize StreamResult with File object to save to file StreamResult result = new StreamResult(new StringWriter()); DOMSource source = new DOMSource(doc); transformer.transform(source, result); return result.getWriter().toString(); } 这里讲一个小插曲,其实,W3C中,XInclude经常和Xpointer联合起来应用的,xpointer可以帮助来定位目标文件的某个小片段而不是整个目标文件,定位方法可以用element(),或者xpointer(),如果element的话,可以用(/1/2/3)这种方式来定位DOM,或者基于 id,对应java的解析框架是xerce,但是非常不幸运的是,最新版本的xerce框架只支持element(/1/3/4/5)这种定位,而对于基于schema-id的方式,也就是某个element声明了id的情况,它没办法定位,但是未来可能会支持这个功能。
http://xerces.apache.org/xerces2-j/faq-xinclude.html#faq-8

基于上述的局限性,我决定只采用xi:include来包含全部文件,然后局部调整的做法,并且绕过xpointer。
所以实现代码如上所示,事实上从JDK 1.6开始,他已经提供了对XInclude的支持,内部是委托给xerce来实现的,这是对应架构图的第3-4步骤。
定位
文件
支持
方式
框架
目标
部分
架构
标记
不幸
也就是
事实
事实上
代码
作用
做法
办法
功能
名字
如上
数据库的安全要保护哪些东西
数据库安全各自的含义是什么
生产安全数据库录入
数据库的安全性及管理
数据库安全策略包含哪些
海淀数据库安全审计系统
建立农村房屋安全信息数据库
易用的数据库客户端支持安全管理
连接数据库失败ssl安全错误
数据库的锁怎样保障安全
软件开发人员要考证吗
什么是工控网络安全
武汉科佰汇网络技术有限公司
香港恒生互联网科技指数
网络安全公司世界排名
数据库增量数据查询展示
网络安全的管制
数据库系统安全性视频
怎么加强数据库安全防范
美国政府各部门网络安全财政预算
三星网络安全证书下载
300亿网络安全
沈阳工学院计算机网络技术代号
怎么做平台软件开发
中学生关于网络安全的故事
问道单机数据库密码哪里改
方舟服务器名称乱码
rsr2015数据库
dnf服务器崩溃的现象
清镇网络安全系统哪个好用
华为服务器开不了机
问道怎么改数据库
迷你世界怎么免费开服务器电脑版
医疗单位网络安全的方案
浦东新区新能源网络技术工业化
ar软件开发哪家好
网络安全调查报告怎么做
亿科网络技术有限公司
软件开发行业前端设计
小学生网络技术有