摘要
在用XML(e Xtensible Markup Language)Schema校验来判断XML文档合法性的过程中,目前LIBXML2所采用的逐层遍历校验法对3层及以下嵌套效率低下,对多于3层嵌套的校验法失效。针对这一问题,文中提出一种新算法,可有效避免逐层遍历法验证的缺陷。先计算XML文档中某待验证元素出现的次数,然后把该次数分解为XSD(XML Schema Definition)文档中所定义的该元素允许出现次数区间内整数的线性组合,计算出所有线性组合中系数和的最小值和最大值。若计算出的系数和范围与XSD文档定义的范围有交集,则验证通过,否则不通过。利用所提算法,对多嵌套和max Occurs较大的XML文档,验证效率可提高两个数量级。
When using XML ( eXtensible Markup Language) Schema to verify the validation of XML document, the present traversal loop method used by LIBXML2 has low efficiency for no more than 3-loop,and will be invalid for more than 3-loop nested document. To solve the problem,propose a new verification algorithm and it can overcome the defect of traversal loop method. First,the times of element that will be validated in the XML document is calculated, then this times is divided into the linear combination of the permitted times section that defined in XSD document,next is to calculate the maximum and minimum of summation of the coefficient in all the linear combination. If the range of the coefficient summation can overlap with the range that defined in XSD document,then the validation passes, otherwise falls. Using this method,the validation efficiency can increase two orders for the XML document with multi-loop nested and bigger maxOccurs.
出处
《计算机技术与发展》
2015年第8期123-127,共5页
Computer Technology and Development
基金
国家自然科学基金资助项目(11275099)