CN112182305A - XML (extensive markup language) analysis module and method based on XML rules and management method of configuration data - Google Patents

XML (extensive markup language) analysis module and method based on XML rules and management method of configuration data Download PDF

Info

Publication number
CN112182305A
CN112182305A CN202011028332.2A CN202011028332A CN112182305A CN 112182305 A CN112182305 A CN 112182305A CN 202011028332 A CN202011028332 A CN 202011028332A CN 112182305 A CN112182305 A CN 112182305A
Authority
CN
China
Prior art keywords
database
xml
class
model class
interface
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
Application number
CN202011028332.2A
Other languages
Chinese (zh)
Other versions
CN112182305B (en
Inventor
赵伟
黄章良
陶洋
陈小军
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Guangzhou Robustel Technologies Co ltd
Original Assignee
Guangzhou Robustel Technologies Co ltd
Priority date (The priority date 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 date listed.)
Filing date
Publication date
Application filed by Guangzhou Robustel Technologies Co ltd filed Critical Guangzhou Robustel Technologies Co ltd
Priority to CN202011028332.2A priority Critical patent/CN112182305B/en
Publication of CN112182305A publication Critical patent/CN112182305A/en
Application granted granted Critical
Publication of CN112182305B publication Critical patent/CN112182305B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/80Information retrieval; Database structures therefor; File system structures therefor of semi-structured data, e.g. markup language structured data such as SGML, XML or HTML
    • G06F16/84Mapping; Conversion
    • G06F16/86Mapping to a database
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/21Design, administration or maintenance of databases
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/25Integrating or interfacing systems involving database management systems
    • G06F16/252Integrating or interfacing systems involving database management systems between a Database Management System and a front-end application
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/30Creation or generation of source code
    • G06F8/38Creation or generation of source code for implementing user interfaces
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/40Transformation of program code
    • G06F8/41Compilation
    • G06F8/42Syntactic analysis
    • G06F8/427Parsing

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Databases & Information Systems (AREA)
  • General Engineering & Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Data Mining & Analysis (AREA)
  • Software Systems (AREA)
  • Human Computer Interaction (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The invention belongs to the field of communication, and discloses an XML (extensive Makeup language) parsing module based on an XML rule, which comprises the following sub-modules: a database model class submodule: the database creating module is used for creating a database according to the XML configuration file, generating a database table contained in the database and creating a mapping relation between a database model class and the database table; serialization class submodule: the method comprises the steps of establishing a mapping relation between a json object transmitted by a front end and a database model class; interface type submodule: the restful interface is generated according to the XML configuration file; the page routing rule generation submodule comprises: for generating page routing rules for restful interface registration from the XML configuration file.

Description

XML (extensive markup language) analysis module and method based on XML rules and management method of configuration data
Technical Field
The invention relates to the field of communication, in particular to an XML analysis module, an analysis method and a management method of configuration data based on XML rules.
Background
In the usage environment of the internet of things, the gateway product generally includes communication and network functions, and also includes various applications of the internet of things, which generally require configuration management.
In the prior art, if any newly added application needs to access and manage the configuration data of the gateway, code writing needs to be carried out again so as to access the configuration database, which results in long development period and many problems.
Disclosure of Invention
The invention aims to provide an XML analysis module, an analysis method and a management method of configuration data based on XML rules, wherein the module automatically generates a database table, a database model class, a mapping relation between the database model class and the database table, a page routing rule and an interface by analyzing based on an XML configuration file, a json object transmitted by a front-end page is converted to obtain a model class object, and the model class object is mapped into the database table, so that the operation of increasing, checking, changing and deleting functions of the front-end page is realized.
In order to achieve the purpose, the invention provides the following technical scheme: an XML parsing module based on XML rules comprises the following sub-modules:
a database model class submodule: the database creating module is used for creating a database according to the XML configuration file, generating a database table contained in the database and creating a mapping relation between a database model class and the database table;
serialization class submodule: the method comprises the steps of establishing a mapping relation between a json object transmitted by a front end and a database model class;
interface type submodule: the restful interface is generated according to the XML configuration file;
the page routing rule generation submodule comprises: for generating page routing rules for restful interface registration from the XML configuration file.
In the XML parsing module based on the XML rule, the database is an sql database or a mysql database.
In the XML parsing module based on the XML rule, the database model sub-module establishes a mapping relationship between the database model and the database table based on the XML configuration file by using an object relational mapping method.
Meanwhile, the invention also discloses a method for automatically generating the configuration database and the configuration management interface of the equipment of the internet of things based on the XML rules, which comprises the following steps:
the method comprises the steps of establishing a database according to an XML configuration file, generating a database table contained in the database, establishing a mapping relation between a database model class and the database table, establishing a mapping relation between a front-end transmitted json object and the database model class, generating a restful interface and generating a page routing rule for restful interface registration.
Finally, the invention also discloses a management method of the configuration data of the equipment of the Internet of things, which is realized based on any one of the XML parsing modules;
the method specifically comprises the following steps:
step 1: the front-end application acquires the page routing rule from the page routing rule generation submodule;
step 2: registering a restful interface according to a page routing rule, and sending configuration data to a serialization sub-module through the restful interface in a json object form; the serialization sub-module establishes mapping from the json object to the database model class to obtain the database model class;
and step 3: and the database model sub-module maps the database model class to a database table in the database, so as to realize the operations of adding, searching, changing and deleting the configuration data in the database table.
Compared with the prior art, the invention has the beneficial effects that:
the full flow function of configuration management can be completed by automatically generating a configuration database and a restful configuration interface and combining with patents CN201910596120.5 and CN201910682579.7, and a user can complete the configuration of front-end pages, CLIs and the like and the parameter management in equipment only by defining XML rules.
Drawings
FIG. 1 is a block diagram of the module of this embodiment 1;
FIG. 2 is a schematic diagram of the module of this embodiment 1;
FIG. 3 is a flowchart of the method of the present embodiment 1;
fig. 4 is a flowchart of the method of embodiment 1.
Detailed Description
The technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are only a part of the embodiments of the present invention, and not all of the embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
Example 1
Referring to fig. 1 and 2, an XML parsing module based on XML rules includes the following sub-modules:
a database model class submodule: the system comprises a database management module, a database management module and a database management module, wherein the database management module is used for establishing an sqilite database according to an XML configuration file, generating a database table contained in the database and establishing a mapping relation between a database model class and the database table;
the XML configuration file is exemplified below:
Figure BDA0002702836720000041
the configuration file specifies the serial number, interface type, IP address, subnet mask, mtu configuration of the child node.
The database model class corresponds to a table in the database that defines, for example, which fields are contained but no specific data, i.e., if there are no objects, the table is empty.
A class object corresponds to a record of the table in the database, and there are 10 objects and 10 data records.
The above XML configuration file automatically generates a class object as follows:
class Network (models) class name definition for database
INTERFACE_TYPE_1='lan0'
INTERFACE_TYPE_2='lan1'
INTERFACE_TYPE_3='lan2'
INTERFACE_TYPE_4='lan3'
Interface _ TYPE _5 ═ lan4' lan0-lan5 are enumerated items, as will be used below
INTERFACE_TYPE_ITEM=[
(0,INTERFACE_TYPE_1),
(1,INTERFACE_TYPE_2),
(2,INTERFACE_TYPE_3),
(3,INTERFACE_TYPE_4),
(4,INTERFACE_TYPE_5),
Interface type definition, which uses the above defined enumeration type to indicate that the configuration item can only select the item in the enumeration type, otherwise it is illegal.
id=models.IntegerField(primary_key=True,unique=True,auto_created=True)
Entry ID field, primary key of database, auto-generated (no user setup), and non-repeatable
interface=models.IntegerField(choices=INTERFACE_TYPE_ITEM,default=0)
INTERFACE TYPE field, which can only select the enumerated TYPE defined above, otherwise illegal, default is INTERFACE _ TYPE _1, namely lan0
ip=models.IPAddressField(default='192.168.0.1')
IP address field, 192.168.0.1 by default
netmask=models.IPAddressField(default='255.255.255.0')
Subnet mask field, 255.255.255.0 by default
mtu=models.IntegerField(default=1500)
Mtu field, 1500 by default
The parent node of the XML corresponds to the class name, each child node of the XML corresponds to a field, and the enum attribute in the XML corresponds to the enumeration item in the database.
After the class objects are generated, corresponding commands are executed in a django frame, and the commands are two commands of management.
The configuration parameters of different pages belong to different database tables, i.e. different XML files are to be established. Xml, for example, if a new APP is to be added, it needs to be newly created.
Serialization class submodule: the method comprises the steps of establishing a mapping relation between a json object transmitted by a front end and a database model class;
the establishment of the mapping relation between the json object and the database model class is a function provided by a django framework, and the access flow of data is as shown in the specification:
(1) transmitting the data in the json format to the Web service through a restful interface (the interface is generated through an interface class submodule) by the Web or cli;
(2) the Django rest frame component in the Django can convert json data into a model object; a model object is an object of the database model class described above, representing a record in a database table.
(3) Model object data is saved to the database in step 1 by the ORM.
The json object may take the following code as an example:
{
"id":1,
"interface":1,
"ip":"192.168.0.1",
"netmask":"255.255.255.0",
"mtu":1500
},
the above is a json object, corresponding to a model object in the model class;
through the analysis, a database table, a database model class, a class object and a database are generated in the database model class submodule according to the XML configuration file;
the serialization class submodule generates a model object according to the json object.
The definition of the database table corresponds to a database model class; a record in the database table corresponds to a model object.
In the conventional technology, if a database is to be directly operated, research and development personnel need to write SQL statements for operation. In the scheme, through the ORM technology, research personnel only need to operate one model object in an object-oriented mode, and then the operations of increasing, deleting, modifying and checking the database can be directly completed without writing SQL statements.
Interface type submodule: the restful interface is generated according to the XML configuration file;
taking the xml configuration file as an example, generating a Restful interface according to the django rest frame and the xml configuration file, wherein the django rest frame component is open source software developed by a third party organization aiming at the django frame and can generate the Restful interface according to the definition of the class;
the operation process is as follows:
the django rest frame component generates two class codes according to the XML configuration file and generates a url route registration code, namely, a restful interface can be automatically generated by the framework.
The following is class code
Figure BDA0002702836720000081
Figure BDA0002702836720000091
The route generation rule is only responsible for the next two lines, the viewset class is responsible for interacting with the restful interface, the json data of the back end is obtained through the serializer class and is filtered and displayed to the front end, or the received data of the front end is transferred to the sirializer class.
The page routing rule generation submodule comprises: for generating page routing rules for restful interface registration from the XML configuration file.
The matching relationship of each submodule is as follows:
the configuration of the page of any embedded device can be managed through an XML configuration file in the embodiment, a database is generated by the database model sub-module based on the XML configuration file, and the database consists of database tables; the database model class and the database represent corresponding relations;
the page routing rule generation submodule and the interface class submodule generate a restful interface and a routing rule according to the XML configuration file;
the front end calls the interface and the routing rule to send the json object to the serialization sub-module;
the serialization class submodule converts the json object into a model object;
the database model class submodule writes the model object into a database table in a database, so that the expression of the xml configuration file of the front-end page is realized;
in the maintenance process, maintenance personnel need to upload the XML configuration file of the changed configuration to realize the management and maintenance of the front-end page.
When a user changes the related configuration of a page, one or more json objects are generated, the json objects are converted into model objects through the serialization class submodule, and the model objects are written into the database table by the database model class submodule to modify the database.
The innovation points of the invention are as follows:
automatically generating a database table, a database model class, a restful interface and a page route based on an XML page configuration file; the conversion between json objects and model objects is an open source prior art; the method comprises the steps that a database table, a database model class, a restful interface and a page route are automatically generated based on an XML page configuration file, when a user modifies front-end page data, through conversion between a json object and a model object, a mapping relation exists between the model object and the database model class, a mapping key exists between the database model class and the database table, the model object can be filled into the database table, updating of a database file is achieved, and the operation of increasing, checking, changing and deleting functions of the front-end page is achieved.
In addition, the embodiment further provides a method for managing configuration data of an internet of things device, which is implemented based on the XML parsing module, with reference to fig. 3 and 4, and includes the following steps:
step 1: the front-end application acquires the page routing rule from the page routing rule generation submodule;
step 2: registering a restful interface according to a page routing rule, and sending configuration data to a serialization sub-module through the restful interface in a json object form; the serialization sub-module establishes mapping from the json object to the database model class to obtain the database model class;
and step 3: and the database model sub-module maps the database model class to a database table in the database, so as to realize the operations of adding, searching, changing and deleting the configuration data in the database table.
In this embodiment, the page routing rule in step 1, and the mapping relationship between the restful interface, the database model class, and the database table in step 2 are all automatically generated according to the XML page configuration file, and a software developer does not need to write the database table, the interface configuration file, and the routing rule by hand, which can effectively reduce the work intensity of an operator.
And by combining with patents CN201910596120.5 and CN201910682579.7, the full flow function of configuration management can be completed, and the user only needs to define XML rules to complete the configuration of front-end pages, CLIs and the like and the parameter management in equipment.
It will be evident to those skilled in the art that the invention is not limited to the details of the foregoing illustrative embodiments, and that the present invention may be embodied in other specific forms without departing from the spirit or essential attributes thereof. The present embodiments are therefore to be considered in all respects as illustrative and not restrictive, the scope of the invention being indicated by the appended claims rather than by the foregoing description, and all changes which come within the meaning and range of equivalency of the claims are therefore intended to be embraced therein. Any reference sign in a claim should not be construed as limiting the claim concerned.

Claims (5)

1. An XML analysis module based on XML rules, which is characterized in that: the system comprises the following sub-modules:
a database model class submodule: the database creating module is used for creating a database according to the XML configuration file, generating a database table contained in the database and creating a mapping relation between a database model class and the database table;
serialization class submodule: the method comprises the steps of establishing a mapping relation between a json object transmitted by a front end and a database model class;
interface type submodule: the restful interface is generated according to the XML configuration file;
the page routing rule generation submodule comprises: for generating page routing rules for restful interface registration from the XML configuration file.
2. An XML parsing module based on XML rules according to claim 1, wherein: the database is an sqilite database or a mysql database.
3. An XML parsing module based on XML rules according to claim 1, wherein: and the database model sub-module establishes a mapping relation between the database model class and the database table based on the XML configuration file by adopting an object relational mapping method.
4. A method for automatically generating an Internet of things equipment configuration database and a configuration management interface based on XML rules is characterized by comprising the following steps:
the method comprises the steps of establishing a database according to an XML configuration file, generating a database table contained in the database, establishing a mapping relation between a database model class and the database table, establishing a mapping relation between a front-end transmitted json object and the database model class, generating a restful interface and generating a page routing rule for restful interface registration.
5. A management method for configuration data of internet of things equipment, which is implemented based on the XML parsing module according to any one of claims 1 to 3;
the method specifically comprises the following steps:
step 1: the front-end application acquires the page routing rule from the page routing rule generation submodule;
step 2: registering a restful interface according to a page routing rule, and sending configuration data to a serialization sub-module through the restful interface in a json object form; the serialization sub-module establishes mapping from the json object to the database model class to obtain the database model class;
and step 3: and the database model sub-module maps the database model class to a database table in the database, so as to realize the operations of adding, searching, changing and deleting the configuration data in the database table.
CN202011028332.2A 2020-09-26 2020-09-26 XML (extensive markup language) analysis module and management method based on XML rules Active CN112182305B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202011028332.2A CN112182305B (en) 2020-09-26 2020-09-26 XML (extensive markup language) analysis module and management method based on XML rules

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202011028332.2A CN112182305B (en) 2020-09-26 2020-09-26 XML (extensive markup language) analysis module and management method based on XML rules

Publications (2)

Publication Number Publication Date
CN112182305A true CN112182305A (en) 2021-01-05
CN112182305B CN112182305B (en) 2023-07-21

Family

ID=73943560

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202011028332.2A Active CN112182305B (en) 2020-09-26 2020-09-26 XML (extensive markup language) analysis module and management method based on XML rules

Country Status (1)

Country Link
CN (1) CN112182305B (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113821210A (en) * 2021-09-17 2021-12-21 中汽创智科技有限公司 File analysis method and device and storage medium

Citations (9)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US7155534B1 (en) * 2002-10-03 2006-12-26 Cisco Technology, Inc. Arrangement for aggregating multiple router configurations into a single router configuration
CN102841889A (en) * 2011-06-20 2012-12-26 中兴通讯股份有限公司 Method and device for achieving efficient database access based on ORM (object relational mapping) architecture
US20150095343A1 (en) * 2013-09-27 2015-04-02 Oracle International Corporation Cloud database connection multiplexing
CN106557568A (en) * 2016-11-14 2017-04-05 中国电子科技集团公司第二十八研究所 The processing method that the XML file format of pattern match is changed with relational database
US20170185609A1 (en) * 2015-12-28 2017-06-29 International Business Machines Corporation Universal adaptor for rapid development of web-based data visualizations
CN108009282A (en) * 2017-12-22 2018-05-08 武汉楚鼎信息技术有限公司 A kind of json data are synchronized to the method and system device of relevant database
CN108121564A (en) * 2017-12-22 2018-06-05 武汉楚鼎信息技术有限公司 A kind of json data Fast synchronization and the method and system device of control
US10331422B1 (en) * 2019-02-10 2019-06-25 Julie Russell System and method for generating API devlopment code for integrating platforms
CN111510330A (en) * 2020-04-10 2020-08-07 中国联合网络通信集团有限公司 Interface management apparatus, method and storage medium

Patent Citations (9)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US7155534B1 (en) * 2002-10-03 2006-12-26 Cisco Technology, Inc. Arrangement for aggregating multiple router configurations into a single router configuration
CN102841889A (en) * 2011-06-20 2012-12-26 中兴通讯股份有限公司 Method and device for achieving efficient database access based on ORM (object relational mapping) architecture
US20150095343A1 (en) * 2013-09-27 2015-04-02 Oracle International Corporation Cloud database connection multiplexing
US20170185609A1 (en) * 2015-12-28 2017-06-29 International Business Machines Corporation Universal adaptor for rapid development of web-based data visualizations
CN106557568A (en) * 2016-11-14 2017-04-05 中国电子科技集团公司第二十八研究所 The processing method that the XML file format of pattern match is changed with relational database
CN108009282A (en) * 2017-12-22 2018-05-08 武汉楚鼎信息技术有限公司 A kind of json data are synchronized to the method and system device of relevant database
CN108121564A (en) * 2017-12-22 2018-06-05 武汉楚鼎信息技术有限公司 A kind of json data Fast synchronization and the method and system device of control
US10331422B1 (en) * 2019-02-10 2019-06-25 Julie Russell System and method for generating API devlopment code for integrating platforms
CN111510330A (en) * 2020-04-10 2020-08-07 中国联合网络通信集团有限公司 Interface management apparatus, method and storage medium

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
张尔喜;先晓兵;王雪锋;: "基于WebAPI的移动端学生综合服务平台设计与实现", 软件工程, no. 10 *

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113821210A (en) * 2021-09-17 2021-12-21 中汽创智科技有限公司 File analysis method and device and storage medium

Also Published As

Publication number Publication date
CN112182305B (en) 2023-07-21

Similar Documents

Publication Publication Date Title
CN113508403B (en) System and method for interoperable communication of automation system components with multiple information sources
CN107743072B (en) Efficient and extensible network simulation scene generation method
CN110958131B (en) GraphQL-based queries supported on a YANG configuration data model
US8065655B1 (en) System and method for the autogeneration of ontologies
CN100484039C (en) Network management apparatus and network management method
CN106559251A (en) A kind of Compilation Method and corresponding interface, component and system based on YANG models
JPH10149398A (en) Map building system and its method
WO2006115694A2 (en) Transforming business models
KR20050115907A (en) Relational model for management information in network devices
CN102567026B (en) Mobile solution constructing system and Mobile solution construction method
CN105049256A (en) Method and system for realizing universal custom interface message
CN105824944B (en) A kind of XML configuration data maintaining method and system based on scripting language
CN112685032A (en) Dynamic api visualization generation method based on spring boot frame
US7127721B2 (en) Core object model for network management configuration applications in telecommunication systems
CN112182305A (en) XML (extensive markup language) analysis module and method based on XML rules and management method of configuration data
KR101810518B1 (en) Object query system and method using BIM data of IFC format
CN115858810A (en) Method, system, computer device and storage medium for automatically constructing knowledge graph
Xiaohua et al. Design and implementation of OpenDayLight manager application
KR100453224B1 (en) Apparatus and method for editing a numerical formula by using wire/wireless internet
CN100438522C (en) Method for creating a protocal-independent manager/agent relationship, in a network management system of a telecommunication network
KR100545348B1 (en) An integrated development system for a SyncML server application development
CN113221511A (en) Method, device and equipment for converting configuration file into XML file and storage medium
WO2012083631A1 (en) Method for managing device parameters of radio frequency identification (rfid) system and rfid system
KR20110138487A (en) Web ontology editing and operating system
Nataf et al. End-to-end YANG-based configuration management

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
CB02 Change of applicant information

Address after: 511356 Room 501, building 2, No. 63, Yong'an Avenue, Huangpu District, Guangzhou, Guangdong

Applicant after: Guangzhou lubangtong Internet of things Technology Co.,Ltd.

Address before: 510653 room F315, 95 daguanzhong Road, Tianhe District, Guangzhou City, Guangdong Province

Applicant before: GUANGZHOU ROBUSTEL TECHNOLOGIES Co.,Ltd.

CB02 Change of applicant information
GR01 Patent grant
GR01 Patent grant