计算机技术与发展
計算機技術與髮展
계산궤기술여발전
COMPUTER TECHNOLOGY AND DEVELOPMENT
2015年
8期
123-127
,共5页
XML文档%复杂类型%LIBXML2%XML Schema校验
XML文檔%複雜類型%LIBXML2%XML Schema校驗
XML문당%복잡류형%LIBXML2%XML Schema교험
XML documents%complex type%LIBXML2%XML Schema validation
在用XML( eXtensible Markup Language) Schema校验来判断XML文档合法性的过程中,目前LIBXML2所采用的逐层遍历校验法对3层及以下嵌套效率低下,对多于3层嵌套的校验法失效。针对这一问题,文中提出一种新算法,可有效避免逐层遍历法验证的缺陷。先计算XML文档中某待验证元素出现的次数,然后把该次数分解为XSD( XML Schema Def-inition)文档中所定义的该元素允许出现次数区间内整数的线性组合,计算出所有线性组合中系数和的最小值和最大值。若计算出的系数和范围与XSD文档定义的范围有交集,则验证通过,否则不通过。利用所提算法,对多嵌套和maxOccurs较大的XML文档,验证效率可提高两个数量级。
在用XML( eXtensible Markup Language) Schema校驗來判斷XML文檔閤法性的過程中,目前LIBXML2所採用的逐層遍歷校驗法對3層及以下嵌套效率低下,對多于3層嵌套的校驗法失效。針對這一問題,文中提齣一種新算法,可有效避免逐層遍歷法驗證的缺陷。先計算XML文檔中某待驗證元素齣現的次數,然後把該次數分解為XSD( XML Schema Def-inition)文檔中所定義的該元素允許齣現次數區間內整數的線性組閤,計算齣所有線性組閤中繫數和的最小值和最大值。若計算齣的繫數和範圍與XSD文檔定義的範圍有交集,則驗證通過,否則不通過。利用所提算法,對多嵌套和maxOccurs較大的XML文檔,驗證效率可提高兩箇數量級。
재용XML( eXtensible Markup Language) Schema교험래판단XML문당합법성적과정중,목전LIBXML2소채용적축층편력교험법대3층급이하감투효솔저하,대다우3층감투적교험법실효。침대저일문제,문중제출일충신산법,가유효피면축층편역법험증적결함。선계산XML문당중모대험증원소출현적차수,연후파해차수분해위XSD( XML Schema Def-inition)문당중소정의적해원소윤허출현차수구간내정수적선성조합,계산출소유선성조합중계수화적최소치화최대치。약계산출적계수화범위여XSD문당정의적범위유교집,칙험증통과,부칙불통과。이용소제산법,대다감투화maxOccurs교대적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 ele-ment 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 pas-ses,otherwise fails. Using this method,the validation efficiency can increase two orders for the XML document with multi-loop nested and bigger maxOccurs.