CN112181539B - File processing method, device, equipment and medium - Google Patents
File processing method, device, equipment and medium Download PDFInfo
- Publication number
- CN112181539B CN112181539B CN202011035738.3A CN202011035738A CN112181539B CN 112181539 B CN112181539 B CN 112181539B CN 202011035738 A CN202011035738 A CN 202011035738A CN 112181539 B CN112181539 B CN 112181539B
- Authority
- CN
- China
- Prior art keywords
- node
- program
- signature
- association information
- selecting
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Active
Links
- 238000003672 processing method Methods 0.000 title abstract description 14
- 238000000034 method Methods 0.000 claims description 191
- 230000004044 response Effects 0.000 claims description 39
- 238000012545 processing Methods 0.000 claims description 26
- 238000004590 computer program Methods 0.000 claims description 23
- 230000006870 function Effects 0.000 claims description 21
- 238000004458 analytical method Methods 0.000 claims description 4
- 230000000875 corresponding effect Effects 0.000 claims 11
- 230000002596 correlated effect Effects 0.000 claims 1
- 230000008569 process Effects 0.000 description 12
- 230000011664 signaling Effects 0.000 description 12
- 238000010586 diagram Methods 0.000 description 6
- 230000009286 beneficial effect Effects 0.000 description 4
- 230000008878 coupling Effects 0.000 description 3
- 238000010168 coupling process Methods 0.000 description 3
- 238000005859 coupling reaction Methods 0.000 description 3
- 238000001514 detection method Methods 0.000 description 3
- 238000004891 communication Methods 0.000 description 2
- 238000012360 testing method Methods 0.000 description 2
- 238000003491 array Methods 0.000 description 1
- 238000013499 data model Methods 0.000 description 1
- 230000003247 decreasing effect Effects 0.000 description 1
- 238000013461 design Methods 0.000 description 1
- 230000000694 effects Effects 0.000 description 1
- 238000005516 engineering process Methods 0.000 description 1
- 230000006872 improvement Effects 0.000 description 1
- 230000003993 interaction Effects 0.000 description 1
- 238000012986 modification Methods 0.000 description 1
- 230000004048 modification Effects 0.000 description 1
- 230000003287 optical effect Effects 0.000 description 1
- 238000006467 substitution reaction Methods 0.000 description 1
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F9/00—Arrangements for program control, e.g. control units
- G06F9/06—Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
- G06F9/44—Arrangements for executing specific programs
- G06F9/448—Execution paradigms, e.g. implementations of programming paradigms
- G06F9/4482—Procedural
Landscapes
- Engineering & Computer Science (AREA)
- Software Systems (AREA)
- Theoretical Computer Science (AREA)
- Physics & Mathematics (AREA)
- General Engineering & Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Information Retrieval, Db Structures And Fs Structures Therefor (AREA)
- Stored Programmes (AREA)
Abstract
The application is applicable to the technical field of computers, and provides a file processing method, which comprises the following steps: analyzing the file to be processed to obtain nodes of the file to be processed; and responding to the node as a signature node, generating codes for realizing the step of selecting the program node according to a pre-constructed association information set, and writing the generated codes into the signature node to realize the execution of the program of the selected program node when the signature node is called, wherein association information in the association information set is used for describing the association relation between the signature node and the program node. The present application can realize automatic execution of the program of the selected program node when the signature node is called by writing the code for executing the step of selecting the program node into the signature node. When the signature node is called, a program of which program node is specifically executed is not required to be additionally set, so that the signature node can be conveniently called, and the calling efficiency of the signature node is improved.
Description
Technical Field
The present application relates to the field of computer technologies, and in particular, to a method, an apparatus, a device, and a medium for processing a file.
Background
The open test sequence exchange (Open Test sequence eXchange, OTX) language is a high-level programming language applied in the field of automotive diagnostics, the complete syntactic semantics and program structure definition of which are mainly given by the ISO13209 series of standards. Wherein, the ISO13209-1 standard mainly comprises the general theory and use cases of OTX; the ISO13209-2 standard mainly includes the specification and requirements of the core data model of OTX; the ISO13209-3 standard mainly includes standard extensions and requirements for OTX.
In OTX, a Signature node (Signature) generally functions to declare an interface, including declaring the name of the interface, declaring input and output parameters of the interface, and so on. The program node (process) may be an implementation of Signature or may be a separate function. Signature and Procedure differ in: signature has no implementation, procedure has an implementation, i.e., procedure can execute a flow. A Signature may generally have a variety of implementations, i.e., a Signature may have a plurality of corresponding procedures.
In the related art, if a signaling needs to be called, a Procedure corresponding to the signaling needs to be configured to implement calling of the signaling. The calling efficiency of the calling mode is not high. Therefore, in the related art, there is a need to improve call efficiency to Signature.
Disclosure of Invention
The embodiment of the application provides a file processing method, a device, equipment and a medium.
In a first aspect, an embodiment of the present application provides a method for processing a file, where the method includes:
analyzing the file to be processed to obtain nodes of the file to be processed;
and responding to the node as the Signature, generating codes for realizing the step of selecting the program node according to a pre-constructed association information set, and writing the generated codes into the Signature so as to realize the program for executing the selected Procedure when the Signature is called, wherein the association information in the association information set is used for describing the association relation between the Signature and the Procedure.
Further, the step of selecting the program node includes:
selecting association information from the association information set, and executing a validity judging step: selecting a corresponding Procedure in response to determining that the validity of the Procedure corresponding to the selected association information is true;
and in response to determining that the validity of the Procedure corresponding to the selected associated information is false, selecting unselected associated information from the associated information set, and continuing to execute the validity judging step.
Further, the validity of the Procedure is positively related to the value of the preset parameter in the Procedure; and
In response to determining that the validity of the corresponding Procedure of the selected association information is true, selecting the corresponding Procedure includes:
and in response to the value of the preset parameter being larger than the preset value, determining the validity of the Procedure corresponding to the selected associated information as true, and selecting the corresponding Procedure.
Further, in response to determining that the validity of the Procedure corresponding to the selected association information is false, selecting unselected association information from the association information set includes:
and responding to the fact that the value of the preset parameter is smaller than or equal to a preset value, determining that the validity of the Procedure corresponding to the selected associated information is false, and selecting the unselected associated information from the associated information set.
Further, the association information in the association information set includes a name of the Signature and attribute information associated with the name of the Signature, and the attribute information includes a name of the Procedure, a name of the Signature, and a storage address of the Procedure.
Further, the pre-constructed association information set is obtained by:
traversing nodes of the file to be processed when the file to be processed is analyzed, and executing the following storage operations when the current node is accessed: responding to the current node as a Procedure, storing the current node and acquiring attribute information of the current node; and in response to the acquired attribute information including the name of the Signature, storing the included name of the Signature and the attribute information of the current node in association with each other in an association information set.
Further, the storing operation further includes: and storing the current node in response to the current node being a node other than the Procedure.
In a second aspect, an embodiment of the present application provides a file processing apparatus, including:
the file analysis unit is used for analyzing the file to be processed to obtain nodes of the file to be processed;
and the node processing unit is used for responding to the node as the Signature, generating codes for realizing the step of selecting the program node according to a pre-constructed association information set, and writing the generated codes into the Signature so as to realize the execution of the selected Procedure when the Signature is called, wherein the association information in the association information set is used for describing the association relation between the Signature and the Procedure.
Further, in the node processing unit, the step of selecting the program node includes:
selecting association information from the association information set, and executing a validity judging step: selecting a corresponding Procedure in response to determining that the validity of the Procedure corresponding to the selected association information is true;
and in response to determining that the validity of the Procedure corresponding to the selected associated information is false, selecting unselected associated information from the associated information set, and continuing to execute the validity judging step.
Further, in response to determining that the validity of the corresponding Procedure of the selected association information is true, selecting the corresponding Procedure includes:
and in response to the value of the preset parameter being larger than the preset value, determining the validity of the Procedure corresponding to the selected associated information as true, and selecting the corresponding Procedure.
Further, in response to determining that the validity of the Procedure corresponding to the selected association information is false, selecting unselected association information from the association information set includes:
and responding to the fact that the value of the preset parameter is smaller than or equal to a preset value, determining that the validity of the Procedure corresponding to the selected associated information is false, and selecting the unselected associated information from the associated information set.
Further, the association information in the association information set includes a name of the Signature and attribute information associated with the name of the Signature, and the attribute information includes a name of the Procedure, a name of the Signature, and a storage address of the Procedure.
Further, the pre-constructed association information set is obtained by:
traversing nodes of the file to be processed when the file to be processed is analyzed, and executing the following storage operations when the current node is accessed: responding to the current node as a Procedure, storing the current node and acquiring attribute information of the current node; and in response to the acquired attribute information including the name of the Signature, storing the included name of the Signature and the attribute information of the current node in association with each other in an association information set.
Further, the storing operation further includes: and storing the current node in response to the current node being a node other than the Procedure.
In a third aspect, an embodiment of the present application provides an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, where the processor implements the steps of the file processing method described above when executing the computer program.
In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium storing a computer program, which when executed by a processor, implements the steps of the file processing method described above.
In a fifth aspect, embodiments of the present application provide a computer program product for, when run on an electronic device, causing the electronic device to perform the file processing method of any one of the first aspects described above.
Compared with the related art, the embodiment of the application has the beneficial effects that: by writing code for executing the step of selecting a program node to Signature, a program that automatically executes the selected Procedure when Signature is called can be realized. Because the program of which Procedure is executed is not needed to be configured in addition when the signaling is called, the signaling can be conveniently called, and the efficiency of calling the signaling is improved.
It will be appreciated that the advantages of the second to fifth aspects may be found in the relevant description of the first aspect, and are not described here again.
Drawings
In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings that are required to be used in the embodiments or the related technical descriptions will be briefly described, and it is apparent that the drawings in the following description are only some embodiments of the present application, and other drawings may be obtained according to the drawings without inventive effort for those skilled in the art.
FIG. 1 is a flow chart of a method for processing files according to an embodiment of the present application;
FIG. 2 is a flowchart illustrating steps for selecting a program node according to an embodiment of the present application;
FIG. 3 is a schematic diagram of a program node according to an embodiment of the present application;
FIG. 4 is a flowchart illustrating a method for processing a file according to another embodiment of the present application;
FIG. 5 is a flowchart illustrating a file parsing step according to an embodiment of the present application;
FIG. 6 is a flow chart of steps performed by code generated by the code generating step according to an embodiment of the present application;
FIG. 7 is a schematic diagram of a document processing apparatus according to an embodiment of the present application;
Fig. 8 is a schematic structural diagram of an electronic device according to an embodiment of the present application.
Detailed Description
In the following description, for purposes of explanation and not limitation, specific details are set forth such as the particular system architecture, techniques, etc., in order to provide a thorough understanding of the embodiments of the present application. It will be apparent, however, to one skilled in the art that the present application may be practiced in other embodiments that depart from these specific details. In other instances, detailed descriptions of well-known systems, devices, circuits, and methods are omitted so as not to obscure the description of the present application with unnecessary detail.
It should be understood that the terms "comprises" and/or "comprising," when used in this specification and the appended claims, specify the presence of stated features, integers, steps, operations, elements, and/or components, but do not preclude the presence or addition of one or more other features, integers, steps, operations, elements, components, and/or groups thereof.
It should also be understood that the term "and/or" as used in the present specification and the appended claims refers to any and all possible combinations of one or more of the associated listed items, and includes such combinations.
As used in the present description and the appended claims, the term "if" may be interpreted as "when..once" or "in response to a determination" or "in response to detection" depending on the context. Similarly, the phrase "if a determination" or "if a [ described condition or event ] is detected" may be interpreted in the context of meaning "upon determination" or "in response to determination" or "upon detection of a [ described condition or event ]" or "in response to detection of a [ described condition or event ]".
Furthermore, the terms "first," "second," "third," and the like in the description of the present specification and in the appended claims, are used for distinguishing between descriptions and not necessarily for indicating or implying a relative importance.
Reference in the specification to "one embodiment" or "some embodiments" or the like means that a particular feature, structure, or characteristic described in connection with the embodiment is included in one or more embodiments of the application. Thus, appearances of the phrases "in one embodiment," "in some embodiments," "in other embodiments," and the like in the specification are not necessarily all referring to the same embodiment, but mean "one or more but not all embodiments" unless expressly specified otherwise. The terms "comprising," "including," "having," and variations thereof mean "including but not limited to," unless expressly specified otherwise.
In order to explain the technical scheme of the application, the following examples are used for illustration.
Referring to fig. 1, a flow chart of a file processing method according to an embodiment of the present application, where the file processing method shown in fig. 1 includes:
and step 101, analyzing the file to be processed to obtain the node of the file to be processed.
The file to be processed is usually an OTX file in an extensible markup language (eXtensible Markup Language, XML) format. The XML format is a plain text format and each XML element may be referred to as a node. Each node typically includes a start tag (< title >), an end tag (</title >) and content between the two tags. Formally, the tags may include notes, references, character data segments, start tags, end tags, null elements, document type declarations, prologs, and the like. It should be noted that there may be one or more files to be processed. If the node has a plurality of files to be processed, the plurality of files to be processed can be respectively analyzed to obtain the nodes of the plurality of files to be processed.
In the present embodiment, the execution subject of the above-described file processing method may be various devices, such as a vehicle diagnostic device. It should be noted that the execution body may be a smart phone, a tablet computer, a laptop portable computer, a desktop computer, or the like.
Here, since the file to be processed is an OTX file in XML format, the file in XML format generally has a specific format, and the file in XML format is composed of several nodes. Therefore, the execution body can analyze the file to be processed in a file analysis mode aiming at the XML format to obtain all nodes of the file to be processed.
And step 102, responding to the node as a signature node, generating codes for realizing the step of selecting the program node according to the pre-constructed association information set, and writing the generated codes into the signature node so as to realize the program of executing the selected program node when the signature node is called.
The association information in the association information set is used for describing the association relation between the Signature and the Procedure. In practice, each of the association information in the association information set is used to describe an association relationship between one Signature and one Procedure. A Signature is typically associated with at least one Procedure.
The step of selecting a program node generally refers to a step of selecting a Procedure from at least one Procedure associated with a Signature. As an example, the step of selecting the program node may include: a Procedure is randomly selected from at least one Procedure associated with the Signature.
In this embodiment, after all the nodes of the file to be processed are obtained by parsing, the execution body may further process the signaling in the execution body. For each Signature, the execution body may generate code for implementing the step of selecting the program node based on an association relationship between the Signature and the Procedure described by the association information set. Thus writing the generated code to Signature to implement the program that executes the selected Procedure when Signature is invoked.
The method provided by the embodiment of the application can realize that the program of the selected Procedure can be automatically executed when the signal is called by writing the code for executing the step of selecting the program node into the signal. Because the program of which Procedure is executed is not required to be additionally set when the Signature is called, the Signature can be conveniently called, and the efficiency of calling the Signature is improved.
In an alternative implementation of various embodiments of the present application, the association information in the association information set generally includes a name of a Signature and attribute information associated with the name of the Signature, and the attribute information includes a name of a Procedure, a name of the Signature, and a storage address of the Procedure. It should be noted that the associated information may also include other information of Signature, and may also include other information of Procedure associated with Signature. The specific limitation is not particularly limited herein.
It should be noted that the set of association information is typically implemented as a map container. The map container is a data structure for storing data in a key value mode. Here, the name of Signature may be used as a key (or referred to as a key), and the attribute information of Procedure may be used as a value (or referred to as a value). The map container can realize rapid and efficient data adding, deleting and checking, and has high data processing efficiency.
In some alternative implementations of the present embodiment, the step of selecting the program node may include steps 201-202.
Fig. 2 is a flowchart illustrating steps of selecting a program node according to an embodiment of the present application.
Step 201, selecting association information from the association information set, and executing a validity judging step: and selecting the corresponding program node in response to determining that the validity of the program node corresponding to the selected association information is true.
Here, the execution subject may select an associated information from the associated information set, and execute the following validity judging step: and if the validity of the Procedure corresponding to the selected association information is true, selecting the Procedure corresponding to the association information. In practical applications, the attribute information of the Procedure generally includes an indication information for indicating the validity of the Procedure. The execution body may analyze the attribute information of the Procedure to obtain the indication information, thereby determining whether the validity of the Procedure is true.
Fig. 3 is a schematic diagram of a program node according to an embodiment of the present application. As shown in FIG. 3, < Procedure > for the first row is the start tag for the Procedure, and </Procedure > for the last row is the end tag for the Procedure.
In line 2, name= "getigbydiagservicer" indicates that the name of the Procedure is getigbydiagservicer. The materialss= "sig: getigionstate" indicates that the Procedure adopts a rule declared by a signaling, and the name of the signaling is sig: getigionstate. validfor= "val: workshop" means that the valdshop name of the validity function of the Procedure is val: workshop. id= "6-p1" indicates that the parent node of the Procedure has an id of 6-p1.
In line 3, the specification node provides a piece of text describing the program.
The relocation node is an implementation flag, and lines 4-16 are implementation contents of the Procedure.
Line 5, parameters node is a parameter set, the parameters of the program in the Procedure are declared here.
Line 6, outParam, is one of the parameters, name= "state", indicating that the name of the parameter is state. id= "6-d1" indicates that the id of the parent node of the parameters node is 6-d1.
Line 7, the specification node provides a piece of text describing the program.
Lines 8-10, the revision node is an implementation of the state parameter, where line 9 indicates that the type of state parameter is a Boolean type.
Lines 13-15, the flow node is a specific program implementation of the Procedure, and the implementation part is omitted in the figure.
According to the contents of fig. 3, if the value of val: workshop function is true, it indicates that the validity of the Procedure is true. Otherwise, if val: workshop function takes on false value, it indicates that the validity of the Procedure is false.
It should be noted that the value of val: workshop function is typically dynamically changed, and the dynamically changed value of val: workshop function may be stored in the association information set as attribute information of Procedure. Therefore, the method can directly analyze the attribute information of the Procedure in the associated information, and can directly know whether the validity of the Procedure is true or not. The data processing efficiency is extremely high.
Step 202, in response to determining that the validity of the program node corresponding to the selected association information is false, selecting unselected association information from the association information set, and continuing to execute the validity judging step.
Here, if the validity of the Procedure corresponding to the association information is false, the executing body may continue to select another unselected association information from the association information set, so as to execute the validity determining step for the new association information. It should be noted that if a valid Procedure is found, the above Procedure for selecting the program node ends. If no valid Procedure is found, the step of selecting the program node ends after traversing the association information set.
In this implementation, automatic selection of a Procedure with a true validity when signaling is invoked, and execution of the selected Procedure may be implemented. The method can realize convenient calling of the Signature, and is beneficial to further improving the calling efficiency of the Signature.
In some alternative implementations of the present embodiment, if the validity of the Procedure is positively related to the value of the preset parameter in the Procedure. Then, in the step 201, in response to determining that the validity of the program node corresponding to the selected association information is true, selecting the corresponding program node includes: and in response to the value of the preset parameter being larger than the preset value, determining the validity of the Procedure corresponding to the selected associated information as true, and selecting the corresponding Procedure.
The preset parameter may be a parameter in a Procedure. The number of the preset parameters may be one or more. If the number of the preset parameters is plural, the average value of the values of the plural parameters may be used as the value of the preset parameter.
The predetermined value may be a predetermined data value. For example, the preset value may be 2.
The validity of the Procedure is directly related to the value of the preset parameter in the Procedure, which generally means that the larger the value of the preset parameter is, the larger the probability that the validity of the Procedure is true is.
Here, if the value of the preset parameter is greater than the preset value, the validity of the Procedure is determined to be true. At this point, the Procedure is selected.
In the implementation mode, the validity of the Procedure is determined by the value of the parameter in the Procedure, so that the implementation is convenient, and the improvement of the data processing efficiency is facilitated. Thereby helping to further improve call efficiency to Signature.
In the implementation manner, when the validity of the Procedure is positively related to the value of the preset parameter in the Procedure, in step 202, in response to determining that the validity of the program node corresponding to the selected association information is false, selecting unselected association information from the association information set includes:
and responding to the fact that the value of the preset parameter is smaller than or equal to a preset value, determining that the validity of the Procedure corresponding to the selected associated information is false, and selecting the unselected associated information from the associated information set.
Here, if the value of the preset parameter is smaller than or equal to the preset value, the validity of the Procedure is determined to be false. And re-selecting the unselected associated information from the associated information set for processing. It can implement that only program whose validity is true is selected for execution.
In an alternative implementation of the various embodiments of the present application, the pre-constructed set of association information is obtained by:
traversing nodes of the file to be processed when the file to be processed is analyzed, and executing the following storage operations when the current node is accessed: first, in response to the current node being a Procedure, the current node is stored and attribute information of the current node is acquired. Then, in response to the acquired attribute information including the name of the Signature, the included name of the Signature and the attribute information of the current node are stored in association with each other in the association information set.
In this implementation manner, when the file to be processed is parsed, the execution body may traverse to each node in the file to be processed. For each node in the file to be processed, the execution body may perform a storage operation on the node. Specifically, if the node is a Procedure, the execution body may store the node and acquire attribute information of the node. Then, whether the attribute information of the node includes the name of the Signature is analyzed, and if so, the name of the Signature included and the attribute information of the node are stored in an associated information set in an associated manner. In practice, the name of the Signature and the attribute information of the Procedure are stored in a map container in the form of key-value pairs, typically with the name of the Signature included as a key and the attribute information of the Procedure as a value.
It should be noted that the association information set is constructed when parsing the file to be processed. Therefore, the file to be processed is only needed to be analyzed once, the data processing efficiency is high, and the method is beneficial to saving of computing resources.
In the above implementation manner, the storing operation may further include: and storing the current node in response to the current node being a node other than the Procedure.
Here, when traversing each node of the file to be processed, if the current node is not a Procedure, the execution body directly stores the current node and attribute information of the current node to obtain the current node. It should be noted that each node in an XML format file typically has attribute information.
In this implementation manner, when traversing each node of the file to be processed, if the current node is a Procedure, the executing body continues to determine whether the Procedure corresponds to a Signature. If the Procedure does not correspond to Signature, the Procedure is stored directly. If the Procedure corresponds to the Signature, storing the name of the corresponding Signature and the attribute information of the Procedure in association with each other to an association information set while storing the Procedure. In addition, if the current node is not the Procedure, the current node is directly stored. The method can analyze the file to be processed only once to obtain each node of the file to be processed and obtain the associated information set. The method is beneficial to improving the data processing efficiency, thereby saving the computing resources.
With continued reference to fig. 4, fig. 4 is a flowchart illustrating a file processing method according to an embodiment of the present application. The file processing method as shown in fig. 4 includes: a file parsing step 401 and a code generating step 402.
Note that the execution subjects of the above-described file parsing step 401 and code generating step 402 may be various devices, such as a vehicle diagnostic device.
Fig. 5 is a flowchart illustrating a file parsing step according to an embodiment of the present application, where the file parsing step includes steps 501-506.
Step 501, it is determined whether there is an OTX file. If yes, go to step 502, otherwise exit the file parsing step.
Step 502, the OTX file is loaded and parsed.
Step 503, judging whether there is a Procedure, if yes, executing step 504, otherwise, executing step 501.
Here, in the process of parsing the OTX source file, if the process is parsed, the process continues to execute step 504. Otherwise, step 501 is executed to implement parsing processing on the next OTX file.
Step 504, the process proceeds to obtain attribute information.
Here, since each node has attribute information therein. The execution body may acquire the attribute information in the Procedure.
Step 505, determine if the Procedure is associated with Signature.
Here, if the attribute information of a Procedure includes the name of a certain Signature, it is considered that the Procedure is associated with the Signature. If the Procedure is associated with Signature, then step 506 is performed, otherwise step 503 is performed to make a determination of other procedures in the current OTX file.
In step 506, the Signature and the Procedure are placed in the map container, the key is Signature, and the value is attribute information of Procedure.
Here, the name of Signature and the attribute information of Procedure are stored in the map container in the form of key-value pairs. Wherein, the key is the name of Signature, and the value is the attribute information of Procedure. Here, the name of the associated Signature and the attribute information of the Procedure are an associated information, and the map container is a specific implementation of the associated information set.
After step 506, step 503 is continued until the current OTX file is parsed.
Here, repeatedly executing step 503 may implement traversing the procedures in the OTX file, thereby obtaining all procedures associated with Signature in the current OTX file. In addition, when the analysis of all OTX files is completed, the above-mentioned related information set can be obtained.
It should be noted that the execution subject of steps 501-506 included in the file parsing step may be various devices, such as a vehicle diagnostic device.
Fig. 6 is a flowchart illustrating steps implemented by the code generated by the code generating step according to the embodiment of the present application. Wherein the code generated by the code generating step may implement the following steps 601-604.
Step 601, loop through the map container in the Signature function body.
Here, in the above file parsing step, in the process of parsing the OTX file, each node of the OTX file may be parsed, so as to obtain each node of the OTX file.
For any of the obtained signalings, the execution body may write a function body for implementing the step of selecting the program node in the signalization. To be implemented within the Signature function, the map container can be traversed. And searching for a valid program node associated with the signature node when traversing the map container to implement a program that executes the selected program node when the signature node is invoked.
Step 602, it is determined whether the Signature has an associated Procedure.
Here, since data is generally stored in the map container in the form of key-value pairs, the keys of the data stored in the map container are: the name of Signature, the value corresponding to the key is: attribute information of the Procedure. Accordingly, the attribute information of the process associated with the Signature name can be found from the map container by the Signature name, thereby obtaining the process associated with the Signature.
Here, if the signaling is associated with a Procedure, step 603 is executed, otherwise the code generation step is exited.
Step 603, determining whether the validity value of the Procedure associated with the Signature is true, and if true, executing step 604. Otherwise, step 601 is executed to continue traversing the map container until a valid Procedure associated with the Signature is found or the map container is traversed.
Step 604, execute the function of the active Procedure associated with the Signature. When the function of the valid Procedure is executed, the function body of the Signature is exited.
It should be noted that the execution subject of the above steps 601 to 604 may be various devices, such as a vehicle diagnostic device.
With further reference to fig. 7, corresponding to the file processing method of the above embodiment, fig. 7 is a block diagram of a file processing apparatus 700 according to an embodiment of the present application, and for convenience of explanation, only a portion related to the embodiment of the present application is shown.
Referring to fig. 7, the apparatus includes:
a file parsing unit 701, configured to parse a file to be processed to obtain a node of the file to be processed;
the node processing unit 702 is configured to generate, in response to the node being a Signature, a code for implementing a step of selecting a program node according to a pre-constructed association information set, and write the generated code into the Signature to implement a program for executing the selected Procedure when the Signature is called, where association information in the association information set is used to describe an association relationship between the Signature and the Procedure.
In one embodiment, the step of selecting a program node in the node processing unit 702 includes:
selecting association information from the association information set, and executing a validity judging step: selecting a corresponding Procedure in response to determining that the validity of the Procedure corresponding to the selected association information is true;
and in response to determining that the validity of the Procedure corresponding to the selected associated information is false, selecting unselected associated information from the associated information set, and continuing to execute the validity judging step.
In one embodiment, in response to determining that the validity of the corresponding Procedure for the selected association information is true, selecting the corresponding Procedure includes:
and in response to the value of the preset parameter being larger than the preset value, determining the validity of the Procedure corresponding to the selected associated information as true, and selecting the corresponding Procedure.
In one embodiment, in response to determining that the validity of the Procedure corresponding to the selected association information is false, selecting unselected association information from the association information set includes:
and responding to the fact that the value of the preset parameter is smaller than or equal to a preset value, determining that the validity of the Procedure corresponding to the selected associated information is false, and selecting the unselected associated information from the associated information set.
In one embodiment, the association information in the association information set includes a name of the Signature and attribute information associated with the name of the Signature, and the attribute information includes a name of the Procedure, the name of the Signature, and a storage address of the Procedure.
In one embodiment, the pre-constructed set of association information is obtained by:
traversing nodes of the file to be processed when the file to be processed is analyzed, and executing the following storage operations when the current node is accessed: responding to the current node as a Procedure, storing the current node and acquiring attribute information of the current node; and in response to the acquired attribute information including the name of the Signature, storing the included name of the Signature and the attribute information of the current node in association with each other in an association information set.
In one embodiment, the storing operation further comprises: and storing the current node in response to the current node being a node other than the Procedure.
The device provided by the embodiment can realize that the program of the selected Procedure is automatically executed when the Signature is called by writing the code for executing the step of selecting the program node into the Signature. Because the program of which Procedure is executed is not required to be additionally set when the Signature is called, the Signature can be conveniently called, and the efficiency of calling the Signature is improved.
It should be noted that, because the content of information interaction and execution process between the above devices/units is based on the same concept as the method embodiment of the present application, specific functions and technical effects thereof may be referred to in the method embodiment section, and will not be described herein.
With further reference to fig. 8, fig. 8 is a schematic structural diagram of an electronic device 800 according to an embodiment of the application. As shown in fig. 8, the electronic device 800 of this embodiment includes: at least one processor 801 (only one processor is shown in fig. 8), a memory 802, and a computer program 803, such as a file processing program, stored in the memory 802 and executable on the at least one processor 801. The steps of any of the various method embodiments described above are implemented by processor 801 when executing computer program 803. The processor 801, when executing the computer program 803, implements the steps of the embodiments of the respective file processing methods described above. The processor 801, when executing the computer program 803, performs the functions of the modules/units of the apparatus embodiments described above, such as the functions of the units 701 to 702 shown in fig. 7.
By way of example, the computer program 803 may be partitioned into one or more modules/units that are stored in the memory 802 and executed by the processor 801 to accomplish the present application. One or more of the modules/units may be a series of computer program instruction segments capable of performing particular functions for describing the execution of the computer program 803 in the electronic device 800. For example, the computer program 803 may be divided into a file parsing unit, a node processing unit, and specific functions of each unit are described in the above embodiments, which are not described herein.
The electronic device 800 may be a computing device such as a server, desktop computer, tablet computer, cloud server, mobile terminal, and the like. Electronic device 800 may include, but is not limited to, a processor 801, a memory 802. It will be appreciated by those skilled in the art that fig. 8 is merely an example of an electronic device 800 and is not intended to limit the electronic device 800, and may include more or fewer components than shown, or may combine certain components, or different components, e.g., an electronic device may also include an input-output device, a network access device, a bus, etc.
The processor 801 may be a central processing unit (Central Processing Unit, CPU), but may also be other general purpose processors, digital signal processors (Digital Signal Processor, DSP), application specific integrated circuits (Application Specific Integrated Circuit, ASIC), field programmable gate arrays (Field-Programmable Gate Array, FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, or the like. A general purpose processor may be a microprocessor or the processor may be any conventional processor or the like.
The memory 802 may be an internal storage unit of the electronic device 800, such as a hard disk or a memory of the electronic device 800. The memory 802 may also be an external storage device of the electronic device 800, such as a plug-in hard disk, a Smart Media Card (SMC), a Secure Digital (SD) Card, a Flash memory Card (Flash Card) or the like, which are provided on the electronic device 800. Further, the memory 802 may also include both internal and external storage units of the electronic device 800. The memory 802 is used to store computer programs and other programs and data required by the electronic device. The memory 802 may also be used to temporarily store data that has been output or is to be output.
It will be apparent to those skilled in the art that, for convenience and brevity of description, only the above-described division of the functional units and modules is illustrated, and in practical application, the above-described functional distribution may be performed by different functional units and modules according to needs, i.e. the internal structure of the apparatus is divided into different functional units or modules to perform all or part of the above-described functions. The functional units and modules in the embodiment may be integrated in one processing unit, or each unit may exist alone physically, or two or more units may be integrated in one unit, where the integrated units may be implemented in a form of hardware or a form of a software functional unit. In addition, the specific names of the functional units and modules are only for distinguishing from each other, and are not used for limiting the protection scope of the present application. The specific working process of the units and modules in the above system may refer to the corresponding process in the foregoing method embodiment, which is not described herein again.
In the foregoing embodiments, the descriptions of the embodiments are emphasized, and in part, not described or illustrated in any particular embodiment, reference is made to the related descriptions of other embodiments.
Those of ordinary skill in the art will appreciate that the various illustrative elements and algorithm steps described in connection with the embodiments disclosed herein may be implemented as electronic hardware, or combinations of computer software and electronic hardware. Whether such functionality is implemented as hardware or software depends upon the particular application and design constraints imposed on the solution. Skilled artisans may implement the described functionality in varying ways for each particular application, but such implementation decisions should not be interpreted as causing a departure from the scope of the present application.
In the embodiments provided in the present application, it should be understood that the disclosed apparatus/electronic device and method may be implemented in other manners. For example, the apparatus/electronic device embodiments described above are merely illustrative, e.g., the division of modules or units is merely a logical functional division, and there may be additional divisions when actually implemented, e.g., multiple units or components may be combined or integrated into another system, or some features may be omitted, or not performed. Alternatively, the coupling or direct coupling or communication connection shown or discussed may be an indirect coupling or communication connection via interfaces, devices or units, which may be in electrical, mechanical or other forms.
The units described as separate units may or may not be physically separate, and units shown as units may or may not be physical units, may be located in one place, or may be distributed over a plurality of network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
In addition, each functional unit in the embodiments of the present application may be integrated in one processing unit, or each unit may exist alone physically, or two or more units may be integrated in one unit. The integrated units may be implemented in hardware or in software functional units.
The integrated modules, if implemented in the form of software functional units and sold or used as a stand-alone product, may be stored in a computer readable storage medium. Based on such understanding, the present application may implement all or part of the flow of the method of the above embodiment, or may be implemented by a computer program to instruct related hardware, and the computer program may be stored in a computer readable storage medium, where the computer program, when executed by a processor, may implement the steps of each of the method embodiments described above. Wherein the computer program comprises computer program code, which may be in the form of source code, object code, executable files or in some intermediate form, etc. The computer readable medium may include: any entity or device capable of carrying computer program code, a recording medium, a U disk, a removable hard disk, a magnetic disk, an optical disk, a computer Memory, a Read-Only Memory (ROM), a random access Memory (RAM, random Access Memory), an electrical carrier signal, a telecommunications signal, a software distribution medium, and so forth. It should be noted that the content of the computer readable medium can be appropriately increased or decreased according to the requirements of the jurisdiction's jurisdiction and the patent practice, for example, in some jurisdictions, the computer readable medium does not include electrical carrier signals and telecommunication signals according to the jurisdiction and the patent practice.
The above embodiments are only for illustrating the technical solution of the present application, and are not limiting; although the application has been described in detail with reference to the foregoing embodiments, it will be understood by those of ordinary skill in the art that: the technical scheme described in the foregoing embodiments can be modified or some technical features thereof can be replaced by equivalents; such modifications and substitutions do not depart from the spirit and scope of the technical solutions of the embodiments of the present application, and are intended to be included in the scope of the present application.
Claims (9)
1. A method of processing a document, the method comprising:
analyzing a file to be processed to obtain a node of the file to be processed, wherein the file to be processed is an OTX file in an XML format, a signature node is a node for declaring an interface in the OTX file, and the function of the signature node is realized through a program node;
responding to the node as a signature node, generating codes for realizing the step of selecting a program node according to a pre-constructed association information set, and writing the generated codes into the signature node so as to realize the execution of the program of the selected program node when the signature node is called, wherein association information in the association information set is used for describing the association relation between the signature node and the program node;
Each piece of association information in the association information set is used for describing an association relation between one signature node and one program node, at least one program node is associated with one signature node, and the step of selecting the program node is used for selecting the program node from the at least one program node associated with the signature node;
the step of selecting the program node comprises the following steps: selecting association information from the association information set, and executing a validity judging step: selecting the corresponding program node in response to determining that the validity of the program node corresponding to the selected association information is true; and responding to the fact that the validity of the program node corresponding to the selected association information is false, selecting the unselected association information from the association information set, and continuing to execute the validity judging step.
2. The method according to claim 1, wherein the validity of the program node is positively correlated to the value of a preset parameter in the program node; and
the responding to the determination that the validity of the program node corresponding to the selected association information is true, selecting the corresponding program node comprises the following steps:
and responding to the fact that the value of the preset parameter is larger than a preset numerical value, determining the validity of the program node corresponding to the selected association information to be true, and selecting the corresponding program node.
3. The method of claim 2, wherein selecting unselected association information from the association information set in response to determining that the validity of the program node to which the selected association information corresponds is false comprises:
and responding to the fact that the value of the preset parameter is smaller than or equal to a preset value, determining that the validity of the program node corresponding to the selected association information is false, and selecting the association information which is not selected from the association information set.
4. The method of claim 1, wherein the association information in the set of association information includes a name of the signature node and attribute information associated with the name of the signature node, the attribute information including a name of the program node, a name of the signature node, and a storage address of the program node.
5. Method according to one of the claims 1-4, characterized in that the pre-constructed set of association information is obtained by:
traversing nodes of the file to be processed when the file to be processed is analyzed, and executing the following storage operations when the current node is accessed: responding to the current node as a program node, storing the current node and acquiring attribute information of the current node; and in response to the acquired attribute information including the name of the signature node, storing the name of the included signature node and the attribute information of the current node in association with each other in an association information set.
6. The method of claim 5, wherein the storing operation further comprises: and storing the current node in response to the current node being a node other than the program node.
7. A document processing apparatus, the apparatus comprising:
the file analysis unit is used for analyzing the file to be processed to obtain a node of the file to be processed, wherein the file to be processed is an OTX file in an XML format, the signature node is a node for declaring an interface in the OTX file, and the function of the signature node is realized through a program node;
the node processing unit is used for responding the node as a signature node, generating codes for realizing the step of selecting the program node according to a pre-constructed association information set, and writing the generated codes into the signature node so as to realize the program of executing the selected program node when the signature node is called, wherein association information in the association information set is used for describing the association relation between the signature node and the program node;
each piece of association information in the association information set is used for describing an association relation between one signature node and one program node, at least one program node is associated with one signature node, and the step of selecting the program node is used for selecting the program node from the at least one program node associated with the signature node;
The step of selecting the program node comprises the following steps: selecting association information from the association information set, and executing a validity judging step: selecting the corresponding program node in response to determining that the validity of the program node corresponding to the selected association information is true; and responding to the fact that the validity of the program node corresponding to the selected association information is false, selecting the unselected association information from the association information set, and continuing to execute the validity judging step.
8. An electronic device comprising a memory, a processor and a computer program stored in the memory and executable on the processor, characterized in that the processor implements the method according to any of claims 1 to 6 when executing the computer program.
9. A computer readable storage medium storing a computer program, characterized in that the computer program, when executed by a processor, implements the method according to any one of claims 1 to 6.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202011035738.3A CN112181539B (en) | 2020-09-27 | 2020-09-27 | File processing method, device, equipment and medium |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202011035738.3A CN112181539B (en) | 2020-09-27 | 2020-09-27 | File processing method, device, equipment and medium |
Publications (2)
Publication Number | Publication Date |
---|---|
CN112181539A CN112181539A (en) | 2021-01-05 |
CN112181539B true CN112181539B (en) | 2023-12-05 |
Family
ID=73944829
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202011035738.3A Active CN112181539B (en) | 2020-09-27 | 2020-09-27 | File processing method, device, equipment and medium |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN112181539B (en) |
Citations (6)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN101887365A (en) * | 2009-05-15 | 2010-11-17 | 国际商业机器公司 | Be used to construct method and system based on the executable code of the application of assembly |
CN102708013A (en) * | 2011-03-07 | 2012-10-03 | 英飞凌科技股份有限公司 | Program-instruction-controlled instruction flow supervision |
CN106372500A (en) * | 2015-07-24 | 2017-02-01 | 英飞凌科技股份有限公司 | Method for determining an intergrity of an execution of a code fragment and a method for providing an abstracted representation of a program code |
CN107291476A (en) * | 2017-06-27 | 2017-10-24 | 北京微影时代科技有限公司 | Canvas code generating methods, device, electronic equipment and storage medium |
JP2019164509A (en) * | 2018-03-19 | 2019-09-26 | 株式会社リコー | Information processing device, program, and information processing system |
CN111684445A (en) * | 2018-02-07 | 2020-09-18 | 索尼公司 | Information processing apparatus, information processing method and program |
-
2020
- 2020-09-27 CN CN202011035738.3A patent/CN112181539B/en active Active
Patent Citations (6)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN101887365A (en) * | 2009-05-15 | 2010-11-17 | 国际商业机器公司 | Be used to construct method and system based on the executable code of the application of assembly |
CN102708013A (en) * | 2011-03-07 | 2012-10-03 | 英飞凌科技股份有限公司 | Program-instruction-controlled instruction flow supervision |
CN106372500A (en) * | 2015-07-24 | 2017-02-01 | 英飞凌科技股份有限公司 | Method for determining an intergrity of an execution of a code fragment and a method for providing an abstracted representation of a program code |
CN107291476A (en) * | 2017-06-27 | 2017-10-24 | 北京微影时代科技有限公司 | Canvas code generating methods, device, electronic equipment and storage medium |
CN111684445A (en) * | 2018-02-07 | 2020-09-18 | 索尼公司 | Information processing apparatus, information processing method and program |
JP2019164509A (en) * | 2018-03-19 | 2019-09-26 | 株式会社リコー | Information processing device, program, and information processing system |
Non-Patent Citations (1)
Title |
---|
基于代理/服务的XML数字签名研究;程雪红等;《计算机安全》;20080715(第07期);全文 * |
Also Published As
Publication number | Publication date |
---|---|
CN112181539A (en) | 2021-01-05 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN108427731B (en) | Page code processing method and device, terminal equipment and medium | |
CN111797402B (en) | A method, device and storage medium for software vulnerability detection | |
CN106371984A (en) | Data monitoring method, equipment and system | |
CN112907198B (en) | Service state circulation maintenance method and device and electronic equipment | |
CN111553652B (en) | Service processing method and device | |
CN110716866A (en) | Code quality scanning method and device, computer equipment and storage medium | |
CN111711540A (en) | Government and enterprise business alarm identification method and device | |
CN112181430B (en) | Code change statistical method, device, electronic equipment and storage medium | |
CN112181924A (en) | File conversion method, device, equipment and medium | |
CN113419738A (en) | Interface document generation method and device and interface management equipment | |
CN111767213B (en) | Database check point testing method and device, electronic equipment and storage medium | |
CN112181539B (en) | File processing method, device, equipment and medium | |
CN118363603A (en) | Code file analysis method, device, electronic equipment and readable storage medium | |
CN116775488A (en) | Abnormal data determination method, device, equipment, medium and product | |
CN117171030A (en) | Method, device, equipment and storage medium for detecting software running environment | |
CN108628909B (en) | Information pushing method and device | |
CN111736848B (en) | Packet conflict positioning method, device, electronic equipment and readable storage medium | |
CN112711584B (en) | Data inspection method, inspection device, terminal equipment and readable storage medium | |
CN115185833A (en) | Abnormal code processing method and device, computer equipment and storage medium | |
CN114818645B (en) | Automatic report generation method, device, equipment and medium based on data body | |
CN111258628A (en) | Rule file comparison method and device, readable storage medium and terminal equipment | |
CN114900339B (en) | Intrusion detection method, intrusion detection system, intrusion detection equipment and storage medium | |
CN111882310B (en) | Data comparison method, device and equipment and computer readable storage medium | |
CN111178044B (en) | Method and device for determining target text elements | |
CN116859893B (en) | Device cyclic linkage detection method, device, electronic device and storage medium |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
GR01 | Patent grant | ||
GR01 | Patent grant |