CN114090523B - Electronic device, and node parsing method and medium for XML file thereof - Google Patents

Electronic device, and node parsing method and medium for XML file thereof Download PDF

Info

Publication number
CN114090523B
CN114090523B CN202210061926.6A CN202210061926A CN114090523B CN 114090523 B CN114090523 B CN 114090523B CN 202210061926 A CN202210061926 A CN 202210061926A CN 114090523 B CN114090523 B CN 114090523B
Authority
CN
China
Prior art keywords
instruction
parameter
xml
node
node data
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
Application number
CN202210061926.6A
Other languages
Chinese (zh)
Other versions
CN114090523A (en
Inventor
陈宁
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Shanghai Glory Smart Technology Development Co ltd
Original Assignee
Honor Device Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Honor Device Co Ltd filed Critical Honor Device Co Ltd
Priority to CN202210061926.6A priority Critical patent/CN114090523B/en
Publication of CN114090523A publication Critical patent/CN114090523A/en
Application granted granted Critical
Publication of CN114090523B publication Critical patent/CN114090523B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/10File systems; File servers
    • G06F16/16File or folder operations, e.g. details of user interfaces specifically adapted to file systems
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F40/00Handling natural language data
    • G06F40/20Natural language analysis
    • G06F40/205Parsing
    • G06F40/221Parsing markup language streams

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Physics & Mathematics (AREA)
  • Databases & Information Systems (AREA)
  • Data Mining & Analysis (AREA)
  • Human Computer Interaction (AREA)
  • Multimedia (AREA)
  • Health & Medical Sciences (AREA)
  • Artificial Intelligence (AREA)
  • Audiology, Speech & Language Pathology (AREA)
  • Computational Linguistics (AREA)
  • General Health & Medical Sciences (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The present application relates to information processing technologies, and in particular, to a node parsing method and medium for an electronic device and an XML file thereof. Wherein the method comprises the following steps: determining an instruction type of a first instruction in first XML node data in an XML file; and resolving the parameter of the first instruction by adopting a resolving mode corresponding to the instruction type of the first instruction. By the method, corresponding to the first instruction of the first instruction type, parameter values of parameters of the first instruction can be analyzed from the first XML node data; the first instruction corresponding to the second instruction type may analyze parameter values of parameters corresponding to the first instruction from the first XML node data and second XML node data adjacent to the first XML node data in the XML file. The electronic equipment can determine the type of the instruction according to the instruction name of the instruction, and then analyze the instruction and the parameter value of the instruction from the data file according to the analysis rule corresponding to the type of the instruction, so that the parameter value of each parameter of the first instruction in the XML file is prevented from being omitted.

Description

Electronic device, and node parsing method and medium for XML file thereof
Technical Field
The present application relates to information processing technologies, and in particular, to an electronic device and a node parsing method and medium for an XML file thereof.
Background
In some cases, the instructions may be stored in a data file, and the application may retrieve the instructions by parsing a data set of the instructions in the data file. For example, the instruction may be an instruction to draw an image, an instruction to acquire drawing data, an instruction to configure drawing parameters, and the like, and the image may be a frame of a game being executed by the electronic device. Taking the data file as an XML (Extensible Markup Language) file, the XML file may store the instructions through XML nodes, each of the XML nodes represents a data set of the instructions, and each of the XML nodes includes a start tag, an end tag and instruction data between the two tags. For example, one style of an XML node that contains instructions in an XML file is:
< node number =1 name = instruction 1>
< parameter name = parameter 1> parameter value 1< parameter >
< parameter name = parameter 2> parameter value 2< parameter >
< node >
< node number =1 name = instruction 2>
< parameter name = parameter 3> parameter value 3< parameter >
< node >
The application program can analyze the name of the instruction according to the XML node of the XML file: instruction 1; parameters of instruction 1: parameters 1 and 2, and parameter values 1 and 2 corresponding to parameters 1 and 2, and instructions 2, parameters of instructions 2: parameter 3 and parameter value 3.
However, when storing instruction data in an XML file, in order to save space, part of parameters and parameter values corresponding to instructions in XML nodes are omitted, for example, for the instruction 2 described above, the instruction 2 further includes one parameter 1 and a parameter value 1 corresponding to the parameter 1, but the parameter is the same as the parameter of the instruction 1, so that in the node corresponding to the instruction 2 in the XML file, the parameter 1 and the parameter value 1 corresponding to the instruction 2 are omitted, and thus, an application program acquires only part of parameters and parameter values of the instruction 2, and when parsing the instruction 2 from the XML node, only the parameter value 3 corresponding to the parameter 3 of the instruction 2 is acquired, and the parameter 1 and the parameter value 1 corresponding to the instruction 2 are omitted, and thus, the parsed instruction is inaccurate.
Disclosure of Invention
The application aims to provide an electronic device and a node analysis method and medium of an XML file of the electronic device.
In a first aspect, an embodiment of the present application provides a node parsing method for an XML file, where the method is used for an electronic device, and includes:
acquiring first XML node data in an XML file;
determining an instruction type of a first instruction in the first XML node data;
analyzing the parameter of the first instruction by adopting an analysis mode corresponding to the instruction type of the first instruction, wherein the analysis mode comprises the following steps:
analyzing parameter values of all parameters of the first instruction based on the first XML node data corresponding to the type of the first instruction as the first instruction type;
the type corresponding to the first instruction is a second instruction type, and parameter values of parameters corresponding to the first instruction are analyzed based on the first XML node data and second XML node data adjacent to the first XML node data in the XML file, wherein the type of the second instruction in the second XML node data is the first instruction type.
With some embodiments of the present application, the electronic device may preset a correspondence between an instruction name of an instruction and a type of the instruction (i.e., a kind of the instruction), and set a corresponding parsing manner (i.e., a parsing rule) for each type of the instruction. After the electronic device obtains the node (i.e., the XML node) including the instruction from the data file (i.e., the XML file), the electronic device may determine the type of the instruction according to the instruction name of the instruction, and then parse the instruction and the parameter value of the instruction from the data file according to the parsing rule corresponding to the type of the instruction.
In a possible implementation of the first aspect, the first XML node data and the second XML node data are data located between a start tag and a corresponding end tag of an XML node in an XML file.
In the embodiment of the present application, the first instruction type may be a normal instruction, and the second instruction type may be an associated instruction. For the conventional instruction, the parameter contained in the first XML node data corresponding to the conventional instruction in the XML file is consistent with the actual parameter of the conventional instruction, and the parsing manner of the conventional instruction may be to parse the parameter value corresponding to the parameter of the conventional instruction from the first XML node data corresponding to the conventional instruction based on the parameter of the conventional instruction.
In this embodiment of the present application, for the association instruction, part of parameters of the association instruction do not exist in the first XML node data corresponding to the association instruction in the XML file, and a parsing manner of the association instruction may be: based on the parameters of the associated instruction, in addition to parsing the parameter values corresponding to the parameters of the partial associated instruction from the first XML node data corresponding to the associated instruction, the parameter values corresponding to the partial parameters that are not present in the first XML node data of the associated instruction need to be parsed from the first XML node data of the already parsed conventional instruction adjacent to the associated instruction.
In a possible implementation of the first aspect, the first instruction type and the second instruction type are determined according to an instruction name of the first instruction.
In this embodiment of the application, the electronic device may first store a corresponding relationship between an instruction name of the first instruction and the first instruction type and the second instruction type, and may determine the type of the first instruction according to the corresponding relationship after analyzing the instruction name of the first instruction from the first XML node data.
In a possible implementation of the first aspect, the second XML node data adjacent to the first XML node data is an XML node arranged before the first XML node data in the XML file.
In this embodiment, the second XML node data corresponding to the second instruction may be an XML node whose line number is smaller than the line number corresponding to the first XML node data in the same XML file.
In a possible implementation of the first aspect, analyzing a parameter value of each parameter of the first instruction by the following method, where the type of the first instruction is the second instruction type, includes:
determining a first parameter which does not exist in first XML node data in the parameters belonging to the first instruction according to a first parameter list of the first instruction;
and acquiring a parameter value of a second parameter with the same parameter name as the first parameter from the parameter corresponding to the second instruction in the second XML node data, and taking the parameter value as the parameter value of the first parameter of the first instruction.
In the embodiment of the application, a parameter value of a first parameter of a first instruction, which does not exist in first XML node data, is obtained from second XML node data corresponding to a second instruction, and the parameter value is used as a parameter value of the first instruction.
In a possible implementation of the first aspect, the first parameter list is used to store a correspondence between an instruction name of the first instruction and each parameter of the first instruction, and the first parameter list is stored in a storage area of the electronic device.
In this embodiment of the application, the first parameter list may be a correspondence between an instruction name of a first instruction preset in the electronic device and each parameter of the first instruction.
In a possible implementation of the first aspect, the method further includes:
and determining the instruction execution sequence corresponding to the first instruction and the second instruction according to the instruction names corresponding to the first instruction and the second instruction.
In a second aspect, an embodiment of the present application provides a readable medium, where the readable medium has instructions stored thereon, and the instructions, when executed on an electronic device, cause the electronic device to perform the node parsing method for the XML file of the first aspect.
In a third aspect, an embodiment of the present application provides an electronic device, including:
a memory for storing instructions for execution by one or more processors of the electronic device, an
And the processor is one of the processors of the electronic equipment and is used for executing the node parsing method of the XML file in the first aspect.
In a fourth aspect, an embodiment of the present application provides a computer program product, including: a non-transitory computer readable storage medium containing computer program code for performing the node parsing method of the XML file of the first aspect.
Drawings
FIG. 1 illustrates a scenario of an electronic device parsing instructions from a data file according to an embodiment of the application;
FIG. 2 illustrates a schematic diagram of a data file containing instructions according to an embodiment of the present application;
FIG. 3 is a diagram illustrating a hardware structure of an electronic device according to an embodiment of the present application;
FIG. 4 is a flowchart illustrating a node parsing method for an XML file according to an embodiment of the present application;
FIG. 5 illustrates a schematic diagram of a data file containing instructions according to an embodiment of the present application;
FIG. 6 illustrates a schematic diagram of a data file containing instructions according to an embodiment of the present application.
Detailed Description
Embodiments of the present application include, but are not limited to, an electronic device and a node parsing method and medium of an XML file thereof. To make the objects, technical solutions and advantages of the present application more clear, embodiments of the present application will be described in further detail below with reference to the accompanying drawings.
Fig. 1 is a schematic view illustrating a scenario that an electronic device 100 parses a data file 200 in an XML format and obtains an instruction from the data file 200 in an embodiment of the present application. As shown in fig. 1, the data file 200 may be a data file containing instructions stored in the server 300, and after acquiring the data file 200 from the server 300 through a communication connection with the server 300, the electronic device 100 reads a node containing instructions in the data file 200, analyzes the node, and acquires the instructions and parameters contained in the data file 200.
In order to solve the problem that the data set of the instruction in the data file omits partial parameters and parameter values of the instruction, which causes inaccuracy in the process of analyzing the data file to obtain the instruction by the application program, the embodiment of the application discloses an analyzing method for the data file. Specifically, the electronic device may preset a correspondence between a name of the instruction and a category of the instruction, and set a corresponding parsing rule for each category of the instruction. After the electronic device obtains the node including the instruction from the data file, the electronic device may determine the type of the instruction according to the name of the instruction, and then parse the instruction and the parameter of the instruction from the data file according to a parsing rule corresponding to the type of the instruction. For example, for an instruction with part of parameters and parameter values omitted from the data file, the electronic device may obtain the parameters and parameter values with the omitted instruction from the data file according to a parsing rule of such an instruction.
In some embodiments of the present application, in a correspondence between a name of an instruction and a type of the instruction preset by an electronic device, the type of the instruction may be divided into a conventional instruction and an associated instruction, where for the conventional instruction, a parameter included in a node corresponding to the conventional instruction in a data file is consistent with an actual parameter of the conventional instruction, and therefore, an analysis rule of the conventional instruction may be: and analyzing a parameter value corresponding to the parameter of the conventional instruction from a node corresponding to the conventional instruction based on the parameter of the conventional instruction.
For the association instruction, the node corresponding to the association instruction in the data file omits a part of actual parameters of the association instruction, so the parsing rule of the association instruction may be: based on the parameters of the associated instruction, in addition to parsing the parameter values corresponding to the parameters of part of the associated instruction from the nodes corresponding to the associated instruction, it is also necessary to obtain the parameter values corresponding to the parameters omitted by the nodes corresponding to the associated instruction from the already parsed instructions (the type of the instruction may be a conventional instruction or the associated instruction) adjacent to the associated instruction.
It is understood that the electronic device may sort the instructions according to the format in which the nodes in the data file store the instructions, and divide the instructions into regular instructions and associated instructions, which do not represent the functionality of the instructions. For example, in an image rendering application, conventional and associated instructions herein may include: in the process of drawing the image, an instruction for drawing a vertex, an instruction for drawing a texture, a coloring instruction and a drawing information configuration instruction for configuring the drawing process are used; the instructions adjacent to the associated instruction may be instructions corresponding to a node in the data file that is prior to the node of the associated instruction.
It is to be understood that, in other embodiments of the present application, the manner of determining the type of the instruction may also be to preset a correspondence between a name of the instruction and a parameter of the instruction, compare the number of parameters corresponding to the instruction obtained from the data file with the parameter of the preset instruction, and if the number of parameters is consistent with the parameter of the preset instruction, determine that the instruction is a normal instruction, and if the number of parameters is inconsistent with the parameter of the preset instruction, determine that the instruction is an associated instruction.
Fig. 2 is a schematic diagram of a data file containing instructions according to an embodiment of the present application, where the data file shown in fig. 2 may be in an XML format, and data sets of the instructions in the data file are nodes. As shown in fig. 2, the data file includes two chunk nodes, where id of the chunk node indicates a serial number of the chunk node in the data file, name is an attribute of the chunk node, and data in a name suffix "" indicates a name of the instruction, each node further includes a name of the parameter and a type of the parameter, that is, data between a start mark < chunk > and an end mark </chunk > of the chunk node, where the name of the parameter and the type of the parameter may be consistent with the name of the parameter of the instruction corresponding to the node and the type of the parameter; each parameter contained in the node also has a parameter value, and the parameter value is used for assigning a value to the parameter of the instruction when the electronic equipment executes the instruction.
As shown in FIG. 2, node number 1 stores the instruction glGenVertexAlrrays, and node number 2 stores the instruction glGenTextures; meanwhile, the electronic device may preset a correspondence between a name of the instruction and a kind of the instruction, for example: as shown in table 1, the electronic device may determine that the instruction glGenVertexArrays is a normal instruction and the instruction glgentextores may be an associated instruction according to the name of the instruction glGenVertexArrays and the name of the instruction glgentextores by the correspondence between the name of the instruction and the kind of the instruction shown in table 1. For the instruction glGenVertexArrays, the electronic device may parse the data file to obtain a parameter n and a parameter array corresponding to the instruction glGenVertexArrays, and parameter values of the parameter n and the parameter array are 1 and 120.
For the instruction glGenTextures, the node with the sequence number 2 in the data file stores part of the parameters and parameter values of the instruction glGenTextures, such as: the parameters byte and data and the parameter values 512 and 1 corresponding to the parameters byte and data. The electronic device determines that the node with the sequence number 2 in the data file omits the parameter array of the instruction glGenTextures according to the parameter array, byte and data of the instruction glGenTextures shown in Table 1, and the electronic device can obtain the parameter value corresponding to the parameter array from the parsed adjacent instruction glGenVertexAlrrays adjacent to the instruction glGenTextures and use the parameter value as the parameter value of the parameter array of the instruction glBufferData.
TABLE 1
Name of instruction Kind of instruction Parameters of an instruction
glGenVertexArrays Regular instructions n,array
glGenTextures Association instruction array,bytesize,data
Fig. 3 is a schematic diagram illustrating a hardware structure of an electronic device 100 for performing a node parsing method for an XML file according to an embodiment of the present application. It is to be understood that the electronic device 100 may also be a computer, a workstation, an intelligent terminal, an application server, an intelligent electronic device capable of automatically and rapidly performing a large amount of numerical calculations and various information processing according to a program stored in advance, and the embodiment of the present application is not limited thereto.
As shown in fig. 3, the electronic device 100 includes a processor 101, a system memory 102, a non-volatile memory 103, a network interface 104, and an input/output device 105, and system control logic 106 for coupling the processor 101, the system memory 102, the non-volatile memory 103, the network interface 104, and the input/output device 105.
The processor 101 is configured to execute instructions of a node parsing method for an XML file according to an embodiment of the present application. For example, the processor 101 may determine a kind of an instruction contained in a data file acquired from the electronic device 100, and parse the instruction and a parameter of the instruction from the data file according to a parsing rule corresponding to the kind of the instruction.
The system memory 102 and the non-volatile storage 103 may be used to temporarily or permanently store instructions 107 and may also be used to temporarily or permanently store parsing rules for parsing instructions from data files according to data files retrieved from the electronic device 100. The instruction 107 is a node parsing method for implementing the XML file according to the embodiment of the present application.
The network interface 104 is used for communication with other devices, for example, the electronic device 100 may communicate with a server through the network interface 104.
The input/output devices 105 may be used for user interaction with the electronic device 100.
It is to be understood that the electronic device 100 may also be a computer, a smart television, a smart speaker, a tablet computer, a server, a wearable device, a head-mounted display, a mobile email device, a portable game console, a portable music player, a reader device, and the like, and the embodiments of the present application are not limited thereto.
The following describes in detail a node parsing method for an XML file executed by the computer 100 according to the present application, with reference to fig. 4, by taking the electronic device 100 shown in fig. 3 as the computer 100 as an example. It is understood that the node parsing method of the XML file shown in fig. 4 may be implemented by a processor of the computer 100 executing a program corresponding to the node parsing method of the XML file.
S401: a data file containing instructions is obtained.
For example, in an image rendering application scenario, the data file may be a data file of an image derived from a rendering tool, the data file containing instructions for drawing the image, such as: the instructions to render the image may include: the method comprises the steps of drawing a vertex instruction, a texture instruction, a coloring instruction and a drawing information configuration instruction for configuring the drawing process, and the drawing of the image is completed by analyzing the instruction contained in the data file and extracting the instruction from the data file. The format of the data file here may be in XML format.
It is understood that the data file may be a data file containing instructions stored in the server 300, and the computer 100 may obtain the data file from the server 300 through a communication connection with the server 300; alternatively, the server 300 may send the data file to the computer 100 via a communication connection. The data file may also be a data file generated by the computer 100 running the rendering tool, and the computer 100 may store the data file in the storage area and read the data file from the storage area.
S402: the node containing the instruction is read from the data file.
In the embodiment of the present application, for a data file in an XML format, a node containing an instruction is an XML node in the XML file, and the node containing the instruction is read from the data file, that is, nodes in the data file are traversed, and the instruction contained in the node and parameters of the instruction are obtained.
The above method for traversing the nodes in the data file may be that the computer 100 obtains all the nodes in the data file by the start tag and the end tag of the node, and obtains the name of the instruction by reading the attribute of each node, for example, determining the name of the instruction by reading the name of the node; the computer 100 then traverses the child nodes included in each node, and the child nodes of each node are parameters of the instruction corresponding to the node.
Fig. 5 is a schematic diagram of an XML-formatted data file containing instructions for drawing an image according to an embodiment of the present application, and it can be seen that the computer 100 may determine that the data file shown in fig. 5 contains three chunk nodes, i.e., data sets of instructions. The first row to the fourth row in fig. 5 describe the first chunk node, wherein id in the first row represents the serial number of the node in the data file, name = "glGenBuffers" represents the name of the instruction corresponding to the node, and it can be seen that the name of the instruction corresponding to the node with serial number 1 is glGenBuffers. glGenBuffers is an instruction in OpenGL (Open Graphics Library) for generating a buffer object, where the buffer object can be data of a pixel in an image.
The second to third lines in FIG. 5 store the parameters of the glGenBuffers instruction, the second line describing the first parameter of the glGenBuffers instruction, as shown in FIG. 5, < int > and </int > denote the start and one end markers of the first parameter; name = "n" indicates that the name of the first argument is n, and typename = "int 32_ t" indicates that the type of the first argument is int32_ t, i.e., integer, indicates a 32-bit integer; 1 between < int > and </int > indicates the parameter value of the first parameter.
As with the storage of the glGenBuffers instruction in the second line of the data file, the third line depicts the second parameter of the glGenBuffers instruction, as shown in FIG. 5, < ResourceId > and </ResourceId > indicate the start tag and an end tag of the second parameter; name = "buffer" means that the name of the first parameter is buffer, and typename = "GLResource" means that the type of the second parameter is array type; 120 between < int > and </int > represents the parameter value of the second parameter.
For the second chunk node, i.e., the node numbered 1, depicted in the fifth through eighth rows of fig. 5, computer 100 may determine that the instruction included in the second chunk node is a glBindBuffers instruction in the same manner as the glGenBuffers instruction included in the second chunk node. Next, the computer 100 determines that the second chunk node further includes the first parameter target and the second parameter BUFFER of the glBindBuffers instruction, and further determines the parameter value GL _ ARRAY _ BUFFER of the target and the parameter value 120 of the BUFFER.
Similarly, for the third chunk node described in the ninth line to the fourteenth line in fig. 5, that is, the node with the sequence number 3, the computer 100 may determine that the instruction included in the third chunk node is a glBufferData instruction, the third chunk node further includes parameters of the glBufferData instruction, which are, respectively, buffer, byte, data, and use, and corresponding parameter values, 120, 512, 1, and GL _ STATIC _ DRAW, of the above parameters.
S403: and determining the type of the instruction corresponding to the node.
In this embodiment of the application, the computer 100 may preset a type of the instruction corresponding to each instruction, as shown in table 2, the computer 100 may preset a correspondence relationship between a name of the instruction, a parameter of the instruction, and the type of the instruction in the storage area, where the type of the instruction may include a conventional instruction and an associated instruction. The computer 100 may determine the type of the instruction corresponding to the instruction included in the node from the correspondence described in table 2 according to the name of the instruction acquired from the node of the data file.
TABLE 2
Name of instruction Kind of instruction Parameters of an instruction
glGenBuffers Regular instructions n,buffer
glBindBuffers Regular instructions target,buffer
glBufferData Association instruction target,buffer,bytesize,data,usage
It is to be understood that table 2 merely illustrates names of instructions contained in the data file, but does not constitute a limitation to the embodiments of the present application, and any other names of instructions may also be included in the embodiments of the present application.
With continuing reference to fig. 5, taking the instruction glGenBuffers corresponding to the node numbered 1 shown in fig. 5 as an example, the computer 100 may determine that the kind of the instruction corresponding to the instruction glGenBuffers is a normal instruction from the correspondence described in table 2 according to the name of the instruction glGenBuffers. It is understood that, for the instruction glbufferData, from the correspondence described in Table 2, it can be determined that the kind of the instruction corresponding to the instruction glbufferData is the related instruction.
In other embodiments of the present application, the computer 100 may further compare the parameter of the instruction obtained from the node of the data file with the parameter of the instruction in the corresponding relationship described in table 2, and if the two parameters are consistent, the computer 100 determines that the instruction is a normal instruction; if not, the computer 100 determines that the instruction is an associated instruction. Continuing with fig. 5, taking instruction glGenBuffers corresponding to the node with serial number 1 shown in fig. 5 as an example, if the parameter of instruction glGenBuffers acquired by the computer 100 from the node with serial number 1 is n, and buffer is consistent with the parameter of instruction glGenBuffers described in table 2, the computer 100 may determine that the instruction glGenBuffers is a normal instruction; taking the instruction glBufferData corresponding to the node with the sequence number of 3 shown in fig. 5 as an example, for the instruction glBufferData, parameters of the instruction glBufferData acquired by the computer 100 from the node with the sequence number of 3 are buffer, byte, data, and use, which are inconsistent with the parameters of the instruction glBufferData described in table 2, and the node with the sequence number of 3 lacks the parameter target, the computer 100 may determine the instruction glBufferData as the associated instruction.
S404: and analyzing the nodes by using the corresponding analysis rule according to the type of the instruction to obtain the analyzed instruction and the parameter of the instruction.
In this embodiment, after the computer 100 determines the type of the instruction corresponding to the instruction in step S403, the computer 100 may analyze the node including the instruction according to the analysis rule corresponding to the type of the instruction, and further obtain the analyzed instruction and the parameter of the instruction. That is, the parameter value stored in the node of the instruction in the data file is acquired, the parameter value is added to the position of the parameter corresponding to the parameter value in the instruction, and the instruction is assigned to form a complete instruction.
Continuing with fig. 5, taking the instruction glGenBuffers corresponding to the node with serial number 1 shown in fig. 5 as an example, the type of the instruction glGenBuffers is a conventional instruction, that is, the parameters of the instruction glGenBuffers stored in the node with serial number 1 are consistent with the actual parameters of the instruction glGenBuffers, so the analysis rule of the instruction glGenBuffers may be that the computer 100 adds the obtained parameter value of the instruction glGenBuffers stored in the node with serial number 1 to the position of the parameter corresponding to the obtained parameter value in the instruction to form a complete instruction glGenBuffers, for example: the complete instruction glGenBuffers after parsing can be glGenBuffers (1, & resource 120).
Similarly, for the instruction glBindBuffers corresponding to the node with sequence number 2 shown in fig. 5, the type of the instruction glBindBuffers is a conventional instruction, and the parameters of the instruction glBindBuffers stored in the node with sequence number 2 are consistent with the actual parameters of the instruction glBindBuffers, so that the analyzed complete instruction glBindBuffers may be glBindBuffers (GL _ arm _ BUFFER, & resource 120).
For the instruction glBufferData corresponding to the node with the sequence number of 3 shown in fig. 5, the type of the instruction glBufferData is a related instruction, that is, the parameter of the instruction glBufferData stored in the node with the sequence number of 3 is not consistent with the actual parameter of the instruction glBufferData, so the analysis rule of the instruction glBufferData may be that the computer 100 adds the parameter value of the part of the instruction glBufferData stored in the node with the sequence number of 3 to the position of the parameter corresponding to the parameter value of the part in the instruction; meanwhile, the computer 100 further needs to obtain parameter values corresponding to parameters omitted from nodes with sequence number 3 of the instruction glBufferData, that is, the target parameter and the parameter value GL _ ARRAY _ BUFFER corresponding to the target parameter, from the instruction glBindBuffers corresponding to the node with sequence number 2 in fig. 5, and add the parameter values corresponding to the parameters omitted from the nodes with sequence number 3 of the instruction glBufferData to the position corresponding to the target parameter in the instruction glBufferData, so as to form complete instruction glBufferData, for example, the complete instruction glBufferData after being analyzed may be glBufferData (GL _ ARRAY _ BUFFER, & resource120, 512, bufferMap (1), GL _ STATIC _ DRAW).
Fig. 4 describes a node parsing method of an XML file executed by an electronic device. By the method, the electronic equipment can analyze different types of instructions and acquire complete parameter values corresponding to the instructions from the data file containing the instructions, and parameter values of partial instructions can be prevented from being lost due to different storage forms corresponding to the different types of instructions in the data file. It is to be understood that fig. 4 only describes the parsing method for the two instructions, namely the conventional instruction and the associated instruction, and in other embodiments of the present application, the data file may further include a drawing configuration parameter value, where the drawing configuration parameter value may be a parameter value of a drawing information configuration instruction, that is, basic drawing information for configuring a process of drawing an image before the electronic device executes the instruction of drawing the image.
In this embodiment of the application, the process of acquiring the drawing information configuration instruction and the drawing configuration parameter value corresponding to the drawing information configuration instruction by the electronic device may be executed in step S404 in fig. 4, and the computer 100 may preset each drawing information configuration instruction and the drawing configuration parameter corresponding to the drawing information configuration instruction, as shown in table 3, and the computer 100 may store the drawing information configuration instruction and the corresponding relationship between the drawing configuration parameters in the storage area in advance. The computer 100 may obtain a parameter value of a parameter of the instruction corresponding to the name of the instruction from the data file according to the name of the instruction in table 3, and add the obtained parameter value to a position of the parameter corresponding to the parameter value in the instruction to form a complete instruction.
TABLE 3
Name of instruction Parameters of an instruction
glFrontFace GL_CW
glEnable GL_DEPTH_TEST
glActiveTexture GL_TEXTURE0
In the embodiment of the present application, the instruction glFrontFace in table 3 is used to set the front drawing, the instruction glEnable is used to turn on the depth test, and the instruction glActiveTexture is used to activate the texture unit.
It is understood that table 3 merely illustrates names of instructions contained in the data file, but does not limit the embodiments of the present application, and any other names of instructions may be included in the embodiments of the present application.
In the embodiment of the present application, in addition to storing instructions in a data file (XML file), parameters (for example, a shader parameter (shading parameter)) are stored in the data file, and the shading parameter is used to perform rendering on a geometric figure of an object included in an image when the instruction for rendering a vertex is executed or to perform coloring on an object included in an image when the instruction is executed.
Fig. 6 is a schematic diagram illustrating an XML-formatted data file containing coloring parameters in an embodiment of the present application, and it can be seen that the computer 100 may determine that the data file shown in fig. 6 contains a struct node, which is a data set of parameters. Where "g _ dfgtextra" in the second row in fig. 6 denotes a parameter index field, the parameter index field denotes a position of a parameter for instructing to locate the parameter and read the parameter, and "0" in the sixth row in fig. 6 denotes a parameter modification value, that is, a parameter value.
By the method, the electronic equipment can analyze various types of instructions and parameters corresponding to the instructions from the data file (XML file), so that the parameters corresponding to the instructions cannot be omitted by the analyzed instructions, and the integrity of the instructions and the parameters is ensured.
It will be understood that, although the terms "first", "second", etc. may be used herein to describe various features, these features should not be limited by these terms. These terms are used merely for distinguishing and are not intended to indicate or imply relative importance. For example, a first feature may be termed a second feature, and, similarly, a second feature may be termed a first feature, without departing from the scope of example embodiments.
Moreover, various operations will be described as multiple operations separate from one another in a manner that is most helpful in understanding the illustrative embodiments; however, the order of description should not be construed as to imply that these operations are necessarily order dependent, and that many of the operations can be performed in parallel, concurrently, or simultaneously. In addition, the order of the operations may be re-arranged. The process may be terminated when the described operations are completed, but may have additional operations not included in the figure. The processes may correspond to methods, functions, procedures, subroutines, and the like.
References in the specification to "one embodiment," "an illustrative embodiment," etc., indicate that the embodiment described may include a particular feature, structure, or characteristic, but every embodiment may or may not necessarily include the particular feature, structure, or characteristic. Moreover, such phrases are not necessarily referring to the same embodiment. Furthermore, when a particular feature is described in connection with a particular embodiment, the knowledge of one skilled in the art can affect such feature in combination with other embodiments, whether or not such embodiments are explicitly described.
The terms "comprising," "having," and "including" are synonymous, unless the context dictates otherwise. The phrase "A/B" means "A or B". The phrase "A and/or B" means "(A), (B) or (A and B)".
As used herein, the term "module" may refer to, be a part of, or include: memory (shared, dedicated, or group) for executing one or more software or firmware programs, an Application Specific Integrated Circuit (ASIC), an electronic circuit and/or processor (shared, dedicated, or group), a combinational logic circuit, and/or other suitable components that provide the described functionality.
In the drawings, some features of the structures or methods may be shown in a particular arrangement and/or order. However, it should be understood that such specific arrangement and/or ordering is not required. Rather, in some embodiments, the features may be described in a manner and/or order different from that shown in the illustrative figures. Additionally, the inclusion of a structural or methodical feature in a particular figure does not imply that all embodiments need to include such feature, and in some embodiments may not include such feature, or may be combined with other features.
While the embodiments of the present application have been described in detail with reference to the accompanying drawings, the application of the present application is not limited to the various applications mentioned in the embodiments of the present application, and various structures and modifications can be easily implemented with reference to the present application to achieve various advantageous effects mentioned herein. Variations that do not depart from the gist of the disclosure are intended to be within the scope of the disclosure.

Claims (8)

1. A node parsing method of an XML file is used for electronic equipment, and is characterized by comprising the following steps:
acquiring first XML node data in the XML file;
determining an instruction type of an instruction in the first XML node data;
analyzing the parameters of the instruction by adopting an analysis mode corresponding to the instruction type of the instruction, wherein the analysis mode comprises the following steps:
analyzing parameter values of parameters of the instruction based on the first XML node data, wherein the type of the instruction included in the first XML node data is a first instruction type;
analyzing parameter values of parameters corresponding to the instructions included in the first XML node data based on the first XML node data and second XML node data adjacent to the first XML node data in the XML file, wherein the type of the instructions in the second XML node data is the first instruction type;
wherein the first XML node data including the instruction of the first instruction type has parameter values of all parameters corresponding to the instruction in an instruction parameter list, and
the first XML node data including an instruction of the second instruction type has a parameter value of a first parameter corresponding to the instruction in the instruction parameter list, and the parameter value of a second parameter corresponding to the instruction in the instruction parameter list is stored in at least one of the second XML node data adjacent to the first XML node data including an instruction of the second instruction type.
2. The method of claim 1, wherein the first XML node data and the second XML node data are data located between a start tag and a corresponding end tag of an XML node in the XML file.
3. The method of claim 2, wherein the first instruction type and the second instruction type are determined from an instruction name of the instruction.
4. The method according to claim 2, wherein the second XML node data adjacent to the first XML node data is an XML node arranged before the first XML node data in the XML file.
5. The method according to claim 1, wherein the instruction parameter list is used for storing a correspondence between an instruction name of the instruction and each parameter of the instruction, and the instruction parameter list is stored in a storage area of the electronic device.
6. The method of claim 3, further comprising:
and determining the instruction execution sequence corresponding to the instruction according to the instruction name corresponding to the instruction.
7. A readable medium having stored thereon instructions which, when executed on an electronic device, cause the electronic device to execute the node parsing method of XML file according to any one of claims 1 to 6.
8. An electronic device, characterized in that the electronic device comprises:
a memory for storing instructions for execution by one or more processors of the electronic device, an
A processor, which is one of processors of an electronic device, for executing the node parsing method of the XML file according to any one of claims 1 to 6.
CN202210061926.6A 2022-01-19 2022-01-19 Electronic device, and node parsing method and medium for XML file thereof Active CN114090523B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202210061926.6A CN114090523B (en) 2022-01-19 2022-01-19 Electronic device, and node parsing method and medium for XML file thereof

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202210061926.6A CN114090523B (en) 2022-01-19 2022-01-19 Electronic device, and node parsing method and medium for XML file thereof

Publications (2)

Publication Number Publication Date
CN114090523A CN114090523A (en) 2022-02-25
CN114090523B true CN114090523B (en) 2022-06-07

Family

ID=80308664

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202210061926.6A Active CN114090523B (en) 2022-01-19 2022-01-19 Electronic device, and node parsing method and medium for XML file thereof

Country Status (1)

Country Link
CN (1) CN114090523B (en)

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101159760A (en) * 2007-10-24 2008-04-09 中兴通讯股份有限公司 Method and system for implementing communication protocol based on XML data interchange file
US7730467B1 (en) * 2001-06-28 2010-06-01 Microsoft Corporation Object-oriented pull model XML parser
CN104778258A (en) * 2015-04-21 2015-07-15 华中科技大学 Data extraction method oriented to protocol dataflow
CN109669606A (en) * 2018-12-19 2019-04-23 西门子传感器与通讯有限公司 Device parameter configuration method and its system, computer readable storage medium
CN111813754A (en) * 2020-06-24 2020-10-23 深圳市元征科技股份有限公司 File processing method, file processing device, diagnostic equipment and electronic equipment
CN113887173A (en) * 2021-10-20 2022-01-04 中国电子科技集团公司第三十研究所 XML-based protocol dynamic packaging and analyzing method

Family Cites Families (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20100321715A1 (en) * 2009-06-22 2010-12-23 Williams David A Methods and structure for preserving node order when storing xml data in a key-value data structure
US9009172B2 (en) * 2012-03-09 2015-04-14 Infosys Limited Methods, systems and computer readable media for comparing XML documents
CN105095348B (en) * 2015-06-09 2019-03-26 北京织星科技有限公司 A method of passing through XML dynamic configuration website

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US7730467B1 (en) * 2001-06-28 2010-06-01 Microsoft Corporation Object-oriented pull model XML parser
CN101159760A (en) * 2007-10-24 2008-04-09 中兴通讯股份有限公司 Method and system for implementing communication protocol based on XML data interchange file
CN104778258A (en) * 2015-04-21 2015-07-15 华中科技大学 Data extraction method oriented to protocol dataflow
CN109669606A (en) * 2018-12-19 2019-04-23 西门子传感器与通讯有限公司 Device parameter configuration method and its system, computer readable storage medium
CN111813754A (en) * 2020-06-24 2020-10-23 深圳市元征科技股份有限公司 File processing method, file processing device, diagnostic equipment and electronic equipment
CN113887173A (en) * 2021-10-20 2022-01-04 中国电子科技集团公司第三十研究所 XML-based protocol dynamic packaging and analyzing method

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
基于Windows的跨进程共享变量池设计;白曦等;《仪器仪表用户》;20110208(第01期);第19-22页 *

Also Published As

Publication number Publication date
CN114090523A (en) 2022-02-25

Similar Documents

Publication Publication Date Title
CN108958736B (en) Page generation method and device, electronic equipment and computer readable medium
CN109992498B (en) Test case generation method and system and computer system
US9547577B2 (en) Method and apparatus for determining processor performance
CN101587441A (en) Apparatus, method, and system of assisting software development
CN111858371A (en) Software testing method, system, storage medium and computer equipment
JP6440895B2 (en) Software analysis apparatus and software analysis method
CN116841536B (en) Component reference relation reconstruction method, device, system and storage medium
CN113018870A (en) Data processing method and device and computer readable storage medium
CN110888810A (en) Method and device for automatic identification and marking, computer equipment and storage medium
CN111078276B (en) Application redundant resource processing method, device, equipment and storage medium
CN110532559B (en) Rule processing method and device
CN112199261A (en) Application program performance analysis method and device and electronic equipment
CN112926008A (en) Method and device for generating form page, electronic equipment and storage medium
CN114090523B (en) Electronic device, and node parsing method and medium for XML file thereof
CN113760242A (en) Data processing method, device, server and medium
CN115543324B (en) Method, device, equipment and medium for generating interactive interface
CN114092590B (en) Electronic device and evaluation method and medium for image rendering performance of electronic device
US20150121051A1 (en) Kernel functionality checker
CN111460235A (en) Atlas data processing method, device, equipment and storage medium
CN116414689A (en) Interface parameter verification method and system based on reflection mechanism
CN114168456A (en) Front-end performance automatic testing method based on 3D-GIS
CN110045961B (en) Management method and management platform of business rules
CN113885996A (en) User interface generation method and device
CN111444392A (en) Method, device and equipment for accessing cave library
CN110750569A (en) Data extraction method, device, equipment 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
TR01 Transfer of patent right
TR01 Transfer of patent right

Effective date of registration: 20230913

Address after: 201306 building C, No. 888, Huanhu West 2nd Road, Lingang New Area, Pudong New Area, Shanghai

Patentee after: Shanghai Glory Smart Technology Development Co.,Ltd.

Address before: Unit 3401, unit a, building 6, Shenye Zhongcheng, No. 8089, Hongli West Road, Donghai community, Xiangmihu street, Futian District, Shenzhen, Guangdong 518040

Patentee before: Honor Device Co.,Ltd.