[go: up one dir, main page]

CN112182305B - XML (extensive markup language) analysis module and management method based on XML rules - Google Patents

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

Info

Publication number
CN112182305B
CN112182305B CN202011028332.2A CN202011028332A CN112182305B CN 112182305 B CN112182305 B CN 112182305B CN 202011028332 A CN202011028332 A CN 202011028332A CN 112182305 B CN112182305 B CN 112182305B
Authority
CN
China
Prior art keywords
database
xml
class
model
submodule
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.)
Active
Application number
CN202011028332.2A
Other languages
Chinese (zh)
Other versions
CN112182305A (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 Lubangtong IoT Co Ltd
Original Assignee
Guangzhou Lubangtong IoT 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 Lubangtong IoT Co Ltd filed Critical Guangzhou Lubangtong IoT 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

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 analysis module based on XML rules, which comprises the following sub-modules: database model class submodule: the method comprises the steps of creating a 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; serialization class submodule: the method comprises the steps of establishing a mapping relation between json objects transmitted by a front end and database model classes; interface class submodule: the method comprises the steps of generating a restful interface according to an XML configuration file; page routing rule generation sub-module: and generating page routing rules for the restful interface registration according to the XML configuration file.

Description

XML (extensive markup language) analysis module and management method based on XML rules
Technical Field
The invention relates to the field of communication, in particular to an XML analysis module and an XML management method based on XML rules.
Background
In the use environment of the internet of things, the gateway product generally comprises communication and network functions, and various application programs of the internet of things, which generally need to be configured and managed.
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 performed again to be able 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 XML analysis method and a configuration data management method 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, and a json object transmitted by a front page is converted to obtain a model object and mapped into the database table to realize the operation of adding, checking, modifying and deleting functions of the front page.
In order to achieve the above purpose, the present invention provides the following technical solutions: an XML parsing module based on XML rules comprises the following sub-modules:
database model class submodule: the method comprises the steps of creating a 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;
serialization class submodule: the method comprises the steps of establishing a mapping relation between json objects transmitted by a front end and database model classes;
interface class submodule: the method comprises the steps of generating a restful interface according to an XML configuration file;
page routing rule generation sub-module: and generating page routing rules for the restful interface registration according to the XML configuration file.
In the XML parsing module based on the XML rule, the database is an sqilite database or a mysql database.
In the XML parsing module based on the XML rule, the database model submodule uses the method of object relation mapping to establish the mapping relation between the database model and the database table based on the XML configuration file.
Meanwhile, the invention also discloses a method for automatically generating the equipment configuration database and the configuration management interface of the Internet of things based on XML rules, which comprises the following steps:
creating a database according to the 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 json object transmitted by the front end and the database model class, generating a restful interface, and generating a page routing rule for registering the restful interface.
Finally, the invention also discloses a management method of the configuration data of the Internet of things equipment, which is realized based on any XML analysis module;
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 class sub-module through the restful interface in a json object mode; the serialization class submodule establishes a mapping from the json object to the database model class to obtain the database model class;
step 3: the database model submodule maps the database model class into a database table in the database, and realizes the operations of adding, checking, modifying and deleting the configuration data in the database table.
Compared with the prior art, the invention has the beneficial effects that:
the configuration database and the restful configuration interface are automatically generated, and then the complete flow function of configuration management can be completed by combining with the CN201910596120.5 and CN201910682579.7 patents, and a user can complete the configuration of a front-end page, a CLI and the like and the parameter management in the equipment by only defining XML rules.
Drawings
Fig. 1 is a block diagram of a module of the present embodiment 1;
fig. 2 is a schematic diagram of the operation of the module of this embodiment 1;
FIG. 3 is a flow chart of the method of embodiment 1;
fig. 4 is a flowchart of the method of the present embodiment 1.
Detailed Description
The following description of the embodiments of the present invention will be made clearly and completely with reference to the accompanying drawings, in which it is apparent that the embodiments described are only some embodiments of the present invention, but not all embodiments. All other embodiments, which can be made by those skilled in the art based on the embodiments of the invention without making any inventive effort, are intended to be within the scope of the invention.
Example 1
Referring to fig. 1 and 2, an XML parsing module based on XML rules includes the following sub-modules:
database model class submodule: the method comprises the steps of creating 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 by the following:
< Network desc= "Network Settings" > parent node start
< id type= "int" range= "1..5"/> child node number, range 1-5
< interface type= "enum" range= "lan0 lan1 lan2 lan3 lan4" default= "lan0" unique= "true"/> child node interface type, range lan0 lan1 lan2 lan3 lan4, default lan0, unique means non-repeatable configuration, e.g. cannot have both child nodes configured as lan0
< IP type= "ip_addr" default= "192.168.0.1" desc= "IP Address"/> -child node IP Address
< netmask type= "ip_addr" default= "255.255.255.0"/> "child node subnet mask
< mtu type= "int" range= "68..1500" default= "1500" > mtu configuration of child node, range 68-1500
Ending of parent node of network
The configuration file specifies the sequence number of the child node, the interface type, the IP address, the subnet mask, mtu configuration.
The database model class corresponds to a table in the database that defines, for example, which fields are included, but does not include specific data, i.e., the table is empty if there are no objects.
The class object corresponds to a record of the table in the database, and there are 10 data records for 10 objects.
The XML configuration file automatically generates class objects as follows:
class name definition of database
INTERFACE_TYPE_1='lan0'
INTERFACE_TYPE_2='lan1'
INTERFACE_TYPE_3='lan2'
INTERFACE_TYPE_4='lan3'
INTERFACE_TYPE_5= 'lan4' lan0-lan5 is an enumeration item, which 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, using the enumeration type defined above, indicates that the configuration item can only select items 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, automatic generation (without user setting), and unrepeatable
interface=models.IntegerField(choices=INTERFACE_TYPE_ITEM,default=0)
The INTERFACE TYPE field can only select the enumeration TYPE defined above, otherwise illegally, default to INTERFACE_TYPE_1, i.e. lan0
ip=models.IPAddressField(default='192.168.0.1')
The IP address field, default to 192.168.0.1
netmask=models.IPAddressField(default='255.255.255.0')
The subnet mask field defaults to 255.255.255.255.0
mtu=models.IntegerField(default=1500)
Mtu field, default 1500
The parent node of the XML corresponds to a class name, each child node of the XML corresponds to a field, and the enum attribute in the XML corresponds to an enumerated item in the database.
After the class object is generated, executing corresponding commands in the django framework, wherein the commands are two commands of a message.
The configuration parameters of different pages belong to different database tables, namely different XML files are to be built. For example, if a new APP is to be added, the app.xml needs to be newly created.
Serialization class submodule: the method comprises the steps of establishing a mapping relation between json objects transmitted by a front end and database model classes;
the establishment of the mapping relation between json objects and database model classes is the function provided by the django framework, and the data access flow is as follows:
(1) The Web or cli transmits json format data to the Web service through a restful interface (the interface is generated through an interface class submodule);
(2) The Django rest framework component in django converts json data into model objects; the model object is the object of the database model class described above, and represents a record in the database table.
(3) The model object data is saved to the database of step 1 through the ORM.
json objects may be exemplified by the following codes:
the above is a json object, corresponding to one model object in the model class;
from the above analysis, it can be seen that 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 the database model class; one record in the database table corresponds to one model object.
In the conventional technology, if the database is to be directly operated, a developer is required to write SQL sentences for operation. According to the technical scheme, through the ORM technology, a developer can directly complete the adding, deleting and checking operation of the database by operating one model object in an object-oriented mode without writing SQL sentences.
Interface class submodule: the method comprises the steps of generating a restful interface according to an XML configuration file;
taking the xml configuration file as an example, generating a Restful interface according to django rest framework and the xml configuration file, wherein django rest framework component is open source software developed by a third party organization aiming at the django framework, and the Restful interface can be generated according to class definition;
the operation process is as follows:
the django rest framework component generates two class codes according to the XML configuration file and generates a url route registration code, namely, the restful interface can be automatically generated by the framework.
The following are class codes
class NetworkSerializer (serialisers. ModelSerializer): serialization class definition, conversion between json and model.
class Meta, meta definition
model = Network bound model class
field= "__ all __" is bound to a field of the model class, __ all __ identifies that all fields are bound.
class NetworkViewSet (views. ModelViewset): view class definition, interact with restful interface
serialiser_class = networkserialiser bound serialization class
queryset=network.
filter_class = NetworkFilter binding filter class, used to filter data.
Below # in the url. Py file is the routing rule
router=defaultrouter () route definition
Router. Register ('network', network ViewSet) binds the restful interface to the view class
The route generation rule is only responsible for the two latter rows, the view class is responsible for interacting with the restful interface, and the rear-end json data is acquired through the seriizer class and filtered and displayed to the front end, or the received front-end data is transferred to the sirializer class.
Page routing rule generation sub-module: and generating page routing rules for the restful interface registration according to the XML configuration file.
The matching relation of the sub-modules is as follows:
the configuration of the pages of any embedded device can be managed through an XML configuration file in the embodiment, and the database model submodule firstly generates a database based on the XML configuration file, wherein the database consists of database tables; the database model class and the database represent the corresponding relation;
the page routing rule generation submodule generates 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 class submodule;
the serialization class submodule converts the json object into a model object;
the database model submodule writes the model object into a database table in the database, so that the xml configuration file of the front-end page is expressed;
in the maintenance process, maintenance personnel need to upload the XML configuration file of the changed configuration, so that the front-end page can be managed and maintained.
When a user changes the relevant configuration of the page, one or more json objects are generated, the json objects are converted into model objects through the serialization class submodule, and the database model submodule writes the model objects into a database table to realize modification of the database.
The innovation point of the invention is that:
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; through the automatic generation of the database table, the database model class, the restful interface and the page route based on the XML page configuration file, when a user modifies the front-end page data, through the conversion between json objects and model objects, the model objects and the database model class have mapping relations, the database model class and the database table have mapping keys, the model objects can be filled in the database table, so that the update of the database file is realized, and the operation of adding, checking, modifying and deleting the front-end page functions is realized.
In addition, the embodiment also provides a management method of the configuration data of the internet of things device based on the XML parsing module, referring to fig. 3 and 4, which 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 class sub-module through the restful interface in a json object mode; the serialization class submodule establishes a mapping from the json object to the database model class to obtain the database model class;
step 3: the database model submodule maps the database model class into a database table in the database, and realizes the operations of adding, checking, modifying and deleting the configuration data in the database table.
In this embodiment, the page routing rule in step 1, the restful interface in step 2, the database model class and the mapping relation between the database tables are automatically generated according to the XML page configuration file, and the software developer does not need to write the database tables, the interface configuration file and the routing rule manually, which can effectively reduce the working strength of the operator.
And combining with the CN201910596120.5 and CN201910682579.7 patents, the whole flow function of configuration management can be finished, and a user can finish the configuration of front-end pages, CLI and the like and the parameter management in the equipment by only defining XML rules.
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 characteristics 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 (4)

1. An XML parsing module based on XML rules is characterized in that: the system comprises the following sub-modules:
database model class submodule: the method comprises the steps of creating a 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;
serialization class submodule: the method comprises the steps of establishing a mapping relation between json objects transmitted by a front end and database model classes;
interface class submodule: the method comprises the steps of generating a restful interface according to an XML configuration file;
page routing rule generation sub-module: the method comprises the steps of generating a page routing rule for restful interface registration according to an XML configuration file;
the establishment of the mapping relationship between the json object and the database model class is based on the function provided by the django framework, and the specific operation is as follows:
(1) The Web or cli transmits json objects to the Web service through a restful interface;
(2) The Django rest framework component in django converts json objects into model objects; the model object is an object of a database model class and represents one record in a database table;
(3) Saving the model object to a database through the ORM;
the matching relation of each sub-module is as follows:
the front end calls a restful interface and a routing rule to send the json object to the serialization class submodule;
the serialization class submodule converts the json object into a model object;
the database model submodule writes the model object into a database table in the database, so that the xml configuration file of the front-end page is expressed;
in the maintenance process, maintenance personnel realize the management and maintenance of the front-end page through uploading the XML configuration file of the changed configuration;
when a user changes the relevant configuration of the page, one or more json objects are generated, the json objects are converted into model objects through the serialization class submodule, and the database model submodule writes the model objects into a database table to realize modification of the database.
2. The XML parsing module based on XML rules of claim 1, wherein: the database is an sqilite database or a mysql database.
3. The XML parsing module based on XML rules of claim 1, wherein: the database model submodule adopts an object relation mapping method to establish a mapping relation between the database model and a database table based on an XML configuration file.
4. A method for managing configuration data of an internet of things device, which is characterized by being 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 class sub-module through the restful interface in a json object mode; the serialization class submodule establishes a mapping from the json object to the database model class to obtain the database model class;
step 3: the database model submodule maps the database model class into a database table in the database, and realizes the operations of adding, checking, modifying 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 CN112182305A (en) 2021-01-05
CN112182305B true 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)

Families Citing this family (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113821210B (en) * 2021-09-17 2024-06-25 中汽创智科技有限公司 File analysis method, device and storage medium
CN113987335A (en) * 2021-09-28 2022-01-28 郑州秀兔网络科技有限公司 A data collection method and device, electronic device, and storage medium

Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
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

Family Cites Families (7)

* 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
US10536545B2 (en) * 2013-09-27 2020-01-14 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
CN106557568B (en) * 2016-11-14 2019-05-21 中国电子科技集团公司第二十八研究所 The processing method of XML file format and the relational database conversion of pattern match
US10331422B1 (en) * 2019-02-10 2019-06-25 Julie Russell System and method for generating API devlopment code for integrating platforms
CN111510330B (en) * 2020-04-10 2023-08-18 中国联合网络通信集团有限公司 Interface management device, method and storage medium

Patent Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
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

Also Published As

Publication number Publication date
CN112182305A (en) 2021-01-05

Similar Documents

Publication Publication Date Title
CN113508403B (en) System and method for interoperable communication of automation system components with multiple information sources
CN108989066B (en) Equipment management method and device
CN101873323B (en) Web service platform based on program slicing technique
US20030204640A1 (en) Method and device for management of tree data exchange
CN112182305B (en) XML (extensive markup language) analysis module and management method based on XML rules
EP2357860A1 (en) Device management server, client and method for locating target operation object
WO2017054531A1 (en) Yang model-based compiling method, and corresponding interface, component, and system
EP2416538B1 (en) Method for providing node information, method for obtaining node information and equipment thereof
CN104461531B (en) A kind of implementation method of reporting system SQL
CN102571420A (en) Method and system for network element data management
CN107451169A (en) A kind of athletic competition information issuing system general-purpose platform
CN105824944B (en) A kind of XML configuration data maintaining method and system based on scripting language
CN1910854B (en) Automatic update system and method for using a meta mib
CN1980144A (en) Method for quickly configurating large data-quantity network management data
CN118034673B (en) Visual editing generation and dynamic analysis system for equipment model of Internet of things
CN105516269A (en) Application configuration method and application configuration device
US20070208842A1 (en) Methods and systems for pushing and pulling network data in user interface design
CN102684894A (en) Method and device for realizing northboundbound interface
US7546313B1 (en) Method and framework for using XML files to modify network resource configurations
Jethanandani YANG, NETCONF, RESTCONF: What is this all about and how is it used for multi-layer networks
CN1658579A (en) Method for set-up artificial equipment agency
CN112822190B (en) Message maintenance method and device
CN114765633B (en) Network message analysis method and device based on real-time Ethernet protocol of train
KR100545348B1 (en) Integrated development system for server application development
CN100384285C (en) Test method of equipment management service system

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