XML file verification method and device

文档序号:1628443 发布日期:2020-01-14 浏览:19次 中文

阅读说明:本技术 Xml文件验证方法及装置 (XML file verification method and device ) 是由 王晓炜 顾颖颖 张潇丹 谢琳 于 2019-09-20 设计创作,主要内容包括:本发明公开了一种XML文件验证方法及装置,其中方法包括:接口文件,待验证的XML文件和所述待验证的XML文件对应的XML标准报文结构文件;根据所述XML标准报文结构文件,确定所述待验证的XML文件的格式验证规则;根据所述接口文件,确定所述待验证的XML文件的内容验证规则和逻辑验证规则;根据所述格式验证规则,内容验证规则和逻辑验证规则,对待验证的XML文件进行验证。本发明对XML文件进行验证,无需进行手工比对,有效节省人力物力,提高了比对效率和结果的准确率。(The invention discloses a method and a device for verifying an XML file, wherein the method comprises the following steps: the XML document to be verified and the XML standard message structure document corresponding to the XML document to be verified; determining a format verification rule of the XML file to be verified according to the XML standard message structure file; determining a content verification rule and a logic verification rule of the XML file to be verified according to the interface file; and verifying the XML file to be verified according to the format verification rule, the content verification rule and the logic verification rule. The invention verifies the XML file without manual comparison, effectively saves manpower and material resources and improves the comparison efficiency and the accuracy of the result.)

1. An XML document verification method, comprising:

acquiring an interface file, an XML file to be verified and an XML standard message structure file corresponding to the XML file to be verified;

determining a format verification rule of the XML file to be verified according to the XML standard message structure file;

determining a content verification rule and a logic verification rule of the XML file to be verified according to the interface file;

and verifying the XML file to be verified according to the format verification rule, the content verification rule and the logic verification rule.

2. The method according to claim 1, wherein the interface file, the XML file to be verified, and the XML standard message structure file corresponding to the XML file to be verified are obtained as follows:

acquiring a script parameter configuration file;

extracting a file corresponding to the path information from a server or a local folder according to the path information in the script parameter configuration file, wherein the path information comprises: the path information of the interface file, the path information of the XML file to be verified and the path information of the XML standard message structure file.

3. The method according to claim 1, wherein determining the format validation rule of the XML file to be validated according to the XML standard message structure file comprises: extracting a label name, a label sequence and a loop body from the XML standard message structure file, and taking the label name, the label sequence and the loop body as a format verification rule of the XML file to be verified;

the verification of the XML file to be verified according to the format verification rule comprises the following steps: and comparing the tag name, the tag sequence and the loop body extracted from the XML standard message structure file with the tag name, the tag sequence and the loop body of the XML file to be verified respectively.

4. The method of claim 1, wherein determining the content validation rules of the XML file to be validated according to the interface file comprises: extracting the data type and the data length of each label from the interface file, and taking the data type and the data length of each label as a content verification rule of the XML file to be verified;

verifying the XML file to be verified according to the content verification rule comprises the following steps: and comparing the data type and the data length of each label extracted from the interface file with the data type and the data length of the corresponding label in the XML file to be verified.

5. The method of claim 1, wherein determining the logical validation rules for the XML file to be validated based on the interface file comprises: extracting a logic rule statement from the interface file, and taking the logic rule statement as a logic verification rule of the XML file to be verified;

verifying the XML file to be verified according to the logic verification rule comprises the following steps: and verifying the XML file to be verified according to the logic rule statements extracted from the interface file.

6. An apparatus for validating an XML document, comprising:

the file acquisition module is used for acquiring an interface file, an XML file to be verified and an XML standard message structure file corresponding to the XML file to be verified;

the first rule module is used for determining the format verification rule of the XML file to be verified according to the XML standard message structure file;

the second rule module is used for determining the content verification rule and the logic verification rule of the XML file to be verified according to the interface file;

and the verification module is used for verifying the XML file to be verified according to the format verification rule, the content verification rule and the logic verification rule.

7. The apparatus of claim 6, wherein the file obtaining module is further configured to obtain the interface file, the XML file to be verified, and the XML standard message structure file corresponding to the XML file to be verified as follows:

acquiring a script parameter configuration file;

extracting a file corresponding to the path information from a server or a local folder according to the path information in the script parameter configuration file, wherein the path information comprises: the path information of the interface file, the path information of the XML file to be verified and the path information of the XML standard message structure file.

8. The apparatus of claim 6, wherein the first rule module is further to: extracting a label name, a label sequence and a loop body from the XML standard message structure file, and taking the label name, the label sequence and the loop body as a format verification rule of the XML file to be verified;

the verification module is further to: and comparing the tag name, the tag sequence and the loop body extracted from the XML standard message structure file with the tag name, the tag sequence and the loop body of the XML file to be verified respectively.

9. The apparatus of claim 6, wherein the second rule module is further to: extracting the data type and the data length of each label from the interface file, and taking the data type and the data length of each label as a content verification rule of the XML file to be verified;

the verification module is further to: and comparing the data type and the data length of each label extracted from the interface file with the data type and the data length of the corresponding label in the XML file to be verified.

10. The apparatus of claim 6, wherein the second rule module is further to: extracting a logic rule statement from the interface file, and taking the logic rule statement as a logic verification rule of the XML file to be verified;

the verification module is further to: and verifying the XML file to be verified according to the logic rule statements extracted from the interface file.

11. A computer device comprising a memory, a processor and a computer program stored on the memory and executable on the processor, wherein the processor implements the method of any one of claims 1 to 5 when executing the computer program.

12. A computer-readable storage medium, characterized in that the computer-readable storage medium stores a computer program for executing the method of any one of claims 1 to 5.

Technical Field

The invention relates to the technical field of bank data processing, in particular to a method and a device for verifying an XML file.

Background

Extensible Markup Language (XML) is a general Markup Language that describes data through a series of simple and easy-to-establish tags, which is easy to grasp and use. In the Internet environment, XML has become a powerful tool for currently processing structured document information. With the wide application of XML, how to verify XML files, and thus ensure the correctness of XML files, has also been paid attention gradually.

The existing XML verification method is usually implemented by manually comparing XML texts one by testers according to interface files, so that a large amount of manpower and material resources are consumed, and the comparison efficiency and the result accuracy are very low.

Disclosure of Invention

The embodiment of the invention provides an XML file verification method, which is used for verifying XML files, saves manpower and material resources, and improves comparison efficiency and result accuracy, and comprises the following steps:

acquiring an interface file, an XML file to be verified and an XML standard message structure file corresponding to the XML file to be verified;

determining a format verification rule of the XML file to be verified according to the XML standard message structure file;

determining a content verification rule and a logic verification rule of the XML file to be verified according to the interface file;

and verifying the XML file to be verified according to the format verification rule, the content verification rule and the logic verification rule.

The embodiment of the invention provides an XML file verification device, which is used for verifying XML files, saves manpower and material resources, and improves comparison efficiency and result accuracy, and the method comprises the following steps:

the file acquisition module is used for acquiring an interface file, an XML file to be verified and an XML standard message structure file corresponding to the XML file to be verified;

the first rule module is used for determining the format verification rule of the XML file to be verified according to the XML standard message structure file;

the second rule module is used for determining the content verification rule and the logic verification rule of the XML file to be verified according to the interface file;

and the verification module is used for verifying the XML file to be verified according to the format verification rule, the content verification rule and the logic verification rule.

The embodiment of the invention also provides computer equipment which comprises a memory, a processor and a computer program which is stored on the memory and can run on the processor, wherein the processor realizes the XML file verification method when executing the computer program.

The embodiment of the invention also provides computer equipment which comprises a memory, a processor and a computer program which is stored on the memory and can run on the processor, wherein the processor realizes the XML file verification method when executing the computer program.

Compared with the scheme that in the prior art, a tester obtains an XML text and then manually compares the XML text one by one according to an interface file, the embodiment of the invention obtains the interface file, the XML file to be verified and the XML standard message structure file corresponding to the XML file to be verified; determining a format verification rule of the XML file to be verified according to the XML standard message structure file; determining a content verification rule and a logic verification rule of the XML file to be verified according to the interface file; and verifying the XML file to be verified according to the format verification rule, the content verification rule and the logic verification rule. According to the embodiment of the invention, the format, the content and the logic verification rule of the XML file to be verified are determined according to the XML standard message structure file and the interface file, and then the XML file to be verified is verified according to the rule without manual comparison, so that manpower and material resources are effectively saved, and the comparison efficiency and the result accuracy are improved.

Drawings

In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings used in the description of the embodiments or the prior art will be briefly described below, it is obvious that the drawings in the following description are only some embodiments of the present invention, and for those skilled in the art, other drawings can be obtained according to the drawings without creative efforts. In the drawings:

FIG. 1 is a diagram illustrating an XML document verification method according to an embodiment of the present invention;

FIG. 2 is a diagram of a structure of an XML document verification apparatus according to an embodiment of the present invention.

Detailed Description

In order to make the objects, technical solutions and advantages of the embodiments of the present invention more apparent, the embodiments of the present invention are further described in detail below with reference to the accompanying drawings. The exemplary embodiments and descriptions of the present invention are provided to explain the present invention, but not to limit the present invention.

In order to verify an XML file, save manpower and material resources, and improve comparison efficiency and result accuracy, an embodiment of the present invention provides an XML file verification method, which, as shown in fig. 1, may include:

step 101, obtaining an interface file, an XML file to be verified and an XML standard message structure file corresponding to the XML file to be verified;

step 102, determining a format verification rule of the XML file to be verified according to the XML standard message structure file;

103, determining a content verification rule and a logic verification rule of the XML file to be verified according to the interface file;

and 104, verifying the XML file to be verified according to the format verification rule, the content verification rule and the logic verification rule.

As shown in fig. 1, in the embodiment of the present invention, an interface file, an XML file to be verified, and an XML standard message structure file corresponding to the XML file to be verified are obtained; determining a format verification rule of the XML file to be verified according to the XML standard message structure file; determining a content verification rule and a logic verification rule of the XML file to be verified according to the interface file; and verifying the XML file to be verified according to the format verification rule, the content verification rule and the logic verification rule. According to the embodiment of the invention, the format, the content and the logic verification rule of the XML file to be verified are determined according to the XML standard message structure file and the interface file, and then the XML file to be verified is verified according to the rule without manual comparison, so that manpower and material resources are effectively saved, and the comparison efficiency and the result accuracy are improved.

9页详细技术资料下载
上一篇:一种医用注射器针头装配设备
下一篇:电网设备状态评价报告生成的方法与系统

网友询问留言

已有0条留言

还没有人留言评论。精彩留言会获得点赞!

精彩留言,会给你点赞!