Method and related device for loading xml diagnostic data based on on-demand parsing of odx standard
By employing an on-demand parsing method in the XML diagnostic data of the ODX standard, optional elements are parsed only on the first access, thus solving the performance bottleneck caused by full pre-parsing, achieving fast parsing and low memory consumption, and improving resource utilization and user experience.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- LAUNCH TECH CO LTD
- Filing Date
- 2026-04-17
- Publication Date
- 2026-07-21
Smart Images

Figure CN122432386A_ABST
Abstract
Description
Technical Field
[0001] This application belongs to the field of automotive diagnostic technology, and in particular relates to a method, system, automotive diagnostic equipment, and computer program product for loading XML diagnostic data based on the on-demand parsing ODX standard. Background Technology
[0002] In automotive diagnostic XML (Extensible Markup Language) data conforming to the ODX (Open Diagnostic Data Exchange) standard, the data model contains a large number of elements defined as "optional" to allow for flexibility in data description. Traditional XML parsing schemes, including streaming parsing with full preloading strategies, typically parse and construct the memory objects corresponding to all elements unconditionally during the initialization phase, regardless of whether subsequent diagnostic operations actually need to access this data.
[0003] Statistical analysis of existing technologies shows that in large-scale ODX file sets, most optional elements have extremely low access rates (e.g., less than 10%) in actual diagnostic processes. This "one-size-fits-all" parsing approach leads to significant resource waste, specifically manifested in excessively long parsing startup times, high memory consumption, and low utilization of computing resources. This particularly restricts the performance and user experience of embedded diagnostic devices and mobile applications—terminals sensitive to startup speed and memory usage. Therefore, there is a need to optimize existing technologies by performing on-demand parsing of ODX diagnostic data. Summary of the Invention
[0004] In view of this, embodiments of this application provide a method, system, automotive diagnostic equipment, and computer program product for loading XML diagnostic data based on on-demand parsing of the ODX standard, in order to solve the technical problems of slow parsing speed, high memory consumption, long startup delay, and low resource utilization caused by full pre-parsing of optional elements in ODX-compliant automotive diagnostic XML documents.
[0005] In a first aspect, this application provides a method for loading XML diagnostic data based on on-demand parsing of the ODX standard, the method comprising: Step S1: Create a data object in memory corresponding to at least one optional element in the target XML document, and set an initialization flag for each data object. The initial state of the initialization flag indicates that the data object has not loaded its corresponding XML data. The target XML document is an XML document that conforms to the ODX standard. Step S2: Start the streaming parser to parse the target XML document; when the streaming parser recognizes the start tag of the optional element, pause the parsing of the optional element subtree, record the position information of the optional element in the target XML document, and store the association relationship between the position information and the corresponding data object; Step S3: When the first data access request for a target data object is received, check its initialization flag; if the initialization flag indicates that the target data object has not loaded data, then obtain the target location information corresponding to the target data object according to the association relationship; Step S4: Based on the target location information, locate the target optional element in the target XML document, parse the subtree of the target optional element, fill the parsed data into the target data object, and update the status of the target initialization flag corresponding to the target data object to indicate that the data has been loaded; Step S5: Return the target data object.
[0006] The technical advantage of this application is that it solves the problems of slow parsing speed, high memory consumption, long startup delay, and low resource utilization caused by the full pre-parsing of all optional elements (0..1 cardinality) in the XML document in existing technologies. By adopting an on-demand mechanism of "parsing only on the first access", unnecessary parsing overhead is avoided.
[0007] In one implementation, step S2, recording the position information of the optional element in the target XML document, includes: Record the byte offset of the start tag in the target XML document file; Accordingly, step S4, locating the target optional element in the target XML document based on the target location information, includes: The read pointer of the streaming parser is positioned at the target byte offset to locate the target optional element in the target XML document.
[0008] The technical advantage of this application embodiment is that it provides an efficient and accurate delayed parsing implementation method, which can achieve fast file positioning through byte offset, thereby parsing only the required subtree and saving the time of skipping and subsequent search.
[0009] In one implementation, after recording the position information of the optional element in the target XML document in step S2, the method further includes: The streaming parser is controlled to skip all content from the start tag to the corresponding end tag and continue parsing subsequent elements.
[0010] The technical effect of this application embodiment is that, when parsing the document for the first time, by physically skipping the entire subtree of optional elements, any processing of their content (such as creating temporary objects, triggering events, etc.) is directly avoided, thereby reducing the initial parsing time and reducing the initial memory usage.
[0011] In one implementation, prior to step S1, the method further includes: Based on predefined rules or the schema information of the target XML document, determine each optional element in the target XML document.
[0012] In one implementation, in step S3, the initial data access request is triggered by calling the access interface of the container object to which the target data object belongs; The access interface is configured to automatically perform the check initialization flag operation before performing the return data operation.
[0013] The technical effect of this application embodiment is that it can transparently implement the "on-demand triggering" mechanism for upper-layer applications, ensuring that user code can enjoy lazy loading optimization without modification, thereby improving development friendliness and compatibility.
[0014] In one implementation, the initialization flag is a Boolean variable; the updating of the flag state in step S4 and the checking of the flag state in step S3 are both completed through atomic operations.
[0015] The technical effect of this application embodiment is that it ensures the correctness and reliability of the lazy loading mechanism in a concurrent environment, prevents the same element from being parsed multiple times or the parsing process from encountering anomalies, and enables the method to be stably applied to servers or diagnostic platforms in high-concurrency scenarios.
[0016] Secondly, the present invention also provides an architecture system based on on-demand parsing of XML diagnostic data according to the ODX standard, the architecture system comprising: A state flag layer is configured to create data objects in memory corresponding to optional elements in the target XML document, and maintain an initialization flag for each data object to identify whether it has loaded data; the initialization flag is set to an unloaded state when the data object is created. The delayed parsing trigger layer is configured to, when the target XML document is parsed for the first time using a streaming parser, record the position information of the optional element in the target XML document when the start tag of the optional element is identified and skip the parsing of the optional element subtree. At the same time, a position information mapping table is constructed and maintained to store the association between the identifier of the optional element and the corresponding position information. An access interception layer is configured to intercept access requests to the data object and determine whether to trigger on-demand parsing based on the state of the initialization flag. When the initialization flag is in an unloaded state, the access interception layer obtains the corresponding location information from the location information mapping table, locates the corresponding position in the target XML document based on the location information, performs parsing on the subtree of the optional element, fills the data obtained from the parsing into the data object, updates the initialization flag to the loaded state, and then returns the data object.
[0017] In one example, the access interception layer further includes: The data access interface is configured to automatically trigger a check of the initialization flag when a request for access to the data object is received, and to return the data object after performing on-demand parsing if the necessary conditions are met; The status query interface is configured to check the status of the initialization flag bit without triggering on-demand parsing when a request is received to query only the existence of optional elements.
[0018] Thirdly, the present invention also provides an automotive diagnostic device, comprising: a processor and a memory, the processor being connected to the memory, the memory being used to store a computer program, and the processor being used to execute the computer program stored in the memory, so that the automotive diagnostic device performs the method described in the first aspect above.
[0019] Fourthly, the present invention also provides a computer program product storing a computer program that is executed by a processor to implement the method described in the first aspect above.
[0020] It is understood that the beneficial effects of the second to fourth aspects mentioned above can be found in the relevant descriptions in the first aspect mentioned above, and will not be repeated here. Attached Figure Description
[0021] To more clearly illustrate the technical solutions in the embodiments of this application, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0022] Figure 1 This is a system block diagram of an architecture based on on-demand parsing of XML diagnostic data according to the ODX standard, provided in an embodiment of this application. Figure 2 This is a schematic diagram of a method for loading XML diagnostic data based on on-demand parsing of the ODX standard, provided in an embodiment of this application. Figure 3 This is a structural block diagram of the automotive diagnostic equipment provided in the embodiments of this application. Detailed Implementation
[0023] In the following description, specific details such as particular system architectures and techniques are set forth for illustrative purposes and not for limitation, in order to provide a thorough understanding of the embodiments of this application. However, those skilled in the art will understand that this application may also be implemented in other embodiments without these specific details. In other instances, detailed descriptions of well-known systems, apparatuses, circuits, and methods have been omitted so as not to obscure the description of this application with unnecessary detail.
[0024] It should be understood that, when used in this application specification and the appended claims, the term "comprising" indicates the presence of the described features, integrals, steps, operations, elements and / or components, but does not exclude the presence or addition of one or more other features, integrals, steps, operations, elements, components and / or a collection thereof.
[0025] It should also be understood that the term “and / or” as used in this application specification and the appended claims means any combination of one or more of the associated listed items and all possible combinations, and includes such combinations.
[0026] As used in this application specification and the appended claims, the term "if" may be interpreted, depending on the context, as "when," "once," "in response to determination," or "in response to detection." Similarly, the phrase "if determined" or "if detected [the described condition or event]" may be interpreted, depending on the context, as meaning "once determined," "in response to determination," "once detected [the described condition or event]," or "in response to detection [the described condition or event]."
[0027] Furthermore, in the description of this application and the appended claims, the terms "first," "second," "third," etc., are used only to distinguish descriptions and should not be construed as indicating or implying relative importance.
[0028] References to "one embodiment" or "some embodiments" as described in this specification mean that one or more embodiments of this application include a specific feature, structure, or characteristic described in connection with that embodiment. Therefore, the phrases "in one embodiment," "in some embodiments," "in other embodiments," "in still other embodiments," etc., appearing in different parts of this specification do not necessarily refer to the same embodiment, but rather mean "one or more, but not all, embodiments," unless otherwise specifically emphasized. The terms "comprising," "including," "having," and variations thereof mean "including but not limited to," unless otherwise specifically emphasized.
[0029] Understandably, as automotive electronic architectures become increasingly complex, XML diagnostic files based on the ODX standard have become an indispensable data carrier for on-board diagnostic systems. The ODX standard (ISO 22901) provides a structured model for accurately describing diagnostic services, communication parameters, and vehicle electronic control unit (ECU) data. However, while pursuing completeness and flexibility, this standard's data model contains a large number of elements defined as "optional" (e.g., elements with cardinality constraints of minOccurs="0" and maxOccurs="1" in XML Schema), such as management data (e.g., ADMIN-DATA), target audience (e.g., AUDIENCE), and functional categories (e.g., FUNCT-CLASSS).
[0030] In practical applications, although the overall probability of these optional elements appearing is not high (e.g., about 24.7% of files in a typical dataset contain them), their definitions are scattered across various levels of the data model, resulting in a still large number of optional elements (up to several thousand) in a single ODX file collection (e.g., a PDX package containing 130 files). Current mainstream XML parsing technologies, especially those using DOM (Document Object Model) or SAX (Simple API for XML) streaming solutions that perform full pre-parsing, typically employ an "immediate loading" strategy. That is, in the initial parsing phase, regardless of whether subsequent business logic requires access, the parser unconditionally traverses and parses every element node in the document, creating complete object instances and populating data for all optional elements. This "one-size-fits-all" full-data parsing approach reveals significant performance bottlenecks when dealing with large-scale, complex XML documents like ODX. It results in severe resource waste, as statistics show that approximately 70% of optional elements are accessed less than 10% of the time in actual diagnostic sessions. This leads to excessively long application startup times (significantly increased initial screen response latency), excessive memory consumption during parsing (pre-created, unaccessed objects persist), and inefficient use of CPU resources. These problems are particularly problematic in embedded automotive diagnostic devices or mobile diagnostic terminals, where startup speed and memory resources are critical, severely impacting user experience and system performance. Therefore, a highly efficient parsing method that can intelligently identify and load optional portions of ODX data according to actual needs is urgently needed.
[0031] To address the shortcomings of the existing technology, this application provides a method, system, automotive diagnostic equipment, and computer program product for loading XML diagnostic data based on the on-demand parsing of the ODX standard. Specifically, this application illustrates the technical solution of the present invention through specific embodiments.
[0032] Example 1 First, such as Figure 1 As shown, the method embodiment of the present invention relies on a three-tier architecture system comprising a state marking layer 01, a delayed parsing triggering layer 02, and an access interception layer 03. Specifically, this architecture is embedded in an XML diagnostic data loading system, which is typically implemented by a software program running on a computer, embedded diagnostic device, or server.
[0033] Among them, the status flag layer 01 is configured to create data objects in memory corresponding to optional elements in the target XML document, and maintain an initialization flag bit for each data object to identify whether it has loaded data; the initialization flag bit is set to an unloaded state when the data object is created; It is understood that the target XML document is a document that conforms to the ODX diagnostic data exchange standard, and the optional elements include at least one of ADMIN-DATA, AUDIENCE, and FUNCT-CLASSS.
[0034] As a preferred example, the initialization flag maintained in the state flag layer 01 is a Boolean variable, and is read and written through atomic operations to ensure the consistency of the state when accessing the data object in a multi-threaded environment.
[0035] The delayed parsing trigger layer 02 is configured to, when the target XML document is parsed for the first time using a streaming parser, record the position information of the optional element in the target XML document when the start tag of the optional element is identified and skip the parsing of the optional element subtree. At the same time, a position information mapping table is constructed and maintained to store the association between the identifier of the optional element and the corresponding position information. For example, the location information recorded in the delayed parsing triggering layer 02 includes at least: the file byte offset of the optional element in the target XML document; the access interception layer locates the element based on the location information by positioning the read pointer of the streaming parser at the file byte offset.
[0036] Access interception layer 03 is configured to intercept access requests to the data object and determine whether to trigger on-demand parsing based on the state of the initialization flag. When the initialization flag is in an unloaded state, the access interception layer obtains the corresponding location information from the location information mapping table, locates the corresponding position in the target XML document based on the location information, performs parsing on the subtree of the optional element, fills the data obtained from the parsing into the data object, updates the initialization flag to the loaded state, and then returns the data object.
[0037] For example, the access interception layer 03 in this embodiment may further include: The data access interface is configured to automatically trigger a check of the initialization flag when a request for access to the data object is received, and to return the data object after performing on-demand parsing if the necessary conditions are met; The status query interface is configured to check the status of the initialization flag bit without triggering on-demand parsing when a request is received to query only the existence of optional elements.
[0038] The technical effect of the architecture system in this application is that, from the system architecture level, it solves the problem of architectural resource waste caused by the full pre-parsing of optional elements in the existing XML parsing system, and provides a modular, reusable on-demand parsing system architecture.
[0039] Through the static functional division and collaboration of the three-tier architecture, the system-level encapsulation of the XML diagnostic data loading method based on the on-demand parsing ODX standard in Embodiment 2 is realized. This enables the on-demand parsing mechanism to be integrated into the existing diagnostic data loading platform as an independent system module, reducing system coupling and improving the maintainability and scalability of the architecture.
[0040] Example 2 like Figure 2 As shown, based on the architecture system of Embodiment 1 above, this application provides a method for loading XML diagnostic data based on on-demand parsing of the ODX standard. This method is applied to automotive diagnostic equipment, and the method includes the following steps S1 to S4: Step S1: Create a data object in memory corresponding to at least one optional element in the target XML document, and set an initialization flag for each data object. The initial state of the initialization flag indicates that the data object has not loaded its corresponding XML data. The target XML document is an XML diagnostic data file conforming to the ODX standard. It should be noted that after the operating system of the automotive diagnostic equipment in this embodiment of the application starts, it can first determine which elements in the target XML document are optional elements with constraints minOccurs="0" and maxOccurs="1" based on the pre-loaded ODX standard schema or configuration file. For example, the system will identify elements such as ADMIN-DATA, AUDIENCE, and FUNCT-CLASSS as targets for which a lazy loading strategy needs to be applied.
[0041] As an example, before parsing an XML document or when parsing a container element, the system creates a corresponding object in memory. <admin-data>The element's "management data object". At this point, only the constructor of the "management data object" is called, setting its internal state flag (initialization flag) to "false" ("uninitialized"), and its data fields remain empty. This object occupies very little memory; for example, it occupies only 8 bytes of memory.
[0042] Step S2: Start the streaming parser to parse the target XML document; when the streaming parser recognizes the start tag of the optional element, pause the parsing of the optional element subtree, record the position information of the optional element in the target XML document, and store the association relationship between the position information and the corresponding data object; As an example, the streaming parser in this application embodiment can be a SAX parser, and the target XML document is an ODX file; For example, the system starts the configured SAX parser and begins streaming the parsing of the target XML document that conforms to the ODX standard, including the following sub-steps: Sub-step 21: The streaming parser sequentially reads the target XML document and triggers relevant events.
[0043] Sub-step 22: When encountering a selectable element (e.g., the currently selectable element is...) <admin-data>When the start tag of an element is reached, the delayed processing logic is triggered, including: a. Record position (claim 2): The processor immediately obtains the file byte offset of the current parser in the input stream (e.g., file byte offset = 1024), and constructs a position information object by combining it with information such as element path.
[0044] b. Establish association: Store this location information object in the delayed resolution location mapping table with a key (such as "ADMIN-DATA").
[0045] c. Skip Subtree: Subsequently, the processor calls the subtree skip method. It jumps directly to the subtree by counting the depth of the start and end labels. The closing tag does not trigger any parsing events for its child elements.
[0046] Sub-step 23: The parser continues processing. <admin-data>The necessary elements that follow.
[0047] Step S3: When the first data access request for a target data object is received, check its initialization flag; if the initialization flag indicates that the target data object has not loaded data, then obtain the target location information corresponding to the target data object according to the association relationship; For example, the initial data access request is triggered by calling the access interface of the container object to which the target data object belongs; for example, the access interface could be a `getManagementData()` method; correspondingly, after the application starts up, the user performs an operation that requires viewing management data; the business code calls the `getManagementData()` method of the container object, including the following sub-steps: Sub-step 31: Inside this method, the associated "management data object" will first be obtained; Sub-step 32: Immediately afterwards, the method calls the `check and initialize()` method inside the object; Sub-step 33: In this check method, the system first checks the status flag, which is currently "false" (uninitialized).
[0048] Sub-step 34: Since the status flag is "false", the system determines that this is the first data access request and needs to trigger on-demand parsing. Therefore, it queries the delayed parsing location mapping table established in step S2 based on the element name (such as "ADMIN-DATA") to obtain the corresponding location information.
[0049] Step S4: Based on the target location information, locate the target optional element in the target XML document, parse the subtree of the target optional element, fill the parsed data into the target data object, and update the status of the target initialization flag corresponding to the target data object to indicate that the data has been loaded; In its specific implementation, step S4 may include the following technical aspects: Location phase: The system uses the file offset in the location information (e.g., file byte offset = 1024) to control the file read pointer or reconfigure the input source of the SAX parser, so that it accurately locates the original ODX file. <admin-data>Starting position; Subtree parsing stage: At this point, the system starts a scoped parsing session that can use the same SAX parser instance, but restricts its parsing scope to the subtree. <admin-data> Start to< / admin-data> Within this subtree at the end; Data population step: Specifically for the event handlers registered on demand in this embodiment, it receives the parsed events and populates the parsed data into the corresponding data fields of the previously created "management data object"; Update status: After the data is populated, the system can set the status flag of the "Manage data object" to "true" ("initialized"); this operation ensures thread safety through atomic comparison operations.
[0050] Step S5: Return the target data object.
[0051] For example, after the `check and initialize()` method completes its execution, control returns to the `get management data()` method. At this point, the "management data object" is an initialized object containing valid data. The `get management data()` method then executes the "return the target data object" operation in step S5, that is, returns this "management data object" to the upper-level business code. After obtaining the object, the business code can call its methods (such as `get language()`) to directly access the loaded data without triggering the parsing process again.
[0052] For subsequent accesses: When the user or other operations call the "Get Management Data()" function again, the process will also execute the initialization check in step S3. At this time, since the status flag is already "true", the check method will return immediately and will not execute any operation in step S4, thus achieving duplicate data access without additional overhead. At this time, step S5 still executes the "Return the target data object" operation, but the returned object is the already initialized object.
[0053] The technical advantages of this application's embodiments are as follows: It solves the problems of slow parsing speed, high memory consumption, long startup latency, and low resource utilization caused by the existing technology's full pre-parsing of all optional elements (0..1 cardinality) in an XML document. By using an on-demand mechanism of "parsing only on first access," unnecessary parsing overhead is avoided, resulting in effectively reduced parsing time (e.g., a 37% reduction), effectively reduced peak memory usage (e.g., an 18% reduction), significantly shortened first-screen response time, and significantly improved resource utilization (e.g., from 25% to 95%).
[0054] Example 3 Furthermore, this application also proposes an automotive diagnostic device. Figure 3 This is a schematic diagram of the structure of an automotive diagnostic device provided in one embodiment of this application. Figure 3 As shown, the automotive diagnostic device 7 of this embodiment includes: at least one processor 70 ( Figure 3 (Only one is shown in the diagram) a processor, a memory 71, and a computer program 72 stored in the memory 71 and executable on the at least one processor 70, wherein the processor 70 executes the computer program 72 to implement the steps in any of the above-described diagnostic device authentication method embodiments.
[0055] The vehicle diagnostic device 7 can essentially be a computer device, such as a tablet computer, laptop, or PDA. This vehicle diagnostic device may include, but is not limited to, a processor 70 and a memory 71. Those skilled in the art will understand that... Figure 3 This is merely an example of the vehicle diagnostic device 7 and does not constitute a limitation on the vehicle diagnostic device 7. It may include more or fewer components than shown, or combine certain components, or different components, such as input / output devices, network access devices, etc.
[0056] The processor 70 can be a Central Processing Unit (CPU), but it can also be other general-purpose processors, digital signal processors (DSPs), application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. The general-purpose processor can be a microprocessor or any conventional processor.
[0057] In some embodiments, the memory 71 may be an internal storage unit of the automotive diagnostic device 7, such as a hard disk or memory of the automotive diagnostic device 7. In other embodiments, the memory 71 may be an external storage device of the automotive diagnostic device 7, such as a plug-in hard disk, SmartMedia Card (SMC), Secure Digital (SD) card, or Flash Card equipped on the automotive diagnostic device 7. Furthermore, the memory 71 may include both internal and external storage units of the automotive diagnostic device 7. The memory 71 is used to store the operating system, applications, bootloader, data, and other programs, such as the program code of the computer program. The memory 71 can also be used to temporarily store data that has been output or will be output.
[0058] It should be noted that the information interaction and execution process between the above-mentioned devices / units are based on the same concept as the method embodiments of this application. For details on their specific functions and technical effects, please refer to the method embodiments section, and they will not be repeated here.
[0059] Those skilled in the art will clearly understand that, for the sake of convenience and brevity, the above-described division of functional units and modules is merely an example. In practical applications, the above functions can be assigned to different functional units and modules as needed, that is, the internal structure of the device can be divided into different functional units or modules to complete all or part of the functions described above. The functional units and modules in the embodiments can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software functional unit. Furthermore, the specific names of the functional units and modules are only for easy differentiation and are not intended to limit the scope of protection of this application. The specific working process of the units and modules in the above system can be referred to the corresponding process in the foregoing method embodiments, and will not be repeated here.
[0060] This application also provides a computer-readable storage medium storing a computer program that, when executed by a processor, implements the steps described in the various method embodiments above.
[0061] This application provides a computer program product that, when run on an automotive diagnostic device, enables the automotive diagnostic device to perform the steps described in the above-described method embodiments.
[0062] If the integrated unit is implemented as a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, all or part of the processes in the methods of the above embodiments of this application can be implemented by a computer program instructing related hardware. The computer program can be stored in a computer-readable storage medium, and when executed by a processor, it can implement the steps of the various method embodiments described above. The computer program includes computer program code, which can be in the form of source code, object code, executable files, or certain intermediate forms. The computer-readable medium can include at least: any entity or device capable of carrying computer program code to a device / terminal equipment, a recording medium, a computer memory, a read-only memory (ROM), a random access memory (RAM), an electrical carrier signal, a telecommunication signal, and a software distribution medium. Examples include USB flash drives, portable hard drives, magnetic disks, or optical disks. In some jurisdictions, according to legislation and patent practice, computer-readable media cannot be electrical carrier signals or telecommunication signals.
[0063] In the above embodiments, the descriptions of each embodiment have different focuses. For parts that are not described in detail or recorded in a certain embodiment, please refer to the relevant descriptions of other embodiments.
[0064] Those skilled in the art will recognize that the units and algorithm steps of the various examples described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of this application.
[0065] In the embodiments provided in this application, it should be understood that the disclosed computer devices and methods can be implemented in other ways. For example, the computer device / diagnostic device authentication system embodiments described above are merely illustrative. For instance, the division of modules or units is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the coupling or direct coupling or communication connection shown or discussed may be an indirect coupling or communication connection through some interfaces, devices, or units, and may be electrical, mechanical, or other forms.
[0066] The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.
[0067] The above-described embodiments are only used to illustrate the technical solutions of this application, and are not intended to limit them. Although this application has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features. Such modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of this application, and should all be included within the protection scope of this application.
Claims
1. A method for loading XML diagnostic data based on on-demand parsing of the ODX standard, characterized in that, The method includes: Step S1: Create a data object in memory corresponding to at least one optional element in the target XML document, and set an initialization flag for each data object. The initial state of the initialization flag indicates that the data object has not loaded its corresponding XML data. The target XML document is an XML document that conforms to the ODX standard. Step S2: Start the streaming parser to parse the target XML document; when the streaming parser recognizes the start tag of the optional element, pause the parsing of the optional element subtree, record the position information of the optional element in the target XML document, and store the association relationship between the position information and the corresponding data object; Step S3: When the first data access request for a target data object is received, check its initialization flag; if the initialization flag indicates that the target data object has not loaded data, then obtain the target location information corresponding to the target data object according to the association relationship; Step S4: Based on the target location information, locate the target optional element in the target XML document, parse the subtree of the target optional element, fill the parsed data into the target data object, and update the status of the target initialization flag corresponding to the target data object to indicate that the data has been loaded; Step S5: Return the target data object.
2. The method according to claim 1, characterized in that, In step S2, recording the position information of the optional element in the target XML document includes: Record the byte offset of the start tag in the target XML document; Accordingly, step S4, locating the target optional element in the target XML document based on the target location information, includes: The read pointer of the streaming parser is positioned at the target byte offset to locate the target optional element in the target XML document.
3. The method according to claim 2, characterized in that, In step S2, after recording the position information of the optional element in the target XML document, the method further includes: The streaming parser is controlled to skip all content from the start tag to the corresponding end tag and continue parsing subsequent elements.
4. The method according to claim 1, characterized in that, Prior to step S1, the method further includes: Based on predefined rules or the schema information of the target XML document, determine each optional element in the target XML document.
5. The method according to claim 1, characterized in that, In step S3, the initial data access request is triggered by calling the access interface of the container object to which the target data object belongs; The access interface is configured to automatically perform the check initialization flag operation before performing the return data operation.
6. The method according to claim 1, characterized in that, The initialization flag is a Boolean variable; updating the flag state in step S4 and checking the flag state in step S3 are both completed through atomic operations.
7. An architecture system based on on-demand parsing of XML diagnostic data according to the ODX standard, characterized in that, The architecture system includes: A state flag layer is configured to create data objects in memory corresponding to optional elements in the target XML document, and maintain an initialization flag for each data object to identify whether it has loaded data; the initialization flag is set to an unloaded state when the data object is created. The delayed parsing trigger layer is configured to, when the target XML document is parsed for the first time using a streaming parser, record the position information of the optional element in the target XML document when the start tag of the optional element is identified and skip the parsing of the optional element subtree. At the same time, a position information mapping table is constructed and maintained to store the association between the identifier of the optional element and the corresponding position information. An access interception layer is configured to intercept access requests to the data object and determine whether to trigger on-demand parsing based on the state of the initialization flag. When the initialization flag is in an unloaded state, the access interception layer obtains the corresponding location information from the location information mapping table, locates the corresponding position in the target XML document based on the location information, performs parsing on the subtree of the optional element, fills the data obtained from the parsing into the data object, updates the initialization flag to the loaded state, and then returns the data object.
8. The architecture system as described in claim 7, characterized in that, The access interception layer further includes: The data access interface is configured to automatically trigger a check of the initialization flag when a request for access to the data object is received, and to return the data object after performing on-demand parsing if the necessary conditions are met; The status query interface is configured to check the status of the initialization flag bit without triggering on-demand parsing when a request is received to query only the existence of optional elements.
9. An automotive diagnostic device, characterized in that, include: A processor and a memory, the processor being connected to the memory for storing a computer program, the processor being configured to execute the computer program stored in the memory to cause the automotive diagnostic device to perform the method as described in any one of claims 1-7.
10. A computer program product, characterized in that, The computer program product stores a computer program that is executed by a processor to implement the method as described in any one of claims 1-7.