CN101000622A - Method and device for checking validity of expandable mark language mode - Google Patents
Method and device for checking validity of expandable mark language mode Download PDFInfo
- Publication number
- CN101000622A CN101000622A CN 200710000087 CN200710000087A CN101000622A CN 101000622 A CN101000622 A CN 101000622A CN 200710000087 CN200710000087 CN 200710000087 CN 200710000087 A CN200710000087 A CN 200710000087A CN 101000622 A CN101000622 A CN 101000622A
- Authority
- CN
- China
- Prior art keywords
- xml
- schema
- database
- xml information
- information
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Granted
Links
Landscapes
- Information Retrieval, Db Structures And Fs Structures Therefor (AREA)
- Document Processing Apparatus (AREA)
Abstract
本发明涉及Internet数据业务领域中一种校验可扩展标记语言模式有效性的方法及装置。所述装置包括:Schema转换模块,用于将根据Schema构造的XML转换为数据库表结构;XML信息插入模块,用于将所述转换后的XML信息自顶向下插入具有所述表结构的数据库中;校验模块,用于在所述XML信息插入模块将所述XML信息插入具有所述表结构的数据库过程中,利用数据库的约束机制校验所述XML信息是否满足Schema的规范要求。还可进一步包括:警告模块,用于在校验模块校验出XML信息不满足Schema的规范要求时发出警告。本发明借助当前数据库技术的强大功能,方便、快捷的检验XML信息的正确性,保证了在进程之间使用XML进行接口交互时,使信息满足数据合法性要求。
The invention relates to a method and a device for checking the validity of an extensible markup language model in the field of Internet data services. The device includes: a Schema conversion module for converting the XML constructed according to the Schema into a database table structure; an XML information insertion module for inserting the converted XML information into the database with the table structure from top to bottom Middle; a verification module, used to verify whether the XML information meets the specification requirements of the Schema by using the constraint mechanism of the database during the process of inserting the XML information into the database with the table structure by the XML information insertion module. It may further include: a warning module, configured to issue a warning when the verification module verifies that the XML information does not meet the specification requirements of the Schema. The invention checks the correctness of the XML information conveniently and quickly by means of the powerful function of the current database technology, and ensures that the information meets the data legitimacy requirements when the XML is used for interface interaction between processes.
Description
技术领域technical field
本发明涉及Internet数据业务领域,尤其涉及一种校验可扩展标记语言模式有效性的方法及装置。The invention relates to the field of Internet data services, in particular to a method and device for checking the validity of an extensible markup language model.
背景技术Background technique
XML(可扩展标记语言)中语义表达的方式越来越被广泛应用于现在的应用软件设计之中,很多软件用它来定义接口之间的交互格式。另一方面进程之间使用XML格式进行交互的时候,服务器进程往往需要对客户进程的XML信息进行Schema(模式,即对一个或一组XML文件的机构的说明,也可以对其内容进行一些约束性和语义上的说明)校验。The semantic expression in XML (Extensible Markup Language) is more and more widely used in the current application software design, and many software use it to define the interaction format between interfaces. On the other hand, when the XML format is used to interact between processes, the server process often needs to perform Schema (mode, that is, a description of the organization of one or a group of XML files, and some constraints on its content. and semantics) checks.
但是由于XML语言语法的松散性,程序员在构造XML文本信息的时候,开始时往往难以保证其正确性,是否符合相应需求的Schema的有效性约束,需要等到与服务器完全确认后才能够确定,而为此往往需要花费很多的精力,而且效率很低。However, due to the looseness of the XML language grammar, when programmers construct XML text information, it is often difficult to ensure its correctness at the beginning. Whether it meets the validity constraints of the corresponding Schema needs to be fully confirmed with the server. And often need to spend a lot of energy for this reason, and efficiency is very low.
发明内容Contents of the invention
本发明实施例提供一种校验可扩展标记语言Schema有效性的方法及装置,解决了现有技术构造XML信息时无法保证正确性的问题。Embodiments of the present invention provide a method and device for verifying the validity of an Extensible Markup Language Schema, which solves the problem that the prior art cannot guarantee correctness when constructing XML information.
本发明实施例是通过以下技术方案实现的:Embodiments of the present invention are achieved through the following technical solutions:
本发明实施例提供一种校验可扩展标记语言模式有效性的方法,包括:An embodiment of the present invention provides a method for verifying the validity of an Extensible Markup Language schema, including:
将可扩展标记语言XML的模式Schema转换为数据库表结构;Convert the schema Schema of Extensible Markup Language XML into a database table structure;
将所述转换后的XML信息自顶向下插入具有所述表结构的数据库中;Inserting the converted XML information from top to bottom into the database with the table structure;
利用数据库的约束机制校验所述XML信息是否满足Schema的规范要求。The constraint mechanism of the database is used to check whether the XML information satisfies the specification requirements of the Schema.
本发明实施例提供一种校验可扩展标记语言模式有效性的装置,包括:An embodiment of the present invention provides a device for verifying the validity of an Extensible Markup Language schema, including:
模式Schema转换模块,用于将根据Schema构造的可扩展标记语言XML转换为数据库表结构;Mode Schema conversion module, used for converting the Extensible Markup Language XML constructed according to the Schema into a database table structure;
XML信息插入模块,用于将所述转换后的XML信息自顶向下插入具有所述表结构的数据库中;XML information insertion module, used to insert the converted XML information from top to bottom into the database with the table structure;
校验模块,用于在所述XML信息插入模块将所述XML信息插入具有所述表结构的数据库过程中,利用数据库的约束机制校验所述XML信息是否满足Schema的规范要求。The verification module is used to verify whether the XML information meets the specification requirements of the Schema by using the constraint mechanism of the database during the process of inserting the XML information into the database with the table structure by the XML information insertion module.
由上述本发明提供的技术方案可以看出,本发明通过将XML信息转换成数据库表结构,再将所述XML信息插入具有所述表结构的数据库中,利用数据库的已有功能实现了对XML的Schema有效性的校验。借助当前数据库技术的强大功能,方便、快捷的检验XML信息的正确性,保证了在进程之间使用XML进行接口交互时,使信息满足数据合法性要求。As can be seen from the technical solution provided by the present invention above, the present invention converts the XML information into a database table structure, then inserts the XML information into the database with the table structure, and utilizes the existing functions of the database to realize the XML Check the validity of the schema. With the help of the powerful functions of the current database technology, the correctness of XML information can be checked conveniently and quickly, ensuring that the information meets the data legality requirements when using XML for interface interaction between processes.
附图说明Description of drawings
图1为本发明所述方法一种实施例流程图;Fig. 1 is a kind of embodiment flowchart of method of the present invention;
图2为本发明所述装置一种实施例模块示意图。Fig. 2 is a schematic diagram of a module of an embodiment of the device of the present invention.
具体实施方式Detailed ways
本发明实施例将XML信息的Schema校验交给数据库来处理,即,将根据Schema构造的XML树型结构转换为数据库的表结构,将所述XML信息插入具有所述表结构的数据库中,利用数据库已有的功能校验XML信息是否满足Schema的规范要求。In the embodiment of the present invention, the Schema verification of XML information is handed over to the database for processing, that is, the XML tree structure constructed according to the Schema is converted into a table structure of the database, and the XML information is inserted into the database with the table structure, Use the existing functions of the database to verify whether the XML information meets the specification requirements of the Schema.
本发明实施例一具体实现过程如图1所示,包括如下步骤:A specific implementation process of Embodiment 1 of the present invention is shown in Figure 1, including the following steps:
步骤1,将需要校验的根据Schema构造的XML的树型结构转换为数据库的表结构;Step 1, converting the XML tree structure constructed according to the Schema that needs to be verified into the table structure of the database;
XML语法的特点为:一条XML信息是由一系列元素构成的一个树型结构,除了根元素外,其它元素均有一个相应的父元素,一个元素可能存在0个或多个子元素,因此XML中的元素实体之间实际上构成一个反身关系,即,父元素与子元素是0对多的关系,而无论父元素还是子元素本身均是一个元素;XML中的元素可以具有0个或多个属性,元素实体与属性实体之间的关系是0对多的关系;The characteristics of XML grammar are: an XML message is a tree structure composed of a series of elements, except the root element, other elements have a corresponding parent element, and an element may have zero or more child elements, so in XML In fact, a reflexive relationship is formed between the element entities, that is, the relationship between the parent element and the child element is 0-to-many, and both the parent element and the child element themselves are one element; elements in XML can have 0 or more Attributes, the relationship between element entities and attribute entities is a 0-to-many relationship;
根据上述XML语法的特点,构造出如下表所示的数据库表结构:According to the characteristics of the above XML syntax, the database table structure shown in the following table is constructed:
利用上述表结构,可以将根据Schema构造的XML树型结构转换成简单的元素实体与属性实体之间以及元素实体之间对应的线性关系;Using the above table structure, the XML tree structure constructed according to the Schema can be converted into a simple linear relationship between element entities and attribute entities and between element entities;
所述转化过程一个具体实例如下:A specific example of the conversion process is as follows:
现有一个XML的Schema,定义如下:There is an XML Schema defined as follows:
<?xml version=″1.0″encoding=″UTF-8″?><? xml version="1.0" encoding="UTF-8"? >
<xs:element name=″name″type=″xs:string″/><xs:element name="name" type="xs:string"/>
<xs:element name=″presence″><xs:element name="presence">
<xs:complexType><xs:complexType>
<xs:sequence><xs:sequence>
<xs:element ref=″user″/><xs:element ref="user"/>
</xs:sequence></xs:sequence>
</xs:complexType></xs:complexType>
</xs:element></xs:element>
<xs:element name=″uri″type=″xs:string″/><xs:element name=″uri″type=″xs:string″/>
<xs:element name=″user″><xs:element name="user">
<xs:complexType><xs:complexType>
<xs:sequence><xs:sequence>
<xs:element ref=″uri″/><xs:element ref="uri"/>
<xs:element ref=″name″/><xs:element ref="name"/>
</xs:sequence></xs:sequence>
</xs:complexType></xs:complexType>
</xs:element></xs:element>
</xs:schema></xs:schema>
对应的一个XML文档是:A corresponding XML document is:
<?xml version=″1.0″encoding=″UTF-8″?><? xml version="1.0" encoding="UTF-8"? >
<presence><presence>
<user><user>
<uri>sip:imsuser01@cmcc.com</uri><uri>sip:imsuser01@cmcc.com</uri>
<name>cmcc</name><name>cmcc</name>
</user></user>
</presence></presence>
可以看出该Schema有一个根元素presence,这个根元素有一个子元素user,而user元素下有两个子元素:uri和name,这样转化为数据库中的信息后就会如下所示:It can be seen that the Schema has a root element presence, which has a sub-element user, and there are two sub-elements under the user element: uri and name, which will be converted into information in the database as follows:
元素标识 父元素标识 名称 值Element ID Parent Element ID Name Value
1 NULL presence NULL1 NULL presence NULL
2 1 user NULL2 1 1 user NULL
3 2 uri sip:imsuser01@cmcc.com3 2 uri sip:imsuser01@cmcc.com
4 2 name cmcc4 2 2 name name cmcc
步骤2,将上述转换后的XML信息自顶向下写入具有上述表结构的数据库中;Step 2, writing the above converted XML information from top to bottom into the database with the above table structure;
由于在元素表中父元素标识实际上是元素实体的一个外键,属性表中的元素标识实际上是属性实体的一个外键,为满足数据库中数据的外键约束要求,即主从关系要求,因此必须先将顶层元素插入数据库,然后再插入底层元素及其相应的属性信息;Since the parent element identifier in the element table is actually a foreign key of the element entity, and the element identifier in the attribute table is actually a foreign key of the attribute entity, in order to meet the foreign key constraint requirements of the data in the database, that is, the master-slave relationship requirement , so the top-level element must be inserted into the database first, and then the bottom-level element and its corresponding attribute information must be inserted;
步骤3,利用数据库中的各种约束机制来实现校验XML信息是否满足Schema的规范要求;Step 3, using various constraint mechanisms in the database to verify whether the XML information meets the specification requirements of the Schema;
如果在将一条XML信息完整插入数据库的过程中出现失败,则说明上述构造的XML信息不满足其Schema要求,需要重新构造;反之则是正确的。If there is a failure in the process of completely inserting a piece of XML information into the database, it means that the XML information constructed above does not meet its Schema requirements and needs to be reconstructed; otherwise, it is correct.
所述数据库中的约束机制包括:属性与元素采用不同方式来处理、满足元素之间的包含关系、某些元素的值不能为空、某些值只能有一个元素、某些元素值只能为数字、和/或某些元素值只能为字符串等等。The constraint mechanism in the database includes: attributes and elements are processed in different ways, the containment relationship between elements is satisfied, the value of some elements cannot be empty, some values can only have one element, and some element values can only are numbers, and/or some element values can only be strings, etc.
所述利用数据库中的各种约束机制进行校验过程中校验出XML信息不满足其Schema要求的情形包括:将属性作为元素来处理、颠倒元素之间的包含关系、不能为空的元素的值为空、只能有一个元素的而非一个元素、只能为数字的元素的值为非数字、和/或只能为字符串的元素的值为非字符串等等。在插入过程中,当出现上述任一情形时则插入失败,表明所述XML信息不满足Schema的规范要求。The situation where the XML information does not meet the Schema requirements during the verification process using various constraint mechanisms in the database includes: treating attributes as elements, reversing the containment relationship between elements, Empty value, only one element instead of one element, non-numeric value for only number element, and/or non-string value for only string element, etc. During the insertion process, when any of the above situations occurs, the insertion fails, indicating that the XML information does not meet the specification requirements of the Schema.
步骤4,在校验所述XML信息不满足Schema的规范要求时,发出警告,提示用户所述XML信息不满足Schema的规范要求。此步骤为可选步骤。Step 4, when the XML information does not meet the specification requirements of the Schema, a warning is issued to prompt the user that the XML information does not meet the specification requirements of the Schema. This step is optional.
本发明实施例二提供一种校验可扩展标记语言Schema有效性的装置,所述装置一种实施例模块示意图如图2所示,包括:Embodiment 2 of the present invention provides a device for verifying the validity of an Extensible Markup Language Schema. A schematic diagram of a module of an embodiment of the device is shown in FIG. 2 , including:
Schema转换模块,用于将根据Schema构造的XML转换为数据库表结构;The Schema conversion module is used to convert the XML constructed according to the Schema into a database table structure;
XML信息插入模块,用于将所述转换后的XML信息自顶向下插入具有所述表结构的数据库中;XML information insertion module, used to insert the converted XML information from top to bottom into the database with the table structure;
校验模块,用于在所述XML信息插入模块将所述转换后的XML信息自顶向下插入具有所述表结构的数据库过程中,利用数据库各种约束校验所述XML信息是否满足Schema的规范要求。A verification module, configured to use various constraints of the database to verify whether the XML information satisfies the Schema when the XML information insertion module inserts the converted XML information from top to bottom into the database with the table structure specification requirements.
所述装置还可以进一步包括:The device may further include:
警告模块,用于接收校验模块的校验结果,在校验模块校验出XML信息不满足Schema的规范要求时发出警告。The warning module is used to receive the verification result of the verification module, and issue a warning when the verification module verifies that the XML information does not meet the specification requirements of the Schema.
综上所述,本发明实施例实现了校验XML的Schema有效性,借助当前数据库技术的强大功能,方便、快捷的检验XML信息的正确性,保证了在进程之间使用XML进行接口交互时,使信息满足数据合法性要求。To sum up, the embodiment of the present invention realizes the verification of XML Schema validity, and with the help of the powerful functions of current database technology, it is convenient and fast to verify the correctness of XML information, ensuring that when using XML for interface interaction between processes, , so that the information meets the data legality requirements.
以上所述,仅为本发明较佳的具体实施方式,但本发明的保护范围并不局限于此,任何熟悉本技术领域的技术人员在本发明揭露的技术范围内,可轻易想到的变化或替换,都应涵盖在本发明的保护范围之内。因此,本发明的保护范围应该以权利要求的保护范围为准。The above is only a preferred embodiment of the present invention, but the scope of protection of the present invention is not limited thereto. Any person skilled in the art within the technical scope disclosed in the present invention can easily think of changes or Replacement should be covered within the protection scope of the present invention. Therefore, the protection scope of the present invention should be determined by the protection scope of the claims.
Claims (7)
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN2007100000872A CN101000622B (en) | 2007-01-10 | 2007-01-10 | Method and device for checking validity of expandable mark language mode |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN2007100000872A CN101000622B (en) | 2007-01-10 | 2007-01-10 | Method and device for checking validity of expandable mark language mode |
Publications (2)
Publication Number | Publication Date |
---|---|
CN101000622A true CN101000622A (en) | 2007-07-18 |
CN101000622B CN101000622B (en) | 2010-08-11 |
Family
ID=38692594
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN2007100000872A Expired - Fee Related CN101000622B (en) | 2007-01-10 | 2007-01-10 | Method and device for checking validity of expandable mark language mode |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN101000622B (en) |
Cited By (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
WO2013135055A1 (en) * | 2012-03-15 | 2013-09-19 | 北京播思无线技术有限公司 | Method for storing xml data into relational database |
CN104809111A (en) * | 2014-01-23 | 2015-07-29 | 北京北方微电子基地设备工艺研究中心有限责任公司 | Method, device and system for verifying validation of automatic system database file |
CN107357792A (en) * | 2016-05-10 | 2017-11-17 | 北京京东尚科信息技术有限公司 | A kind of method and apparatus of data parsing |
CN107800917A (en) * | 2017-12-15 | 2018-03-13 | 定远县网萌电子商务有限公司 | Archival digitalization Machining Intelligent process flow line platform |
-
2007
- 2007-01-10 CN CN2007100000872A patent/CN101000622B/en not_active Expired - Fee Related
Cited By (6)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
WO2013135055A1 (en) * | 2012-03-15 | 2013-09-19 | 北京播思无线技术有限公司 | Method for storing xml data into relational database |
US9928289B2 (en) | 2012-03-15 | 2018-03-27 | Borqs Wireless Ltd. | Method for storing XML data into relational database |
CN104809111A (en) * | 2014-01-23 | 2015-07-29 | 北京北方微电子基地设备工艺研究中心有限责任公司 | Method, device and system for verifying validation of automatic system database file |
CN107357792A (en) * | 2016-05-10 | 2017-11-17 | 北京京东尚科信息技术有限公司 | A kind of method and apparatus of data parsing |
CN107357792B (en) * | 2016-05-10 | 2019-12-31 | 北京京东尚科信息技术有限公司 | Data analysis method and device |
CN107800917A (en) * | 2017-12-15 | 2018-03-13 | 定远县网萌电子商务有限公司 | Archival digitalization Machining Intelligent process flow line platform |
Also Published As
Publication number | Publication date |
---|---|
CN101000622B (en) | 2010-08-11 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
Klarlund et al. | DSD: A schema language for XML | |
AU2003225697B2 (en) | Dynamic generation of schema information for data description languages | |
US20050144556A1 (en) | XML schema token extension for XML document compression | |
RU2351007C2 (en) | System and method of supporting "extrinsic" xml and "intrinsic" xml in text processor document | |
CN101101602A (en) | Data format verification method and device | |
CN102982010A (en) | Method and device for abstracting document structure | |
CN103902269B (en) | System and method for generating MIB files through XML files | |
US7143346B2 (en) | Simple types in XML schema complex types | |
Balfanz et al. | FIDO U2F Javascript API | |
CN104573053B (en) | An XML-based method for dynamic customization of configuration item templates | |
CN101000622A (en) | Method and device for checking validity of expandable mark language mode | |
Hucka et al. | The systems biology markup language (SBML): Language specification for level 3 version 1 core | |
CN101866331A (en) | Method and device for converting XML documents in different languages | |
US8954396B2 (en) | Validating and enabling validation of package structures | |
Tao et al. | Integrated syntax and semantic validation for services computing | |
CN108733353B (en) | Interface construction method and device | |
US7562295B1 (en) | Representing spelling and grammatical error state in an XML document | |
Sengupta et al. | The case for conceptual modeling for XML | |
Fiorello et al. | DTD++ 2.0: Adding support for co-constraints. | |
KR20060028500A (en) | Apparatus and method for verifying input data of application program in real time | |
Stillhard | A Compact Syntax for XML Schema | |
CN117874292A (en) | Message generation method, system, equipment and medium based on database configuration | |
Plattner | Kilian Stillhard A Compact Syntax for XML Schema | |
Heinzl et al. | Using XML schema to improve writing, validation, and structure of WS-policies | |
Süß | Sugar for OCL |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
C06 | Publication | ||
PB01 | Publication | ||
C10 | Entry into substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
C14 | Grant of patent or utility model | ||
GR01 | Patent grant | ||
CF01 | Termination of patent right due to non-payment of annual fee | ||
CF01 | Termination of patent right due to non-payment of annual fee |
Granted publication date: 20100811 Termination date: 20180110 |