A method for information extraction and conversion based on ARXML files
By converting ARXML files into JSON format, the problems of low efficiency and poor flexibility in ARXML file parsing are solved, efficient data processing and cross-platform integration are achieved, and it can adapt to different application scenarios.
Patent Information
- Application Number
- CN202411619035.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-13
- Publication Date
- 2025-09-05
- Estimated Expiration
- 2044-11-13
AI Technical Summary
The existing technology has low efficiency, poor flexibility and poor operability when parsing and processing ARXML files, and the XML format has difficulties in software system integration and cross-platform use.
An information extraction and conversion method based on ARXML files is adopted. The XPath expression is defined through the configuration file module. The parser module is used to extract information from the ARXML file and convert it into JSON format. Dynamic definition of data extraction is supported, and the action dependency parsing module is used to recursively parse path reference information.
It improves data processing efficiency, enhances data readability and operability, supports cross-platform integration, and adapts to different application scenarios.
Smart Images

Figure CN119576337B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of configuration and file format conversion of automobile electronic control units, and in particular to an information extraction and conversion method based on ARXML files. Background Art
[0002] As the number and complexity of automotive electronic control units (ECUs) increase, data management and exchange within these systems are becoming increasingly important. AUTOSAR (AUTomotive Open System ARchitecture), an open, standardized automotive software architecture, is widely adopted in the automotive industry. AUTOSAR uses the ARXML (AUTOSAR XML) file format to describe ECU configuration information and system design data. However, the complex structure and hierarchical relationships of ARXML files result in low data parsing and processing efficiency. Existing technologies primarily obtain information by directly parsing ARXML files. This approach has the following drawbacks: First, it is inefficient: ARXML files have a complex structure and a relatively bloated format, which reduces data processing efficiency. Second, it suffers from poor flexibility: most existing systems do not support dynamic definition of data to be extracted through configuration files, making it difficult to adapt to different application scenarios. Third, it suffers from poor operability: the ARXML format is not intuitive for developers, increasing the difficulty of data manipulation and debugging. Furthermore, XML-formatted data presents challenges in software system integration and cross-platform use. Summary of the Invention
[0003] The present invention aims to provide an information extraction and conversion method based on ARXML files to solve the problems raised in the above background technology. To achieve the above object, the present invention provides the following technical solutions:
[0004] An information extraction and conversion method based on ARXML files is characterized in that the conversion system adopted includes a parser module, a configuration file module and an action dependency parsing module; the method includes the following steps:
[0005] Step S1: defining XPath expressions related to information extraction in the configuration file through the configuration file module, so as to facilitate use in subsequent information extraction;
[0006] Step S2: The parser module extracts required information from the ARXML file using the XPath expression in the configuration file stored by the configuration file module, and converts the extracted information into element information according to the parsing rules. The element information is used as the main entry information to generate a main entry information JSON file.
[0007] Step S3, determining whether there is unknown path reference information in the element information, if yes, proceeding to step S4; if no, ending;
[0008] Step S4, recursively parse the unknown path reference information in the element information through the action dependency parsing module, convert the path reference information into XPath expressions, and extract information based on these expressions, and then convert the extracted information into element information according to the parsing rules. The element information is used as the path reference information to generate a path reference information JSON file.
[0009] As a further solution of the present invention: in step S2, the parser module extracts required information from the ARXML file using the XPath expression in the configuration file stored by the configuration file module, and converts the extracted information into element information according to the parsing rules, specifically including:
[0010] Read ARXML file: load ARXML file from the specified input path;
[0011] Traverse node tags: Use the XPath expression defined in the configuration file to traverse all nodes in the ARXML file and find the target node;
[0012] Recursively parse the target node: For a target node that contains child nodes, traverse and extract information of all child nodes layer by layer, store the extracted information in the corresponding data structure according to the parsing rules, retain the hierarchical relationship of the data, and output the element information in JSON format.
[0013] As a further solution of the present invention: the recursive parsing of the target node specifically includes the following steps:
[0014] Step S21, check child nodes: determine whether each node contains child nodes, if yes, go to step S22, <short-name>Tag judgment; if not, go to step S24 and perform regular analysis on the current node;
[0015] Step S22, perform <short-name>Tag judgment: Check whether the current node contains <short-name>Label, if yes, the current node exists <short-name>If the label is set, the current node is specially processed 1; if not, the current node does not exist <short-name>tag, then go to step S23 to check for duplicate tags;
[0016] Step S23, checking duplicate labels: determining whether the current node contains duplicate labels. If so, that is, duplicate labels exist, then special processing 2 is performed on the current node; if not, that is, duplicate labels do not exist, then go to step S24 and perform regular parsing on the current node.
[0017] Step S24, performing conventional parsing: For nodes that do not meet the special processing conditions, perform conventional parsing, that is, convert the node information into a dictionary form, maintaining the hierarchical relationship of the data;
[0018] Step S25, returning node data: after completing the parsing of the current node and the corresponding child nodes, returning the parsed node data, and outputting the data in JSON format.
[0019] As a further solution of the present invention: in step S24, performing conventional parsing on the current node specifically includes:
[0020] 1) Read and parse the XML structure in the ARXML file;
[0021] 2) Use the tag name in the XML structure as the key in the dictionary and the text value in the tag as the value in the corresponding dictionary;
[0022] 3) If the tag in the XML structure contains subtags, convert the subtags into a nested dictionary structure to maintain the original hierarchical relationship.
[0023] As a further solution of the present invention: In step S22, the special processing 1 is performed on the current node, specifically: when there is <short-name>When labeling, <short-name>The text value of the label is used as the root key of the processed node, and a child node is added to the processed node, and the value of the child node is the root label of the processed node.
[0024] As a further solution of the present invention: In step S23, the special processing 2 is performed on the current node, specifically: when the same level in the ARXML file contains repeated tags, and the tags do not contain <short-name>When repeating a tag, add the corresponding character mark after the repeated tag as the corresponding dictionary key.
[0025] Compared with the existing technology, the present invention has the following advantages: Given that the JSON format organizes data in key-value pairs and has a lighter structure than XML, the present invention extracts and converts ARXML file information into JSON format, which speeds up data parsing and transmission, improves data processing efficiency, and enhances data readability and operability, making it easier for developers to perform data operations and debugging. Furthermore, the present invention supports the dynamic definition of XPath expressions through configuration files, making data extraction operations more flexible. Furthermore, JSON-formatted data can be seamlessly integrated into modern software systems (including web front-ends, mobile applications, and cloud services), thus providing better cross-platform performance. BRIEF DESCRIPTION OF THE DRAWINGS
[0026] Figure 1 is an overall flow chart of the information extraction and conversion method of the present invention;
[0027] Figure 2 This is a data processing flow chart of the parser module in the information extraction and conversion method of the present invention. DETAILED DESCRIPTION
[0028] The following will clearly and completely describe the technical solutions in the embodiments of the present invention in conjunction with the accompanying drawings. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without making creative efforts are within the scope of protection of the present invention.
[0029] The information extraction and conversion method based on ARXML files provided in the specific embodiment of the present invention realizes the extraction of information from ARXML files and converts the information into JSON format that organizes data in a key-value pair manner. The overall flow chart of the information extraction and conversion method of the present invention is as follows: Figure 1 As shown, including the following:
[0030] First, the information extractor is configured through the configuration file module, including defining the namespace, duplicate key handling method, and XPath expression for navigating ARXML description information.
[0031] Then, the parser module is used to read the XPath expression in the configuration file, and the required data is extracted from the ARXML file through the XPath expression. The extracted data is organized into element information output in JSON format according to the corresponding parsing rules.
[0032] Again, part of the element information output by the parser module is the main entry information in JSON format (i.e. main entry information.json), and the other element information contains multi-level path reference (REF) information, and the path reference information can form a complex dependency chain.
[0033] Finally, when the element information contains multi-level path reference information, the action dependency parsing module recursively parses the path reference information contained in the element information, converts the path reference information into XPath expressions, extracts data based on the XPath expressions, and then organizes the extracted data into JSON format path reference information (i.e., REF.json) and outputs it according to the corresponding parsing rules.
[0034] The parser module reads the XPath expression in the configuration file and extracts the required data from the ARXML file through the XPath expression. Figure 2 As shown, the following steps are included:
[0035] (1) Read ARXML file: Load the ARXML file from the specified input path to ensure that the file format is correct and can be processed later.
[0036] (2) Traverse node labels: Apply XPath expressions to traverse all nodes in the ARXML file and check the structure and content of each node one by one.
[0037] (3) Recursively parse the target node: For nodes that contain child nodes, traverse and extract information of all child nodes layer by layer, and store the extracted information in the corresponding data structure to preserve the hierarchical relationship of the data. The specific steps are as follows:
[0038] 1) Check child nodes: Determine whether each node contains child nodes. If so, proceed <short-name>Label judgment; if not, perform regular parsing on the current node, that is, convert the node information into dictionary form.
[0039] 2) Processing <short-name>Tags: Check if the current node contains <short-name>Tag, if yes, means it exists <short-name>If the label is set, the current node is specially processed 1; if not, it means it does not exist <short-name>tag, then proceed to the next step of processing, which is to check for duplicate tags.
[0040] 3) Check for duplicate labels: Determine whether the current node contains duplicate labels. If so, it means there are duplicate labels, and the current node is subjected to special processing 2; if not, it means there are no duplicate labels, and the current node is subjected to regular parsing.
[0041] 4) Perform regular parsing: For nodes that do not meet the special processing conditions, perform regular parsing, that is, convert the node information into a dictionary form to maintain the hierarchical relationship of the data.
[0042] 5) Return node data: After completing the parsing of the current node and its child nodes, return the parsed node data and output the data in JSON format.
[0043] The node parsing performed by the recursive parsing target node includes regular parsing, special processing 1, and special processing 2, as follows:
[0044] ① Conventional parsing: recursively convert the tag information in the ARXML file into the corresponding dictionary form, including the following steps:
[0045] 1) First, read and parse the XML structure in the ARXML file;
[0046] 2) For each tag in the XML structure, use the tag name as the key in the dictionary, and the text value in the tag will correspond to the value in the dictionary;
[0047] 3) If a tag contains subtags, the subtags are converted into a nested dictionary structure to maintain the original hierarchical relationship.
[0048] For example:
[0049] Example of ARXML tag information:
[0050]
[0051]
[0052] Element information obtained after parsing:
[0053]
[0054]
[0055] ②Special processing 1: In ARXML, <short-name>Tags are used to provide a short name for each element in order to uniquely identify the elements in the file and simplify referencing and accessing them. <short-name>Tags are specially processed for subsequent reference and access. If there is <short-name>The tag uses the text value of the processed node as the root key of the node. In order to obtain the type information of the processed node, a child node "object_type" is added to the node. The value of the child node is the root tag of the processed node.
[0056] For example:
[0057] Example of arxml tag information:
[0058]
[0059] Element information obtained after parsing:
[0060]
[0061] ③ Special treatment 2: Special treatment of repeated tags: In ARXML files, there may be many repeated tags at the same level, and in the dictionary structure, the keys at the same level must be unique. To solve this problem, if the tag contains <short-name>Tags, then use the above method ② to process, for duplicate tags, if the tag does not contain <short-name>, add "@repeat times" after the repeat tag as the corresponding dictionary key.
[0062] For example:
[0063] Example of arxml tag information:
[0064] <sender-receiver-to-signal-mapping> ...
[0066] < / sender-receiver-to-signal-mapping>
[0067] <sender-receiver-to-signal-mapping> ...
[0069] < / sender-receiver-to-signal-mapping>
[0070] <sender-receiver-to-signal-mapping> ...
[0072] < / sender-receiver-to-signal-mapping>
[0073] Element information obtained after parsing:
[0074]
[0075] It will be apparent to those skilled in the art that the present invention is not limited to the details of the exemplary embodiments described above and that the invention can be embodied in other specific forms without departing from the spirit or essential characteristics of the invention. Therefore, the embodiments should be considered in all respects as illustrative and non-restrictive, and the scope of the invention is defined by the appended claims, not the foregoing description, and all variations within the meaning and range of equivalents of the claims are intended to be included therein. Any reference sign in a claim should not be construed as limiting the claim to which it relates.
[0076] In addition, it should be understood that although this specification is described in terms of implementation methods, not every implementation method contains only one independent technical solution. This narrative method of the specification is only for the sake of clarity. Those skilled in the art should regard the specification as a whole. The technical solutions in each embodiment can also be appropriately combined to form other implementation methods that can be understood by those skilled in the art.
Claims
1. A method for extracting and converting information based on ARXML files, characterized in that: The conversion system used includes a parser module, a configuration file module and an action dependency parsing module; the method includes the following steps: Step S1: defining XPath expressions related to information extraction in the configuration file through the configuration file module, so as to facilitate use in subsequent information extraction; Step S2: The parser module extracts required information from the ARXML file using the XPath expression in the configuration file stored by the configuration file module, and converts the extracted information into element information according to the parsing rules. The element information is used as the main entry information to generate a main entry information JSON file. Step S3, determining whether there is unknown path reference information in the element information, if yes, proceeding to step S4; if no, ending; Step S4, recursively parse the unknown path reference information in the element information through the action dependency parsing module, convert the path reference information into XPath expressions, and extract information based on these expressions, and then convert the extracted information into element information according to the parsing rules. The element information is used as the path reference information to generate a path reference information JSON file.
2. The method for extracting and converting information based on ARXML files according to claim 1, characterized in that: In step S2, the parser module extracts the required information from the ARXML file using the XPath expression in the configuration file stored by the configuration file module, and converts the extracted information into element information according to the parsing rules, specifically including: Read ARXML file: load ARXML file from the specified input path; Traverse node tags: Use the XPath expression defined in the configuration file to traverse all nodes in the ARXML file and find the target node; Recursively parse the target node: For a target node that contains child nodes, traverse and extract information of all child nodes layer by layer, store the extracted information in the corresponding data structure according to the parsing rules, retain the hierarchical relationship of the data, and output the element information in JSON format.
3. The method for extracting and converting information based on ARXML files according to claim 2, characterized in that: The recursive parsing target node specifically includes the following steps: Step S21, check child nodes: determine whether each node contains child nodes, if yes, go to step S22, <short-name> Tag judgment; if not, go to step S24 and perform regular analysis on the current node; Step S22, perform <short-name>Tag judgment: Check whether the current node contains <short-name>Label, if yes, the current node exists <short-name>If the label is set, the current node is specially processed 1; if not, the current node does not exist <short-name> tag, then go to step S23 to check for duplicate tags; Step S23, checking duplicate labels: determining whether the current node contains duplicate labels. If so, that is, duplicate labels exist, then special processing 2 is performed on the current node; if not, that is, duplicate labels do not exist, then go to step S24 and perform regular parsing on the current node. Step S24, performing conventional parsing: For nodes that do not meet the special processing conditions, perform conventional parsing, that is, convert the node information into a dictionary form, maintaining the hierarchical relationship of the data; Step S25, returning node data: after completing the parsing of the current node and the corresponding child nodes, returning the parsed node data, and outputting the data in JSON format.
4. The method for extracting and converting information based on ARXML files according to claim 3, characterized in that: In step S24, performing conventional parsing on the current node specifically includes: 1) Read and parse the XML structure in the ARXML file; 2) Use the tag name in the XML structure as the key in the dictionary and the text value in the tag as the value in the corresponding dictionary; 3) If the tag in the XML structure contains subtags, convert the subtags into a nested dictionary structure to maintain the original hierarchical relationship.
5. The method for extracting and converting information based on ARXML files according to claim 3, characterized in that: In step S22, the current node is subjected to special processing 1, specifically: when there is <short-name>When labeling, <short-name> The text value of the label is used as the root key of the processed node, and a child node is added to the processed node, and the value of the child node is the root label of the processed node.< / short-name> 6. The method for extracting and converting information based on ARXML files according to claim 3, characterized in that: In step S23, the special processing 2 is performed on the current node, specifically: when the same level in the ARXML file contains repeated tags, and the tags do not contain <short-name> When repeating a tag, add the corresponding character mark after the repeated tag as the corresponding dictionary key.< / short-name>
Citation Information
Patent Citations
Data conversion method and device, equipment and medium
CN117573927A
Simulation test method, system and terminal for vehicle communication
CN118473979A