CN110502667A - The parsing of ODX document and generation technique based on DOM frame - Google Patents

The parsing of ODX document and generation technique based on DOM frame Download PDF

Info

Publication number
CN110502667A
CN110502667A CN201810485857.5A CN201810485857A CN110502667A CN 110502667 A CN110502667 A CN 110502667A CN 201810485857 A CN201810485857 A CN 201810485857A CN 110502667 A CN110502667 A CN 110502667A
Authority
CN
China
Prior art keywords
document
odx
parsing
java
rule
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.)
Pending
Application number
CN201810485857.5A
Other languages
Chinese (zh)
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.)
Nanjing University
Original Assignee
Nanjing University
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 Nanjing University filed Critical Nanjing University
Priority to CN201810485857.5A priority Critical patent/CN110502667A/en
Publication of CN110502667A publication Critical patent/CN110502667A/en
Pending legal-status Critical Current

Links

Landscapes

  • Document Processing Apparatus (AREA)
  • Stored Programmes (AREA)

Abstract

The invention proposes a kind of parsing of ODX document based on DOM frame and generation techniques, are broadly divided into three modules: XML Schema parsing module, ODX document parsing module and ODX document creation module.The XML Schema rule of ODX document is divided into basic data type rule, complex data type rule, structure type rule, constrained type rule and expansion type rule by XML Schema parsing module, and the java class mapping ruler for meeting ODX document format is devised according to various rule-likes, so that each of ODX document class, which can standardize, generates corresponding java class mapping;ODX document parsing module extracts all class members's information of Similar integral to be resolved first with reflection mechanism, circulation, and followed by DOM frame, all properties and element information for obtaining root node are put into queue to be resolved.Finally the value of attribute or element in queue to be resolved is mapped in the corresponding member variable of target class: indirect assignment is carried out for basic data type, recurrence assignment is carried out for member object, each array member is recycled for aray variable and indirect assignment is selected according to the actual type of each array member or carries out recursive operation;ODX document creation module is similar with parsing module, first all class members's information of circulation extraction Similar integral to be resolved, as queue to be generated.Next each member of queue to be generated is parsed or is modified by the way that whether it passes through, judge whether the member variable should export, finally according to the different recursive completion ODX document generation operations of data type: basic data type is directly generated, recursive generation is carried out for member object, each array member is recycled for aray variable and directly generates or carry out recursive operation according to the selection of the actual type of each array member.

Description

The parsing of ODX document and generation technique based on DOM frame
Technical field
The invention belongs to field of computer technology, especially software technology field.The invention proposes one kind to be solved based on DOM The parsing of universal ODX document and the generation technique for analysing frame and Java reflection mechanism, being capable of System design ODX document and Java Mapping between class, and the mutual conversion between any ODX document and Java object can be completed.In terms of vehicle-mounted Have a wide range of applications demand.
Background technique
The open diagnostic data of road vehicle (Open diagnostic data exchange, abbreviation ODX) is a kind of base Format is diagnosed in the vehicle data of XML.It is used to describe the relevant number with automobile ECU (Electronic Control Unit) According to.Including control primitive, data communication primitive, messaging parameter, information of vehicles and configuration instruction between vehicle and ECU etc. with The relevant information of ECU.Vehicle diagnosing system based on ODX database schema can be by reading and parsing the ODX of each ECU File obtains all information relevant to the ECU, meets the needs of each phases diagnostic data.
Before ODX data model proposes, due to the difference of application scenarios, developing instrument, the not same order of vehicle diagnostics exploitation The data format that section uses is all different.However the interdependence again of each stage in development process is diagnosed, it is inseparable.If Diagnostic requirements descriptor format is constantly converted, it may be difficult to be guaranteed the consistency of data, not only increased the complexity of demand management, but also make Each stage work linking is difficult, increases overall cost.If using ODX as diagnostic data in entirely diagnosis development process Format, since its open source and standardized nature, the above problem are all addressed.
Vehicle communication interface of new generation based on ODX database schema is had been widely used at present in the U.S. and Germany Among leading Automobile Enterprises, however most of Chinese vehicle enterprise is in development phase, the parsing and life of ODX document for D-Server At, as D-Server building important component, have very high application value.Therefore, the present invention bases oneself upon vehicle enterprise demand Pain spot, efficient, the accurate ODX document of trial proposition automatically parses and generating algorithm, for independent research ODX Database Systems and newly Generation vehicle diagnosing system provides reference.
ODX document is mainly write by XML (eXtensible Markup Language, extensible markup language). XML is widely used in field of data exchange, because of the flexibility and scalability of its height to guarantee the uniformity of data. Relative to common XML file, ODX document exists simultaneously document architecture and greatly solves with the feature of logical relation complexity, traditional XML Analysis technology is unable to satisfy the demand of ODX document parsing, need to customize and solve for the parsing of the document of ODX and generation technique The parsing and generation problem of ODX document.
In conclusion the parsing and generation of ODX document are for building ODX database or even young mobile diagnostic system There is important role;And XML document analytic method traditional at present is unable to satisfy the demand of ODX document parsing.On meeting Demand is stated, the invention proposes a kind of design methods of ODX document parsing and generation technique.
Summary of the invention
Groundwork of the invention be propose it is a kind of based on DOM analytical framework and the universal ODX of Java reflection mechanism text Shelves parsing and generation technique.The technology is broadly divided into three modules: XML Schema parsing module, ODX document parsing module and ODX document creation module.It is respectively intended to solve the problems, such as that the java class mapping ruler of ODX document, ODX document to Java object turn Change problem and Java object to ODX document transfer problem.Wherein XML Schema module design meets ODX document format XML Schema transformation rule maps each of ODX document class standard metaplasia at corresponding java class;ODX document solution Analysis and generation module are based on DOM analytical framework, in conjunction with Java reflection mechanism, devise the efficient ODX document of lower coupling and Mutual transfer algorithm between Java object.In view of the above problems, work and contribution of the invention is as follows:
1.XML Schema rule parsing.XML Schema rule parsing module is ODX document parsing module and ODX document The basis of generation module is responsible for constructing legal Java data structure according to ODX XML Schema file (odx.xsd). Suitable data structure is only constructed, just can be carried out subsequent parsing and generation operation.Odx.xsd file, as ODX document In XML Schema file, the content structure of specified in more detail ODX document each class and its mutual relationship.This module Effect be exactly to be converted to the rule in odx.xsd: firstly the need of the strictly all rules that occur in identification odx.xsd file, Next need to realize each rule to the mapping between Java data structure, to guarantee parsing and the adequacy generated and complete Property, it lays the foundation for two modules below.
The parsing of 2.ODX document.What this module was responsible for completing to export from ODX document to XML Schema rule parsing module The conversion process of Java class.Input is ODX document, exports Java object.This module firstly the need of creation ODX Java object, Then the content according to ODX document, all classes occurred in the efficient parsing document of lower coupling are needed, and parsing result is stored up There are in Java object.
3.ODX document structure tree.This module is responsible for completing from the java class that XML Schema rule parsing module exports to ODX The conversion process of document.Input is Java object, is exported as ODX document.This module is firstly the need of new ODX document is created, so It is needed afterwards according to the content and the definition of XML file structure in Java object, the efficient generation object of lower coupling needs to export All member variables in ODX document, output one meet odx.xsd requirement XML document.
Detailed description of the invention
Fig. 1 is three modules and its corresponding relationship of ODX document parsing and generation technique, and the present invention is first to ODX document XML Schema rule parsed, next complete the mutual conversion between ODX document and Java object.Detailed process is such as Under:
1) XML Schema rule is converted: XML Schema file of the strictly all rules of ODX document in ODX document There are clear stipulaties in odx.xsd.To realize the mutual conversion between ODX document and Java it is necessary to various to what is wherein occurred The mapping under Java data structure is explained and provided to rule, to achieve the effect that standardization generates java class.
2) after XML Schema is converted, many Java objects can ODX document structure tree algorithm: be generated.It needs to use at this time DOM frame parses ODX document, and the high degree of coupling of DOM frame, recursive parsing are substantially reduced using reflection mechanism ODX document.
3) ODX document structure tree algorithm: ODX document is created by DOM frame first, is next passed with Java reflection mechanism Return the xml code for generating ODX document.
Fig. 2 is the pseudocode of ODX document parsing module, and specific step is as follows for module:
1) firstly, utilizing the indiscriminate all information about firms for extracting parsing class of reflection mechanism.
2) attribute and element information that root node to be resolved is next extracted using DOM frame, construct queue to be resolved.
3) finally, carrying out recursive assignment operation to variable for different types of data.
Fig. 3 is the pseudocode of ODX document creation module, and specific step is as follows for module:
1) firstly, utilizing the indiscriminate all information about firms for extracting parsing class of reflection mechanism.
2) next using the information about firms extracted in step 1) as queue to be generated, each member change is looped to determine Whether amount should export, and if it is execute output operation.
Specific embodiment
The present invention includes three modules, therefore describes specific steps respectively according to these three modules.
XML Schema parsing module specifically includes the following steps:
1) it firstly, summarizing the strictly all rules occurred in the XML Schema file (odx.xsd) of ODX document, and carries out Classifying Sum.
2) different mapping rulers is designed for different types of rule that step 1) extracts, it is ensured that corresponding java class It can satisfy these rules
The rule that rule in step 1) summarizes in ODX document white paper summarizes.All rules can be divided For basic data type rule, complex data type rule, structure type rule, constrained type rule and expansion type rule.
Step 2) devises corresponding mapping method for different types of rule that step 1) extracts.Master data class The conversion method of type rule are as follows:
The conversion method of complex data type rule are as follows:
Structure, the conversion method of constraint and expansion type are as follows:
As shown in Fig. 2, ODX document parsing module comprising the following steps:
1) firstly, using the indiscriminate all information about firms for extracting parsing class of reflection mechanism, code 3- in corresponding diagram 2 8 rows.
2) attribute and element information that root node to be resolved is next extracted using DOM frame, construct queue to be resolved, right Answer code 9-12 row in Fig. 2.
3) finally, carrying out recursive assignment operation, code 14-34 in corresponding diagram 2 to variable for different types of data Row.
Step 1) extracts all class members's information that class TARGET to be resolved is inherited by reflection mechanism, circulation.It counts at this time What is stored in group fields is all variables that possible use in this parsing.
Step 2) obtains all properties and element information of root node ROOT by DOM frame.Queue to be resolved at this time What is stored in parserQueue is all XML attributes or element for waiting and being resolved, next the category in parserQueue Property or the value of element are mapped in the corresponding member variable of TARGET class.
Step 3) does following two pieces thing: (1) In to each of queue parserQueue to be resolved element or attribute Corresponding member variable is searched out in fields;(2) according to the different recursive completion assignment operations of data type: for base Notebook data type carries out indirect assignment, carries out recurrence assignment for member object, recycles each array member for aray variable And indirect assignment is selected according to the actual type of each array member or carries out recursive operation.
As shown in figure 3, ODX document creation module comprising the following steps:
1) firstly, using the indiscriminate all information about firms for extracting parsing class of reflection mechanism, code 3- in corresponding diagram 3 7 rows.
2) next using the information about firms extracted in step 1) as queue to be generated, loop to determine each at Whether member's variable should export, and if it is execute output operation.Code 8-33 row in corresponding diagram 2.
Step 1) extracts all class members's information that class TARGET to be resolved is inherited by reflection mechanism, circulation.It counts at this time What is stored in group fields is all variables that possible use during this ODX document structure tree.
Step 2) does following two pieces thing using fields as queue to be generated, to each member of fields array: (1) By the member variable whether by parsing or modification, judge whether the member variable should export;(2) according to different data The recursive completion ODX document generation operation of type: basic data type is directly generated, member object is passed Return generation, for aray variable recycle each array member and according to the actual type of each array member selection directly generate or into Row recursive operation.
After three above module is completed, the present invention carries out the relevant analysis of Time & Space Complexity.
In the whole process of parsing, the operation carried out is needed to have: (1) constructing dom tree for the document of input;(2) recursive solution Analysis input document.Before analysing in depth this two-part time complexity, need to define what some analyses needed to use first Variable: N is the sum of element and attribute of the ODX document of input;X is the member variable number that an average java class includes.
The building process of dom tree is looked first at, the essence of dom tree is traversal XML document, constructs mapping tree.In XML document In, if XML document can regard the tree for having N number of node as attribute as leaf node.It is available, no matter It is depth-first traversal or breadth first traversal, time complexity is O (N).Resolving is looked next at, according to solution above Analysis algorithm it is found that analytical algorithm can be locating to each attribute or element traversal all member variables of class match, with Recursion resolution afterwards, therefore the time complexity of resolving is O (xN).The time complexity of entire analytical algorithm are as follows:
O (xN)+O (N)=O (N)
In the entire parsing and generating process, the following information of major storage in JVM heap: the dom tree of building is parsed Java variable and recurrence stack.Still assume that n1 is the first prime number for inputting document at this time, n2 is attribute number, and N is element and attribute Sum, a are storage space of the attribute in dom tree, and b is storage space of the element in dom tree, and t is Java change The ratio of variable is resolved in amount, x is the member variable number that average each java class possesses.It is available, the space of dom tree Complexity are as follows:
O (a × n1)+O (b × n2)=O (N)
Store the space complexity of Java variable are as follows:
O (N ÷ t)=O (N)
The space complexity of recurrence information are as follows:
O (N ÷ x)=O (N)
Therefore, algorithm total space complexity is O (N).
In short, the invention proposes a kind of parsing of universal ODX document and generation technique, which is divided into three moulds Block: XML Schema parsing module, ODX document parsing module and ODX document creation module.XML Schema module design The XML Schema transformation rule for meeting ODX document format, to each of ODX document class standard metaplasia at corresponding Java Class mapping;The parsing of ODX document and generation module are based on DOM analytical framework and it is efficient to devise lower coupling in conjunction with Java reflection mechanism Mutual transfer algorithm between the ODX document and Java object of rate.The parsing and generation technique that this discovery is proposed have linear Time & Space Complexity, have clear superiority in the parsing of large-scale ODX document.

Claims (5)

1. ODX (the Open that one kind is based on DOM (Document Object Model, DOM Document Object Model) frame Diagnostic data exchange, the open diagnostic data of road vehicle) document parses and generation technique, it is characterized in that root According in ODX document XML Schema file construct Java object mapping ruler, be ODX document each class standard metaplasia at Java data structure;The operation for being resolved to Java object can be carried out to ODX document, i.e., extract member using reflection mechanism and believe It ceases, and extracts the attribute and element of root node to be resolved using DOM frame, recurrence assignment behaviour is carried out according to different types of data Make;Corresponding ODX document can be generated for Java object, i.e., extract information about firms using reflection mechanism, and to each member Whether judgement should export, and be exported ODX document recurrence using DOM frame.
2. a kind of described parsing of ODX document and generation technique, feature based on DOM frame includes according to claim 1 Following steps:
1) transformation rule collection is formulated based on the XML Schema document in ODX document, in the building Java data structure stage, is Corresponding mapping ruler is formulated in every kind of constraint in XML Schema document, and formation rule collection generates Java number for standardizing According to structure;
2) degree of coupling is reduced based on Java reflection mechanism, structure is come for class a operation Java reflection mechanism a large amount of in ODX document Build unified interface;
3) exploitation of XML parsing and Core Generator based on DOM frame selects DOM frame when parsing and generating ODX document To carry out the parsing and generation of xml code.
3. the parsing of ODX document and generation technique according to claim 2 based on DOM frame, it is characterized in that in step 1) Transformation rule collection is formulated based on the XML Schema document in ODX document, is XML in the building Java data structure stage Corresponding mapping ruler is formulated in every kind of constraint in Schema document, and formation rule collection generates Java data knot for standardizing Structure;The legacy structure content and limitation that XML Schema is used to describe XML document define sharable vocabulary, it is provided The necessary frame of XML document and the limitation for acting on this document, are described in detail the different elements and attribute of an XML document Resulting structure and data type, the XML Schema document rule in ODX document is divided into following five seed type: base by the present invention Notebook data typing rule, complex data type rule, structure type rule, constrained type rule and expansion type rule, and needle To the corresponding mapping ruler collection of each type of Rulemaking, it is ensured that the Java data structure of generation can correspond to the institute of ODX document It requires.
4. the parsing of ODX document and generation technique according to claim 2 based on DOM frame, it is characterized in that in step 2), The degree of coupling is reduced based on Java reflection mechanism, unification is constructed for class a operation Java reflection mechanism a large amount of in ODX document Interface;Java reflection mechanism to provide unified parsing for different classes a large amount of in ODX document and generates interface offer May, in the present invention, Java reflection mechanism is mainly used among ODX document analytic technique and ODX document structure tree technology, tool Gymnastics is made as follows:
ODX document analytic technique: in the algorithm incipient stage, believed using the member of Java reflection mechanism Dynamic Extraction class to be resolved Breath;The type of member variable is judged using reflection mechanism in assignment phase, and finally completes assignment operation using reflection mechanism;
ODX document structure tree technology: in the algorithm incipient stage, believed using the member of Java reflection mechanism Dynamic Extraction class to be generated Breath, constructs list to be generated;In document output stage, the type of member variable is judged using Java reflection mechanism and extracts member The value of variable.
5. the parsing of ODX document and generation technique according to claim 2 based on DOM frame, it is characterized in that in step 3), The exploitation of XML parsing and Core Generator based on DOM frame selects DOM frame to carry out when parsing and generating ODX document The parsing and generation of xml code;DOM framework technology apply to XML Schema document analysis module, ODX document creation module and ODX document parsing module all among three modules, specifically includes: the reading and information extraction of XML Schema file;ODX text The reading and information extraction of shelves;The generation of ODX document.
CN201810485857.5A 2018-05-16 2018-05-16 The parsing of ODX document and generation technique based on DOM frame Pending CN110502667A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201810485857.5A CN110502667A (en) 2018-05-16 2018-05-16 The parsing of ODX document and generation technique based on DOM frame

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201810485857.5A CN110502667A (en) 2018-05-16 2018-05-16 The parsing of ODX document and generation technique based on DOM frame

Publications (1)

Publication Number Publication Date
CN110502667A true CN110502667A (en) 2019-11-26

Family

ID=68584175

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201810485857.5A Pending CN110502667A (en) 2018-05-16 2018-05-16 The parsing of ODX document and generation technique based on DOM frame

Country Status (1)

Country Link
CN (1) CN110502667A (en)

Cited By (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111258564A (en) * 2020-01-17 2020-06-09 通号万全信号设备有限公司 Method and device for automatically generating codes based on QT
CN111552267A (en) * 2020-04-22 2020-08-18 深圳市元征科技股份有限公司 Vehicle diagnosis method and device and vehicle diagnosis equipment
CN112035474A (en) * 2020-08-28 2020-12-04 深圳市元征科技股份有限公司 Data searching method and device
CN112445491A (en) * 2020-11-19 2021-03-05 深圳市元征科技股份有限公司 File sequence processing method and device, terminal equipment and storage medium
CN115935946A (en) * 2022-12-05 2023-04-07 成都延华西部健康医疗信息产业研究院有限公司 Analytic mapping processing method and device of HL7V3 standard/FHIR standard

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
蔚晓娟 等: "基于DOM的XML解析与应用", 《计算机技术与发展》 *

Cited By (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111258564A (en) * 2020-01-17 2020-06-09 通号万全信号设备有限公司 Method and device for automatically generating codes based on QT
CN111258564B (en) * 2020-01-17 2024-04-26 通号万全信号设备有限公司 Method and device for automatically generating codes based on QT
CN111552267A (en) * 2020-04-22 2020-08-18 深圳市元征科技股份有限公司 Vehicle diagnosis method and device and vehicle diagnosis equipment
CN112035474A (en) * 2020-08-28 2020-12-04 深圳市元征科技股份有限公司 Data searching method and device
CN112035474B (en) * 2020-08-28 2023-06-02 深圳市元征科技股份有限公司 Data searching method and device
CN112445491A (en) * 2020-11-19 2021-03-05 深圳市元征科技股份有限公司 File sequence processing method and device, terminal equipment and storage medium
CN115935946A (en) * 2022-12-05 2023-04-07 成都延华西部健康医疗信息产业研究院有限公司 Analytic mapping processing method and device of HL7V3 standard/FHIR standard
CN115935946B (en) * 2022-12-05 2023-08-15 成都延华西部健康医疗信息产业研究院有限公司 Analytical mapping processing method and device for HL7V3 standard/FHIR standard

Similar Documents

Publication Publication Date Title
CN110502667A (en) The parsing of ODX document and generation technique based on DOM frame
CN102341781B (en) Software test bed generation
Visser et al. Enabling technologies for interoperability
Candel et al. A unified metamodel for NoSQL and relational databases
US8924415B2 (en) Schema mapping and data transformation on the basis of a conceptual model
US8234312B2 (en) Schema mapping and data transformation on the basis of layout and content
CN103412853B (en) A kind of automatic example generation method for file convertor
US20090024384A1 (en) Data processing method and system, program for realizing the method, and computer readable storage medium storing the program
US20050203869A1 (en) Hierarchical database apparatus, components selection method in hierarchical database, and components selection program
US7756819B2 (en) Integrated authoring system for electronic technical manual and paper technical manual using logistics support analysis data and authoring method therefor
WO2008021561A2 (en) Joint optimization of wrapper generation and template detection
CN114638160B (en) Knowledge service method for complex equipment digital twin model
WO2000075849A2 (en) Method and apparatus for data access to heterogeneous data sources
CN105808853B (en) A kind of ontological construction management of Engineering Oriented application and ontology data automatic obtaining method
CN107133027A (en) A kind of syntax tree stratification method for expressing
CN115547466B (en) Medical institution registration and review system and method based on big data
CN103425740A (en) IOT (Internet Of Things) faced material information retrieval method based on semantic clustering
CN105260300A (en) Service test method based on CAS (General Classification Standards of China Accounting Standards) application platform
CN115202626A (en) Low-code front-end development method supporting multi-technology stack components
Mann et al. SMT-switch: a solver-agnostic C++ API for SMT solving
CN109325217B (en) File conversion method, system, device and computer readable storage medium
US8131728B2 (en) Processing large sized relationship-specifying markup language documents
CN115169578A (en) AI model production method and system based on meta-space data markers
CN108228688B (en) Template generation method, system and server based on XBRL
Forcher et al. Semantic logging: Towards explanation-aware das

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
WD01 Invention patent application deemed withdrawn after publication

Application publication date: 20191126

WD01 Invention patent application deemed withdrawn after publication