A method for generating secure platform data based on XSD configuration
Through the security platform data generation method based on XSD configuration, the problem of configuration data generation in the rail transit signal equipment system is solved, and an efficient, general and easy-to-maintain data generation process is realized.
Patent Information
- Application Number
- CN202111261747.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-10-28
- Publication Date
- 2025-03-04
- Estimated Expiration
- 2041-10-28
AI Technical Summary
In rail transit signal equipment systems, traditional methods generate configuration data with problems such as increased difficulty in data analysis, lengthy code, lack of universality and expansion.
The secure platform data generation method based on XSD configuration is adopted to generate configuration information jar packages by reading the XSD rule configuration file, and combined with the data processing platform jar package, the automatic processing and generation of input and output files are realized.
It improves data generation efficiency, reduces the amount of code, enhances the universality and expansion of the system, and facilitates maintenance and updates.
Smart Images

Figure CN113986220B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of data processing, and in particular to a method for generating security platform data based on XSD (XML Schema Definition, extensible markup language framework) configuration. Background Art
[0002] In the rail transit signal equipment system, in order to make the system run normally, the configuration data of the station equipment needs to be burned into the flash of the system hardware board. If the traditional method is used to generate the configuration data, the following problems will occur: (1) Directly reading the input file and parsing it. This method is only suitable for small input data volumes. When the input data volume increases, the difficulty of parsing the input data increases exponentially, which will take a lot of time. (2) There is no defined output data template. This method results in each output file needing to use code to build its own framework, fill in the fields in the framework, and then generate the file. As a result, the code becomes lengthy and bloated, which is not conducive to daily maintenance. (3) The code of each project is only applicable to its own project and cannot be universal. In addition, the project code has poor scalability. Iterative updates of the project lead to changes in the input and output files, which requires a large amount of code to be added to the reading and output parts. Summary of the invention
[0003] The present invention provides a method for generating safety platform data based on XSD configuration for data configuration of rail transit signal system equipment. The method comprises two parts. The first part is a class generation tool in the form of an executable jar package (Java ARchive, Java archive), and its function is to read the XSD rule configuration file and output a jar package containing input file configuration information. The second part is a data processing platform, which is in the form of a jar package that cannot be run independently. Developers are required to import the data processing platform jar package and the configuration file information jar package generated by the first part into the project, and then call the reading and processing output methods of the safety platform data in various formats provided. Currently, input and output processing in multiple formats is supported.
[0004] To achieve the above-mentioned purpose, the present invention provides a security platform data generation method based on XSD configuration, which comprises the following steps: step S1, read the template input file and generate an XSD configuration file; step S2, read and parse the XSD configuration file generated in step S1 to obtain XSD configuration information; step S3, write the XSD configuration information parsed in step S2 into a class file and generate a configuration information jar package; step S4, read the actual input file to be processed of the project, create a first object, and store the data contained in the actual input file in the first object; step S5, based on the class file in the configuration information jar package generated in step S3, create a second object, and fill the data in the first object into the second object; step S6, according to the file format generated by the user, output the configuration data file containing the second object filled in step S5.
[0005] Among them, the generation of the XSD configuration file described in step S1 specifically includes: defining the fields in the template input file according to project requirements, configuring the fields in the template input file as complex type elements or simple type elements, and generating an XSD configuration file that outputs the filled data; and the same type of template input file only needs to configure one XSD configuration file.
[0006] Among them, the reading and parsing of the XSD configuration file described in step S2 specifically includes the following steps: step S201, using a third-party tool to read the configuration information stored in the XSD configuration file generated in step S1, and storing the element type and attribute type in the configuration information in a preset object; step S202, creating a newly defined storage object; step S203, storing the element configuration information in the preset object in the storage object created in step S202.
[0007] Preferably, the element type and attribute type information in the preset object described in step S201 is stored in a tree structure; the root node of the tree structure is a complex type element or a simple type element; the nodes under the root node are all child nodes; if the root node is a complex type element, the child nodes under the root node are simple type elements or attribute types; if the root node is a simple type element, the child nodes under the root node are empty.
[0008] Among them, the storage process described in step S203 includes: step S231, recursively traverse from the root node of the preset object generated in step S201 to obtain all element types and attribute type information; step S232, according to the upper and lower levels of the element types of the tree structure in the preset object, set the parent-child relationship between the root node and the child node in the storage object; step S233, if the attribute type exists, store the attribute type in the child node of the storage object; if the attribute type does not exist, there is no need to perform step S233 until all element types of the preset object are traversed.
[0009] Among them, the step S3 of writing the XSD configuration information into the class file and generating a jar package specifically includes the following steps: step S301, traversing the storage objects in step S203 in sequence; step S302, distinguishing the element type traversed in step S301 to obtain a complex type element; step S303, marking each complex type element in step S302, and generating a class file separately for each complex type element; step S304, summarizing all the class files generated in step S303, and packaging them to generate a configuration information jar package.
[0010] Preferably, the complex type element marked in step S303 includes corresponding simple type elements and attribute types.
[0011] Preferably, the class file generated in step S303 generates a filling interface function according to the element type and attribute type contained in the current class file, and saves the filling interface function in the corresponding class file.
[0012] Among them, the reading of the actual input file to be processed of the project described in step S4 specifically includes the following steps: step S401, importing the configuration information jar package and the data processing platform jar package generated in step S3 into the corresponding project; step S402, creating a corresponding first object according to the format of the actual input file of the project; step S403, calling the internal interface function in the data processing platform jar package to store the object in the actual input file into the first object.
[0013] Among them, when creating the second object, step S5 calls the filling interface functions of all class files corresponding to the actual input files in the configuration information jar package generated in step S3 in sequence; uses the filling interface function to search the corresponding element in the first object created in step S4 according to the field name and fills the element into the second object.
[0014] Preferably, in the process of filling the object in step S5, before filling each element, it is first determined whether the current element contains the restriction condition. If so, a corresponding check is performed. If the check is correct, the next element is filled. If the check is wrong, the program reports an error and stops the filling process.
[0015] The output configuration data file described in step S6 is generated and outputted in a specified format by calling an internal interface function in a data processing platform jar package that matches the project output file format.
[0016] In summary, compared with the prior art, the method for generating secure platform data based on XSD configuration provided by the present invention has the following beneficial effects:
[0017] (1) The present invention uses XSD to configure the input and output file data structure. The good extensibility of XSD files facilitates later updates and maintenance;
[0018] (2) The present invention abstracts the rule configuration file into an XSD file and converts it into a class file in the form of metadata, and outputs it in the form of a jar package for users to call. The provided framework template greatly reduces the amount of code in the process of processing input and output files. Only the method interface needs to be called to realize the reading and output processing, which is convenient for users to integrate;
[0019] (3) The present invention has strong versatility and supports reading and outputting input files in various formats including INI, XML, CSV, PAR, BIN, etc., and can meet the needs of users of different products;
[0020] (4) This data configuration tool has been integrated into the safety data configuration tools of signal projects such as 200T, VCU, and TSP. In actual use, it has greatly improved the efficiency of user data configuration. At the same time, due to its good scalability, subsequent maintenance and updates are more convenient than traditional methods. BRIEF DESCRIPTION OF THE DRAWINGS
[0021] Figure 1 It is a flow chart of the method for generating secure platform data based on XSD configuration of the present invention;
[0022] Figure 2 A schematic diagram of the device structure of the XSD-configured security platform data generation method of the present invention. DETAILED DESCRIPTION
[0023] The following will be combined with the attached embodiment of the present invention Figure 1 ~Attached Figure 2 , the technical solutions, structural features, objectives achieved and effects in the embodiments of the present invention are described in detail.
[0024] It should be noted that the drawings are in a very simplified form and use non-precise proportions. They are only used to conveniently and clearly assist in explaining the embodiments of the present invention, and are not used to limit the conditions for the implementation of the present invention. Therefore, they have no substantive technical significance. Any structural modification, change in proportional relationship or adjustment of size, without affecting the effects and purposes that can be achieved by the present invention, should still fall within the scope of the technical content disclosed by the present invention.
[0025] It should be noted that, in the present invention, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only the elements explicitly listed, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device.
[0026] The XSD configuration file contains two basic types: element and attribute. The element type must exist in the XSD configuration file, and the existence of the attribute type is related to the format of the input file. For example, there are only element types in the INI format input file, while there are element types in the XML format input file, and the attribute type is also configured. The XSD configuration file can be read by a third-party tool, and a tree-structured data object with a root node is output. The present invention provides a security platform data generation method based on XSD configuration, and the data generation method includes two parts. One part is to generate an XSD configuration information jar package based on the XSD configuration file, and the other part is to import the generated configuration information jar package and the data processing platform jar package into the project, and use the various interface functions contained in the data processing platform jar package to generate the corresponding configuration data file. Figure 1 As shown, the security platform data generation method specifically includes the following steps:
[0027] Step S1, read the template input file and generate an XSD configuration file;
[0028] Step S2, reading and parsing the XSD configuration file generated in step S1 to obtain XSD configuration information;
[0029] Step S3, write the XSD configuration information parsed in step S2 into a class file and generate a configuration information jar package;
[0030] Step S4, reading the actual input file to be processed of the project, creating a first object, and storing the data contained in the actual input file in the first object;
[0031] Step S5: Create a second object based on the class file in the configuration information jar package generated in step S3, and fill the data in the first object into the second object;
[0032] Step S6: Output the configuration data file containing the second object filled in step S5 according to the file format generated by the user.
[0033] Among them, the template input file described in step S1 includes INI, XML, CSV, PAR, and BIN format files, and the fields of each format file correspond to the elements in the XSD configuration file including the field name, field type, maximum number of field occurrences, and minimum number of field occurrences.
[0034] Furthermore, the elements are divided into simple type elements and complex type elements. The simple type elements include the following basic data types: String, Byte, Short, Integer, Double, Boolean, Long, Date. If the scope of the element is restricted in the project requirements, a <annotation>Sub-elements; The sub-elements of the restriction conditions include: maximum value, minimum value, regular expression, fixed value, maximum length, minimum length, file type, optionality, enumeration value, big-endian and small-endian storage, primitive type, and default value; All elements except the simple type elements mentioned above are defined as complex type elements. When generating a configuration file, the complex type elements will generate a class file separately, and the class file contains the corresponding simple type elements. That is to say, the simple type elements will not generate output files separately, but will be included in the class file generated by the complex type elements.
[0035] Among them, the generation of the XSD configuration file described in step S1 specifically includes: defining the fields in the template input file according to project requirements, configuring the fields in the template input file as complex type elements or simple type elements, and generating an XSD configuration file that outputs the filled data; and the same type of template input file only needs to configure one XSD configuration file.
[0036] The reading and parsing of the XSD configuration file in step S2 specifically includes the following steps:
[0037] Step S201: Use a third-party tool to read the configuration information stored in the XSD configuration file generated in step S1, and store the element type and attribute type in the configuration information in a preset object;
[0038] Step S202: Create a newly defined storage object;
[0039] Step S203: Store the element configuration information in the preset object into the storage object created in step S202.
[0040] Among them, the element type and attribute type information in the preset object described in step S201 are stored in a tree structure; the root node of the tree structure is a complex type element or a simple type element; the nodes under the root node are all child nodes; if the root node is a complex type element, the child nodes under the root node are simple type elements or attribute types; if the root node is a simple type element, the child nodes under the root node are empty, that is, there are no child nodes.
[0041] Furthermore, the storage process described in step S203 includes:
[0042] Step S231, recursively traverse from the root node of the preset object generated in step S201 to obtain all element type and attribute type information;
[0043] Step S232: According to the upper and lower levels of the element types of the tree structure in the preset object, a parent-child relationship between the root node and the child nodes is correspondingly set in the storage object;
[0044] Step S233: if the attribute type exists, store the attribute type in the child node of the storage object; if the attribute type does not exist, there is no need to perform step S233 until all element types of the preset object are traversed.
[0045] Through steps S201 to S203 , the hierarchical relationship of elements in the storage object can be made consistent with the hierarchical relationship of elements in the XSD configuration file generated in step S1 .
[0046] Wherein, writing the XSD configuration information into the class file and generating the jar package in step S3 specifically includes the following steps:
[0047] Step S301, traverse the storage objects in step S203 in sequence;
[0048] Step S302, determining the element type obtained by traversing in step S301 to obtain a complex type element;
[0049] Step S303: Mark each complex type element in step S302, and generate a class file for each complex type element separately;
[0050] Step S304: Aggregate all class files generated in step S303 and package them to generate a configuration information jar package.
[0051] Furthermore, the complex type element marked in step S303 contains the corresponding simple type element and attribute type, that is, the corresponding simple type element and attribute type will be stored in the class file of the complex element type to which it is attached. At the same time, the class file generated in step S303 will generate a filling interface function according to the element type and attribute type contained in the current class file, and save the filling interface function in the corresponding class file.
[0052] The actual input file to be processed in step S4 includes the following steps:
[0053] Step S401: Import the configuration information jar package generated in step S3 and the existing data processing platform jar package into the corresponding project;
[0054] Step S402: Create a corresponding first object according to the format of the actual input file of the project;
[0055] Step S403: Call the internal interface function in the data processing platform jar package to store the object in the actual input file into the first object.
[0056] Among them, the data processing platform jar package described in step S401 includes multiple functional jar packages with different purposes; such as jar packages for obtaining various paths, jar packages for file reading and output processing, jar packages for running data processing platforms, etc.; each of the functional jar packages stores multiple internal interface functions with different functions.
[0057] Among them, when creating the second object, step S5 sequentially calls the filling interface functions of all class files corresponding to the actual input files in the configuration information jar package generated in step S3; uses the filling interface function to find the corresponding element in the first object created in step S4 according to the field name and fills the element into the second object; at the same time, before filling each element, it will first determine whether the current element contains a restriction condition. If it does, it will make a corresponding check. If the check is correct, it will continue to fill the next element. If the check is wrong, the program will report an error and stop the filling process. By checking the restriction conditions, it can be ensured that the element filling is consistent with the rule range format given by the project requirements.
[0058] The process of outputting the data file described in step S6 includes: calling the internal interface function in the data processing platform jar package according to the file format outputted according to the project requirements, so as to realize the generation and output of the configuration data file in the specified format.
[0059] Specifically, taking the 200T safety computer trackside data configuration tool integrated with the data generation method as an example, a station data with an input file format of INI is configured based on the configuration tool to specifically illustrate the use process of the method:
[0060] Step S1, generate an XSD configuration file based on the definition of the input file field in the 200T project requirements and the INI format input file (i.e., the template input file). The field contained in the input file is configured as a complex type element A; the element tag contained in the field is configured as a simple type element B, and the XSD configuration file with the element type configured is output. Since the input file format of this implementation is INI, there is no need to configure the attribute type in this embodiment.
[0061] Step S2, read and parse the XSD configuration file generated in step S1. Step S201, use the third-party tool XSOM to read the configuration information stored in the XSD configuration file generated in step S1, and store the complex type element A and the simple type element B in the configuration information in the preset object 1; step S202, create a newly defined storage object 2; step S203, store the complex type element A and the simple type element B in the preset object 1 in the storage object 2 created in step S202.
[0062] Further, step S203 includes: step S231, recursively traverse from the root node of the preset object 1 generated in step S201 to obtain information of all complex type elements A and simple type elements B; step S232, according to the upper and lower levels of the complex type elements A and the simple type elements B, set the parent-child relationship between the root node and the child node in the storage object 2. In the storage object 2 of this embodiment, the complex type element A is configured as the parent node (root node), and the simple type element B is configured as the children node (child node); this embodiment has no attribute type, so it is only necessary to traverse all elements of the preset object 1.
[0063] Step S3, write the XSD configuration information parsed in step S2 into the class file and generate a jar package; specifically including: step S301, traverse the elements in the storage object 2 created in step S203 in sequence; step S302, identify the element information traversed in step S301 again to obtain a complex type element B; step S303, mark the complex type element B in step S302, and generate a class file for the complex type element B separately; step S304, package the class file generated in step S303 to generate a configuration information jar package. Among them, the class file generated in step S303 will generate the corresponding filling interface function according to the element type contained in the current class file, and save it in the class file.
[0064] Step S4, read the actual input file of the project; specifically: Step S401, import the configuration information jar package and the data processing platform jar package generated in Step S3 into the 200T project; Step S402, according to the input file is in INI format, create an iniNode object that processes the INI input file interface function, and initialize the parameters of the incoming file path, file prefix (used to distinguish files when reading), and file structure MAP (MAP created according to the input file, key is the node name, value is the list of field names contained under the node) in the iniNode object; Step S403, call the internal interface function in the data processing platform jar package, store the objects in the actual input file into the iniNode object, and through the internal interface function, return the iniNode object containing the INI file content of the specified path, and the data structure in the iniNode object is consistent with the MAP data structure of the input file.
[0065] Step S5, according to the INI file read in step S4, find the filling interface function corresponding to the class file from the configuration information jar package generated by the imported step S3, and create the second object to be filled in the end, and use the iniNode object containing various element type information of the input file returned by step S4 as the first parameter, and use the filling interface function to find the corresponding element in the iniNode object returned by step S4 according to the field name and fill it into the second object; and according to the restriction condition type, pass the second object as the second parameter to the range check interface in the data processing platform jar package. Taking the maximum value check as an example, after the range check interface is called, the maximum and minimum value information will be obtained from the iniNode object, and compared with the field value obtained by the second object. If an illegal value appears, an error reminder will be given, otherwise it will run down in order until all elements in the second object are traversed.
[0066] Step S6, generate and output a configuration data file in a specified format; in this embodiment, an IniWriter object is created in the data processing platform jar package, and the writerToFile interface of the IniWriter object can be called. Specifically, the second object and the output path returned after filling in step S5 are used as parameters, and the writerToFile interface of the IniWriter object is called, and the writerToFile interface can generate an output file in INI format.
[0067] The specific process of users generating security platform data is as follows: Figure 2 As shown, the XSD configuration file and the actual output file are imported into the security data platform software, and the site data file is generated through steps S1-S6. Then the user uses any storage tool (such as a USB flash drive, a CD, etc.) to import the site data generated by the security data platform software into the on-site equipment, thus completing the entry of the station equipment configuration data.
[0068] In summary, compared with the existing data generation methods, the security platform data generation method based on XSD configuration provided by the present invention has the advantages of strong scalability, easy user integration, and simple maintenance.
[0069] Although the content of the present invention has been described in detail through the above preferred embodiments, it should be appreciated that the above description should not be considered as a limitation of the present invention. After reading the above content, it will be apparent to those skilled in the art that various modifications and substitutions of the present invention will occur. Therefore, the protection scope of the present invention should be limited by the appended claims.< / annotation>
Claims
1. A method for generating data of a security platform based on XSD configuration, the method comprises two parts, one part is to generate an XSD configuration information jar package based on the XSD configuration file, the other part is to import the generated configuration information jar package and the data processing platform jar package into the project, and use the various interface functions contained in the data processing platform jar package to generate the corresponding configuration data file, characterized in that: The specific steps include: Step S1, read the template input file and generate an XSD configuration file; Step S2, reading and parsing the XSD configuration file generated in step S1 to obtain XSD configuration information; Step S3, write the XSD configuration information parsed in step S2 into a class file and generate a configuration information jar package; Step S4, reading the actual input file to be processed of the project, creating a first object, and storing the data contained in the actual input file in the first object; Step S5: Create a second object based on the class file in the configuration information jar package generated in step S3, and fill the data in the first object into the second object; Step S6: Outputting the configuration data file containing the second object filled in step S5 according to the file format generated by the user; The reading and parsing of the XSD configuration file in step S2 specifically includes the following steps: Step S201: Use a third-party tool to read the configuration information stored in the XSD configuration file generated in step S1, and store the element type and attribute type in the configuration information in a preset object; Step S202: Create a newly defined storage object; Step S203, storing the element configuration information in the preset object into the storage object created in step S202; The element type and attribute type information in the preset object described in step S201 is stored in a tree structure; the root node of the tree structure is a complex type element or a simple type element; the nodes under the root node are all child nodes; if the root node is a complex type element, the child nodes under the root node are simple type elements or attribute types; if the root node is a simple type element, the child nodes under the root node are empty; The storage process described in step S203 includes: Step S231, recursively traverse from the root node of the preset object generated in step S201 to obtain all element type and attribute type information; Step S232: According to the upper and lower levels of the element types of the tree structure in the preset object, a parent-child relationship between the root node and the child nodes is correspondingly set in the storage object; Step S233: if the attribute type exists, store the attribute type in the child node of the storage object; if the attribute type does not exist, step S233 is not required until all element types of the preset object are traversed; Wherein, writing the XSD configuration information into the class file and generating the jar package in step S3 specifically includes the following steps: Step S301, traverse the storage objects in step S203 in sequence; Step S302, determining the element type obtained by traversing in step S301 to obtain a complex type element; Step S303: Mark each complex type element in step S302, and generate a class file for each complex type element separately; Step S304: Aggregate all class files generated in step S303 and package them to generate a configuration information jar package; The class file generated in step S303 generates a filling interface function according to the element type and attribute type contained in the current class file, and saves the filling interface function in the corresponding class file.
2. The method for generating secure platform data based on XSD configuration according to claim 1, characterized in that: The generation of the XSD configuration file described in step S1 specifically includes: defining the fields in the template input file according to project requirements, configuring the fields in the template input file as complex type elements or simple type elements, and generating an XSD configuration file that outputs the filled data; and the same type of template input file only needs to configure one XSD configuration file.
3. The method for generating secure platform data based on XSD configuration according to claim 1, characterized in that: The complex type element marked in step S303 includes the corresponding simple type element and attribute type.
4. The method for generating secure platform data based on XSD configuration according to claim 1, characterized in that: The actual input file to be processed of the reading project described in step S4 specifically includes the following steps: Step S401: Import the configuration information jar package and the data processing platform jar package generated in step S3 into the corresponding project; Step S402: Create a corresponding first object according to the format of the actual input file of the project; Step S403: Call the internal interface function in the data processing platform jar package to store the object in the actual input file into the first object.
5. The method for generating secure platform data based on XSD configuration according to claim 4, characterized in that: When creating the second object, step S5 sequentially calls the filling interface functions of all class files corresponding to the actual input files in the configuration information jar package generated in step S3; uses the filling interface function to search the corresponding element in the first object created in step S4 according to the field name and fills the element into the second object.
6. The method for generating secure platform data based on XSD configuration according to claim 5, characterized in that: In the process of filling the object in step S5, before filling each element, it will first determine whether the current element contains the restriction condition. If it does, a corresponding check will be performed. If the check is correct, the next element will be filled; if the check is wrong, the program will report an error and stop the filling process.
7. The method for generating secure platform data based on XSD configuration according to claim 6, characterized in that: The output configuration data file described in step S6 is generated and outputted in a specified format by calling an internal interface function in the data processing platform jar package that matches the project output file format.
Citation Information
Patent Citations
Automatic code generation method of architecture analysis and design language (AADL) model
CN101739258A
Method for converting CSV (Comma-Separated Values) data labeled by metadata to RDF (Resource Description Framework) data
CN104933162A