Extensible Markup Language (XML) document encoding / decoding methods, storage media, and computer program products

By decoupling the XML document encoding/decoding logic from business data through the configuration management module and the depth-first search algorithm, the problem of high maintenance costs for XML document encoding/decoding is solved, and efficient encoding/decoding processing and flexible system adaptation are achieved.

CN122491206APending Publication Date: 2026-07-31CHINA MERCHANTS BANK
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
CHINA MERCHANTS BANK
Filing Date
2026-05-29
Publication Date
2026-07-31

AI Technical Summary

Technical Problem

In existing technologies, XML document encoding and decoding have high maintenance costs, low efficiency, are difficult to evolve independently, and the encoding and decoding modules are heavily coupled with business logic.

Method used

The configuration management module loads configuration objects, decoupling the core encoding/decoding logic from the business data structure. A depth-first search algorithm is used to extract node data and fill the digest signature string synchronously during the decoding stage, and to generate XML document elements during the encoding stage, avoiding redundant I/O and computational overhead.

Benefits of technology

It significantly reduces system maintenance costs, improves the processing efficiency of XML document encoding and decoding, reduces data loss and structural distortion, and enhances the system's flexibility and scalability.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122491206A_ABST
    Figure CN122491206A_ABST
Patent Text Reader

Abstract

This application discloses an Extensible Markup Language (XML) document encoding / decoding method, storage medium, and computer program product, relating to the field of document parsing technology. The method includes: acquiring encoding and / or decoding requests sent by a client and loading a configuration object from a configuration management module; performing a depth-first search algorithm traversal on the tree model in the XML document to be decoded based on the decoding request and the configuration object to extract node data; filling the node data into a business data set and a decoding digest signature string to obtain the document decoding result; performing a depth-first search algorithm traversal on the business data to be encoded based on the encoding request and the configuration object to generate XML document elements; and filling the XML document elements into the XML document tree structure to obtain the document encoding result. Loading the configuration object reduces maintenance costs, and the depth-first search algorithm traversal improves processing efficiency.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of document parsing technology, and in particular to Extensible Markup Language (XML) document encoding and decoding methods, storage media, and computer program products. Background Technology

[0002] Extensible Markup Language (XML) is a general-purpose data exchange format. Encoding and decoding technologies for XML documents mainly include those based on standard parsing libraries and those based on dedicated encoding and decoding methods with strong business coupling. While encoding and decoding based on standard parsing libraries can accomplish basic encoding and decoding functions, it requires pre-defining business classes or mapping relationships that strictly correspond to the XML structure. This results in strong coupling between the encoding / decoding logic and business objects, leading to high maintenance costs. Dedicated encoding and decoding based on strong business coupling, due to its dependence on this coupling, makes it difficult for the encoding / decoding module to evolve independently, resulting in high system maintenance costs and low code reusability and encoding / decoding efficiency.

[0003] Therefore, how to reduce the maintenance cost of XML document encoding and decoding and improve the processing efficiency of XML document encoding and decoding has become a technical problem that this application urgently needs to solve. Summary of the Invention

[0004] The main objective of this application is to provide an Extensible Markup Language (XML) document encoding / decoding method, storage medium, and computer program product, aiming to solve the technical problem of how to reduce the maintenance cost of XML document encoding / decoding and improve the processing efficiency of XML document encoding / decoding.

[0005] To achieve the above objectives, this application proposes an Extensible Markup Language (Extreme Markup Language) document encoding / decoding method, the method comprising: Obtain the encoding and / or decoding requests sent by the client, and load the pre-parsed configuration object from the preset configuration management module; Based on the decoding request and the configuration object, a depth-first search algorithm is used to traverse the tree model in the Extensible Markup Language document to be decoded in order to extract node data; The node data is filled into the corresponding business data set and the decoding digest signature string to obtain the document decoding result; Based on the encoding request and the configuration object, a depth-first search algorithm is used to traverse the business data to be encoded in order to generate Extensible Markup Language document elements; The Extensible Markup Language (XML) document elements are populated into a pre-built XML document tree structure to obtain the document encoding result.

[0006] In one embodiment, the step of obtaining the encoding request and / or decoding request sent by the client and loading the pre-parsed configuration object from the preset configuration management module includes: Obtain the encoding and / or decoding requests sent by the client; The configuration management module loads the Extensible Markup Language document paths and field mapping rules from the client; Based on the encoding request and / or the decoding request, the Extensible Markup Language document path and the field mapping rules are passed to the configuration object in the preset configuration management module.

[0007] In one embodiment, the configuration object includes a decoding service object, and the step of performing a depth-first search algorithm traversal on the tree model in the Extensible Markup Language document to be decoded based on the decoding request and the configuration object to extract node data includes: Based on the decoding request, the Extensible Markup Language document to be decoded is converted into a tree model; Extract the root node of the tree model from the decoding service object; A depth-first search algorithm is used to traverse the tree model from the root node to extract node data.

[0008] In one embodiment, the step of traversing the tree model from the root node using a depth-first search algorithm to extract node data includes: A depth-first search algorithm is used to traverse the tree model from the root node and determine the node type of each tree model node. Given that the node type of the tree model node is a multi-packet node, extract the first result set under the current multi-packet node from the tree model, and traverse the first result set to extract node data for each sub-packet in the result set. Given that the node type of the tree model node is a leaf node, extract the node data corresponding to the current tree model node from the tree model; Given that the node type of the tree model node is a nested node, a depth-first search recursive traversal is performed with the current tree model node as the root to extract the node data of the current tree model node.

[0009] In one embodiment, the step of filling the node data into the corresponding business data set and the decoding digest signature string to obtain the document decoding result includes: Based on the traversal order of the depth-first search algorithm and the field mapping rules in the decoding service object, the node data is filled into a preset business data set; The node data is formatted into a decoded digest signature string according to the preset signature node rules, and the decoded digest signature string is appended to the signature buffer; The business data set and the decoding digest signature string are used as the document decoding result.

[0010] In one embodiment, the configuration object includes an encoding service object, and the step of performing a depth-first search algorithm traversal on the business data to be encoded based on the encoding request and the configuration object to generate Extensible Markup Language document elements includes: Based on the encoding request, the business data to be encoded is deserialized into a tree structure representation, and an empty tree model is created; Add the root node represented by the tree structure to the empty tree model to obtain the Extensible Markup Language document tree structure; Based on the Extensible Markup Language (XML) document path in the encoding service object, a depth-first search algorithm is performed on the tree structure representation to generate XML document elements.

[0011] In one embodiment, the step of performing a depth-first search algorithm traversal on the tree structure representation based on the Extensible Markup Language (XML) document path in the encoding service object to generate XML document elements includes: Based on the Extensible Markup Language document path in the encoding service object, a depth-first search traversal is performed on the tree structure representation to determine the node type of each tree structure representation node in the tree structure representation; Given that the node type of the tree structure representation node is a multi-package node, extract the second result set under the current multi-package node from the tree structure representation, and traverse the second result set to generate Extensible Markup Language document elements corresponding to each sub-package in the second result set; Given that the node type of the node in the tree structure representation is a leaf node, extract the Extensible Markup Language document element corresponding to the current tree structure representation node from the tree structure representation; Given that the node type of the tree structure representation node is a nested node, a depth-first search recursive traversal is performed with the current tree structure representation node as the root to generate the Extensible Markup Language document element of the current tree structure representation node.

[0012] In one embodiment, the document elements of the Extensible Markup Language (XML) document are populated into a pre-built XML document tree structure to obtain the document encoding result; Based on the hierarchical relationship of the nodes in the current tree structure representation, the Extensible Markup Language (XML) document elements are populated into the pre-built XML document tree structure. The Extensible Markup Language document elements are appended to the encoded digest signature string according to the preset signature node rules; The Extensible Markup Language (XML) document tree structure is serialized into an XML document, and the document encoding result is obtained based on the XML document and the encoded digest signature string.

[0013] In addition, to achieve the above objectives, this application also proposes a storage medium, which is a computer-readable storage medium, on which a computer program is stored, and which, when executed by a processor, implements the steps of the Extensible Markup Language document encoding and decoding method described above.

[0014] In addition, to achieve the above objectives, this application also provides a computer program product, which includes a computer program that, when executed by a processor, implements the steps of the Extensible Markup Language document encoding / decoding method described above.

[0015] One or more technical solutions proposed in this application have at least the following technical effects: First, by loading configuration objects through a pre-defined configuration management module, the core encoding / decoding logic is decoupled from the specific business data structure. This allows for modifications to the external configuration only, without altering the encoding / decoding algorithm itself, when the XML format or business requirements change, significantly reducing system maintenance costs. Furthermore, during the decoding phase, a depth-first search traversal is performed on the tree model of the XML to be decoded based on the configuration object. Node data extraction and digest signature string filling are completed simultaneously in a single traversal, avoiding redundant I / O and computational overhead caused by multiple traversals or separate signature processing steps in traditional solutions. Second, during the encoding phase, a depth-first search algorithm traversal is performed on the business data to be encoded based on the configuration object, generating XML document elements and filling them into the XML tree structure, preventing data loss and structural distortion. In summary, this application reduces maintenance costs caused by business coupling by loading configuration objects through a configuration management module and improves overall processing efficiency through a depth-first search algorithm traversal mechanism. Attached Figure Description

[0016] The accompanying drawings, which are incorporated in and form part of this specification, illustrate embodiments consistent with this application and, together with the description, serve to explain the principles of this application.

[0017] To more clearly illustrate the technical solutions in the embodiments of this application or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, for those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0018] Figure 1 This is a flowchart illustrating the first embodiment of the Extensible Markup Language document encoding / decoding method of this application; Figure 2 This is a flowchart illustrating the third embodiment of the Extensible Markup Language document encoding / decoding method of this application; Figure 3 This is a schematic diagram of the decoding process provided in this application; Figure 4 A schematic diagram of the coding process provided in this application; Figure 5 This is a schematic diagram of the module structure of the Extensible Markup Language document encoding / decoding device according to an embodiment of this application; Figure 6 This is a schematic diagram of the device structure of the hardware operating environment involved in the Extensible Markup Language document encoding and decoding method in this application embodiment.

[0019] The purpose, features, and advantages of this application will be further explained in conjunction with the embodiments and with reference to the accompanying drawings. Detailed Implementation

[0020] It should be understood that the specific embodiments described herein are merely illustrative of the technical solutions of this application and are not intended to limit this application.

[0021] To better understand the technical solution of this application, a detailed description will be provided below in conjunction with the accompanying drawings and specific implementation methods.

[0022] The main solution of this application embodiment is as follows: Obtain the encoding request and / or decoding request sent by the client, and load the pre-parsed configuration object from the preset configuration management module; perform a depth-first search algorithm traversal on the tree model in the document to be decoded (based on the decoding request and the configuration object) to extract node data; fill the node data into the corresponding business data set and decoding digest signature string to obtain the document decoding result; perform a depth-first search algorithm traversal on the business data to be encoded (based on the encoding request and the configuration object) to generate Extensible Markup Language (XML) document elements; fill the XML document elements into the pre-built XML document tree structure to obtain the document encoding result.

[0023] In this embodiment, for ease of description, the Extensible Markup Language document encoding and decoding system will be used as the execution subject for the following description.

[0024] This embodiment takes into account that: since Extensible Markup Language (XML) is a general data exchange format, encoding and decoding technologies for XML documents mainly include encoding and decoding based on standard parsing libraries and dedicated encoding and decoding based on strong business coupling. While encoding and decoding based on standard parsing libraries can complete basic encoding and decoding functions, it requires pre-defining business classes or mapping relationships that strictly correspond to the XML structure. There is a strong coupling between the encoding / decoding logic and business objects, resulting in high maintenance costs. Dedicated encoding and decoding based on strong business coupling, due to its dependence on the coupling relationship with the business, makes it difficult for the encoding / decoding module to evolve independently, leading to high system maintenance costs and low code reusability and encoding / decoding efficiency.

[0025] Therefore, this application provides a solution. First, by loading a configuration object through a pre-defined configuration management module, the core encoding / decoding logic is decoupled from the specific business data structure. This allows changes in XML format or business requirements to be made only by modifying the external configuration, without altering the encoding / decoding algorithm itself, thus significantly reducing system maintenance costs. Furthermore, during the decoding phase, a depth-first search traversal is performed on the tree model of the XML to be decoded based on the configuration object. Node data extraction and digest signature string filling are completed simultaneously in a single traversal, avoiding redundant I / O and computational overhead caused by multiple traversals or separate signature processing steps in traditional solutions. Second, during the encoding phase, a depth-first search algorithm traversal is performed on the business data to be encoded based on the configuration object, generating XML document elements and filling them into the XML tree structure, preventing data loss and structural distortion. In summary, this application reduces maintenance costs caused by business coupling by loading configuration objects through a configuration management module and improves overall processing efficiency through a depth-first search algorithm traversal mechanism.

[0026] It should be noted that the executing entity in this embodiment can be a computing service device with data processing, network communication, and program execution functions, such as a tablet computer, personal computer, or mobile phone, or an electronic device capable of implementing the above functions, such as an Extensible Markup Language (XML) document encoding / decoding system. The following description uses an XML document encoding / decoding system as an example to illustrate this embodiment and the subsequent embodiments.

[0027] Based on this, embodiments of this application provide an Extensible Markup Language (Extreme Markup Language) document encoding / decoding method, referring to... Figure 1 , Figure 1 This is a flowchart illustrating the first embodiment of the Extensible Markup Language document encoding / decoding method of this application.

[0028] In this embodiment, the Extensible Markup Language document encoding / decoding method includes steps S10-S50: Step S10: Obtain the encoding request and / or decoding request sent by the client, and load the pre-parsed configuration object from the preset configuration management module; The configuration management module refers to the functional unit within the system responsible for loading, parsing, and managing external configuration files (such as JSON, YAML, or XML format configuration files).

[0029] A configuration object is an in-memory data structure generated by the configuration management module based on an external configuration file. It contains the client's preset XML path and business field mapping relationship, node types (such as ordinary leaf nodes, repeatable leaf nodes, nested nodes, and multi-package nodes), and signature node path rules.

[0030] Specifically, the system first receives an encoding or decoding request from the client, which may carry the identifier of the data to be processed or the raw data stream. Then, the system calls the interface of the configuration management module to read the configuration file from a pre-configured storage location (such as the local file system, configuration center, or database) and deserializes it into a configuration object.

[0031] In one possible implementation, the configuration object can be further divided into a decoding configuration object and an encoding configuration object, which are used to guide the decoding and encoding processes, respectively. Alternatively, a unified configuration object can be used, with different field identifiers distinguishing the mapping rules required for decoding and encoding. In another possible implementation, the configuration management module supports a hot-reloading mechanism, so that when the external configuration file changes, the configuration object in memory can be automatically updated without restarting the system, thereby further improving the system's dynamic adaptability.

[0032] Step S20: Based on the decoding request and the configuration object, perform a depth-first search algorithm to traverse the tree model in the Extensible Markup Language document to be decoded in order to extract node data; A tree model is a model of Extensible Markup Language (XML) documents that is parsed into an in-memory document object tree, where each node corresponds to an element, attribute, or text content in the XML document.

[0033] Depth-first search traversal refers to a traversal method that starts from the root node of a tree model, visits the deepest leaf node along a branch, then backtracks to the previous level node and continues to visit the next branch, until all nodes have been visited once.

[0034] Specifically, based on the Extensible Markup Language (XML) document string to be decoded carried in the decoding request, the system uses a document parser (such as dom4j) to parse the string into an in-memory tree model. Then, the system obtains the XML path of the root node from the configuration object and locates the starting node in the tree model. Subsequently, the system starts a depth-first search algorithm: for each node visited, the system determines the next operation based on the node type corresponding to the node path in the configuration object (which is predefined by the configuration object).

[0035] In one possible implementation, the system maintains a stack or recursive call stack to explicitly control the traversal order, thus preventing stack overflow due to excessive recursion depth. In another possible implementation, for large XML documents, the system can employ an iterative depth-first search, using a manually managed stack structure instead of recursion.

[0036] Step S30: Fill the node data into the corresponding business data set and decoding digest signature string to obtain the document decoding result; A business data collection refers to a container that stores decoded field values. It can be a key-value pair mapping (such as a Map structure) or a more general tree structure (such as a JsonNode object).

[0037] The decoded digest signature string refers to the string buffer content formed by formatting and concatenating key data extracted from specified nodes in traversal order according to the preset signature node rules in the configuration object during the depth-first traversal.

[0038] Specifically, before starting the traversal, the system first creates an empty business data collection object (e.g., an empty Map instance) and an empty string buffer to accumulate signature strings. Whenever a node data is extracted, the system determines the business field name corresponding to the node data according to the field mapping rules defined in the configuration object, and then stores the data in the business data collection in the form of key-value pairs, where the key is the business field name and the value is the extracted data.

[0039] Furthermore, the system checks whether the current node path is in the signature node rules declared by the configuration object: if so, the string representation of the node data is appended to the string buffer in the current order of depth-first traversal.

[0040] Step S40: Based on the encoding request and the configuration object, perform a depth-first search algorithm to traverse the business data to be encoded in order to generate Extensible Markup Language document elements; Business data to be encoded refers to structured data provided by the client that needs to be converted into an XML document.

[0041] Extensible Markup Language (XML) document elements refer to the basic units in an XML document, including start tags, end tags, text content, attributes, and the nesting relationships between elements.

[0042] Specifically, the system first obtains the business data to be encoded (such as a Map or JSON string) from the client based on the encoding request. The system then deserializes this business data into a tree-structured representation in memory, for example, by converting the JSON string into a JsonNode object using the Jackson library.

[0043] Furthermore, the system creates an empty XML document tree structure (e.g., an empty Document object created using dom4j). Then, based on the root node path defined in the configuration object, the system creates a root element in the empty XML document tree. Using the tree structure representation of the business data as the traversal object, the system initiates a depth-first search algorithm: starting from the root node, it sequentially visits each node according to the mapping relationship between the XML path and the business fields defined in the configuration object, generating the corresponding Extensible Markup Language (XML) document element for each node.

[0044] Step S50: Fill the Extensible Markup Language (XML) document elements into the pre-built XML document tree structure to obtain the document encoding result.

[0045] A pre-built Extensible Markup Language (Extreme Markup Language) document tree structure refers to an empty Document object that conforms to the Document Object Model (DOM) specification and can accommodate dynamically added nodes in a tree-like manner.

[0046] Specifically, during the depth-first search traversal, for each XML element generated, the system immediately locates the XML element that should be the parent node based on the hierarchical relationship of the current node in the business data tree structure and the XML path defined in the configuration object (by maintaining a current path stack or passing a parent node reference in recursive calls), and then calls the parent node's add child element method (such as the addElement method of Element in dom4j) to mount the element onto the tree.

[0047] Furthermore, the system outputs the encoded digest signature string generated synchronously during the traversal process (the generation method of this signature string is symmetrical to the signature string generation in the decoding stage). The system encapsulates the XML string and the encoded digest signature string together into a document encoding result and returns it to the client.

[0048] This embodiment provides an Extensible Markup Language (XML) document encoding / decoding method. First, a configuration object is loaded through a pre-defined configuration management module, decoupling the core encoding / decoding logic from the specific business data structure. This allows changes in XML format or business requirements to be made only by modifying the external configuration, without altering the encoding / decoding algorithm itself, significantly reducing system maintenance costs. Furthermore, during the decoding phase, a depth-first search traversal is performed on the tree model of the XML to be decoded based on the configuration object. Node data extraction and digest signature string filling are completed simultaneously in a single traversal, avoiding redundant I / O and computational overhead caused by multiple traversals or separate signature processing steps in traditional solutions. Second, during the encoding phase, a depth-first search algorithm traversal is performed on the business data to be encoded based on the configuration object, generating XML document elements and filling them into the XML tree structure, preventing data loss and structural distortion. In summary, this application reduces maintenance costs caused by business coupling by loading a configuration object through a configuration management module and improves overall processing efficiency through a depth-first search algorithm traversal mechanism.

[0049] Based on the first embodiment of this application, a second embodiment of this application is proposed. In the second embodiment of this application, content that is the same as or similar to that in the first embodiment described above can be referred to the above description and will not be repeated hereafter.

[0050] In this embodiment, step S10, which involves obtaining the encoding request and / or decoding request sent by the client and loading the pre-parsed configuration object from the preset configuration management module, may include steps S11 to S13: Step S11: Obtain the encoding request and / or decoding request sent by the client; A client refers to the upper-layer business system, application, or service caller that initiates the encoding and decoding operation of an Extensible Markup Language document.

[0051] An encoding request refers to a command or message from a client that asks the system to convert internal business data into an Extensible Markup Language (Extensible Markup Language) document. This request typically carries the business data to be encoded or the storage identifier of the data.

[0052] A decoding request is a command or message from a client that asks the system to parse an Extensible Markup Language (XML) document into a set of business data. This request typically carries the XML document string to be decoded or the document's access path.

[0053] Specifically, the system exposes a unified application programming interface (API), which receives a request object containing a request type field and the corresponding data payload. The system first parses the request object and extracts the request type identifier. In one possible implementation, the client and the system communicate using the Hypertext Transfer Protocol (HTTP), with encoded and decoded requests mapped to different Uniform Resource Locator (URL) endpoints. The system distinguishes the operation type based on the URL path of the requested endpoint.

[0054] Step S12: The configuration management module loads the Extensible Markup Language document path and field mapping rules from the client; An Extensible Markup Language (XML) document path refers to a string that locates the position of an element or attribute in an XML document. It is usually expressed in the style of XPath expressions, such as " / root node / child node / target node".

[0055] Field mapping rules refer to a set of rules that establish a correspondence between XML document paths and client-side business field names.

[0056] Specifically, the configuration management module loads Extensible Markup Language document paths and field mapping rules from the configuration source specified by the client. The client can provide the location of the configuration source to the configuration management module in a variety of ways: for example, by carrying the configuration file name or configuration identifier in the request, or by pre-registering the configuration source when the system starts.

[0057] Step S13: Based on the encoding request and / or the decoding request, the Extensible Markup Language document path and the field mapping rule are passed to the configuration object in the preset configuration management module.

[0058] A configuration object is an in-memory data structure generated by the configuration management module based on the loaded Extensible Markup Language (EXPLAIN) document paths and field mapping rules, which is directly used by the encoding / decoding execution module. This configuration object typically includes, but is not limited to, the following fields: root node path, node type mapping table, field mapping table, and signature node path set.

[0059] Specifically, after loading the Extensible Markup Language (XML) document path and field mapping rules, the system's configuration management module instantiates a configuration object (such as an instance of the DecodeConfig or EncodeConfig class) and populates all the XML document path, field mapping rules, node types, signature rules, etc., into the various properties of the configuration object.

[0060] Furthermore, the system obtains the corresponding encoding / decoding service object (such as an instance of IDecodeService or IEncodeService) based on the determined request type (encoding request or decoding request).

[0061] Understandably, for requests that involve both encoding and decoding (i.e., scenarios that require both decoding and encoding), the system will create decoding configuration objects and encoding configuration objects separately, and pass in the corresponding decoding service objects and encoding service objects respectively.

[0062] In this embodiment, the corresponding process is triggered by obtaining the request type. The configuration management module independently loads the XML path and field mapping rules and encapsulates them into a configuration object, which is then passed to the encoding / decoding service. This allows the core encoding / decoding logic to be completely decoupled from specific business fields and XML structures. When business rules change, only the external configuration needs to be updated without modifying the code, thereby significantly reducing maintenance costs. At the same time, it supports concurrent processing of multiple configurations, improving the system's flexibility and scalability.

[0063] Based on the first and / or second embodiments of this application, a third embodiment of this application is proposed. In the third embodiment of this application, content that is the same as or similar to the first and / or second embodiments described above can be referred to the above description and will not be repeated hereafter.

[0064] Based on this, please refer to Figure 2 , Figure 2 The flowchart provided for the third embodiment of this application is as follows: Figure 2 As shown, step S20, which involves performing a depth-first search algorithm to extract node data from the tree model in the Extensible Markup Language document to be decoded based on the decoding request and the configuration object, may include steps S21 to S23: Step S21: Based on the decoding request, convert the Extensible Markup Language document to be decoded into a tree model; Upon receiving a decoding request, the system first extracts the XML string to be decoded from the request. The system then calls a document parser (such as the `DocumentHelper.parseText(String xmlText)` method provided by dom4j) to parse the string. The parser checks the validity of the XML format (e.g., whether tags are closed, whether attribute values ​​are enclosed in quotes, etc.), and throws a parsing exception if the format is invalid. After successful validation, the parser uses the root element of the XML document as the root node of the tree and creates corresponding node objects for each child element, text node, comment, etc., establishing parent-child relationships according to the document order to obtain a tree model.

[0065] In one possible implementation, for very large XML documents (e.g., exceeding 100 MB), the system can adopt a strategy that combines streaming parsing with partial tree building, keeping only the subtree that needs to be processed in memory to reduce memory usage.

[0066] Step S22: Extract the root node of the tree model from the decoding service object; The decoding service object is a class instance that implements the decoding interface (such as IDecodeService). This object encapsulates a configuration object (including the root node path, field mapping rules, node type, etc.) and other resources required to perform decoding.

[0067] The root node of the tree model is the node object that represents the top-level element of the entire XML document (i.e., the root element of the Document object).

[0068] Specifically, during initialization, the decoding service object obtains the preset root node path from the configuration object. The system calls the getRootNode(Document doc) method provided by the decoding service object. This method takes the generated tree model Document object as input and locates the corresponding root element node in the Document according to the internally configured root node path through XPath expressions or node traversal.

[0069] In one possible implementation, the configuration object does not directly store the root node path, but instead stores a root node identifier. The decoding service object uses this identifier to look up the actual node name in a predefined namespace mapping table.

[0070] In another possible implementation, if the root node path is not explicitly specified in the configuration object, the decoding service object defaults to using the root element of the Document object as the starting root node for traversal. The extracted root node object will be used as the initial input parameter for the depth-first search algorithm.

[0071] Step S23: Use a depth-first search algorithm to traverse the tree model from the root node to extract node data.

[0072] The system starts with the root node of a tree model and uses recursion or an explicit stack to control the traversal order. For each node visited, the system extracts node data based on the node type corresponding to the path specified in the configuration object.

[0073] In this embodiment, by converting the XML document into a tree model, extracting the root node, and performing a depth-first search traversal, a faithful access to the complete structure of the XML document is achieved. This process ensures that nested nodes and repeating elements of any depth can be extracted in an orderly manner, avoiding node omissions and hierarchical errors. It also provides a consistent traversal order for subsequent synchronous generation of the signature string, thereby improving the accuracy, completeness, and processing efficiency of decoding.

[0074] Furthermore, based on this embodiment, in a feasible implementation, step S23, which involves using a depth-first search algorithm to traverse the tree model from the root node to extract node data, may include steps S231-S234: Step S231: Use a depth-first search algorithm to traverse the tree model from the root node and determine the node type of each tree model node. The node type refers to the category identifier predefined for the node path in the configuration object, including but not limited to: ordinary leaf node (NORMAL_LEAF), repeatable leaf node (LIST_LEAF), nested node (NEST_BRANCH, which is further subdivided into nested nodes declared in the parent object and nested nodes declared in the child object), and multi-package node (MULTI_BRANCH).

[0075] During traversal, the system searches the configuration object for the corresponding node type enumeration value based on the XPath path of the current node in the tree model. If no match is found, the system can either use the default type (such as a regular leaf node) or throw a configuration missing exception.

[0076] Step S232: Under the condition that the node type of the tree model node is a multi-packet node, extract the first result set under the current multi-packet node from the tree model, and traverse the first result set to extract node data for each sub-packet in the result set. A multi-package node refers to a parent node that contains multiple child nodes with the same structure and which can repeat. The first result set refers to the set of all child nodes under the current multi-package node that conform to a specific sub-package rule. A sub-package refers to each independent, structurally complete, and repeating unit in the result set.

[0077] The system first determines that the current node is a multi-package node. It then retrieves a list of all direct child nodes of the current node (or selects a path based on the sub-packages defined in the configuration) as the first result set. For each child node (i.e., each sub-package) in the first result set, the system uses that sub-package as the local root node, extracts the data from all its leaf nodes, and organizes this data sequentially into a data unit (e.g., a Map or JsonNode object) corresponding to that sub-package. After all sub-packages have been processed, the system places all data units into a list, which serves as the business data corresponding to that multi-package node.

[0078] Step S233: Under the condition that the node type of the tree model node is a leaf node, extract the node data corresponding to the current tree model node from the tree model; A leaf node is a node in a tree model that no longer contains other element child nodes (but may contain text content), corresponding to a tag in an XML document that does not contain nested child elements.

[0079] After determining whether the current node is a regular leaf node (NORMAL_LEAF) or a repeatable leaf node (LIST_LEAF), the system further extracts data from the current node object: if the node contains text content, the `getText()` method of the node object is called to obtain the text string; if the node contains attributes and the configuration specifies that the attribute value should be extracted, the `attributeValue(attrName)` method is called to obtain the attribute value. For repeatable leaf nodes (multiple leaf nodes with the same name under the same parent node, such as multiple...),... <item>The system treats this as a list, extracts the value of each leaf node sequentially, and places it into an array. The extracted node data is stored in the data collector of the current traversal context, and this data is also passed to the signature module.

[0080] Step S234: Under the condition that the node type of the tree model node is a nested node, perform a depth-first search recursive traversal with the current tree model node as the root to extract the node data of the current tree model node.

[0081] Nested nodes are element nodes that contain other child element nodes but are not multi-package nodes. Their internal structure may include multiple levels of child nodes and leaf nodes.

[0082] Specifically, the system first determines that the current node is a nested node, sets the current node as the new traversal starting point, and recursively calls the depth-first search function. During the recursive call, the system re-executes the node type determination, child node traversal, and other logic until all descendant nodes under the nested node have been processed. After the recursion returns, the system continues processing the current node's next sibling node (if any).

[0083] In this implementation, multi-packet, leaf, and nested nodes are dynamically distinguished by node type, enabling depth-first search to accurately handle duplicate sub-packets, basic data, and deeply nested structures. This mechanism ensures that all types of nodes are extracted according to correct logic, avoiding data omissions or disordered order, while maintaining a consistent traversal order with the encoding stage, providing a reliable guarantee for achieving high-fidelity decoding and synchronous signature.

[0084] Furthermore, based on this embodiment, in a feasible implementation, step S30, which involves filling the node data into the corresponding business data set and the decoding digest signature string to obtain the document decoding result, may include steps S31 to S33: Step S31: Based on the traversal order of the depth-first search algorithm and the field mapping rules in the decoding service object, fill the node data into the preset business data set; Field mapping rules refer to the pre-configured mapping table in the decoding service object that associates XML paths with business field names; the pre-set business data set refers to the container created by the system before decoding begins to store the decoding results, which is usually a key-value pair mapping (such as Map) or a tree structure (such as JsonNode object).

[0085] Specifically, during the depth-first search process, the system records the complete path of the current node in the tree model each time it extracts data from a leaf node. The system then calls the field mapping rules maintained in the decoding service object to find the corresponding business field name based on this path. If a mapping is found, the system stores the extracted node data in a preset business data set, using the business field name as the key and the node data as the value. For repeatable leaf nodes (such as lists), the system creates an array or list structure and appends data sequentially according to the traversal order.

[0086] Step S32: Format the node data into a decoded digest signature string according to the preset signature node rules, and append the decoded digest signature string to the signature buffer; Signature node rules refer to a set of rules pre-loaded by the configuration management module that indicate which XML paths' node data needs to be included in the digest signature string.

[0087] The decoded digest signature string refers to the string buffer content composed of multiple node data concatenated in traversal order.

[0088] A signature buffer is an extensible string object allocated in memory for accumulating signature strings.

[0089] Specifically, before starting the depth-first search, the system creates an empty signature buffer. During the depth-first search traversal, whenever the system extracts node data, it first queries the preset signature node rules based on the current node's XML path to determine if the path is in the signature node set. If it is, the system formats the node data. The formatted string is appended to the signature buffer. For sub-packages under multi-package nodes, the system appends the data of the signature nodes within each sub-package in the order of sub-package processing, thus ensuring that the signature string reflects the data sequence of the entire document. After the traversal is complete, the string in the signature buffer is the decoded digest signature string.

[0090] Step S33: Use the business data set and the decoding digest signature string as the document decoding result.

[0091] The document decoding result refers to a wrapper object that contains at least two properties: a collection of business data (e.g., a Map or JsonNode object) and a decoding digest signature string (e.g., a String type). This result object can be returned to the client via serialization (e.g., JSON format).

[0092] Specifically, after completing the entire depth-first search traversal, business data filling, and signature string appending, the system creates a result object instance (e.g., a DecodeResult class). The constructor of this instance receives the business data set and the current contents of the signature buffer as parameters. The system stores the business data set and signature string into the corresponding fields of the result object, respectively. Then, the system returns the result object to the caller (i.e., the client or the upper-level business module).

[0093] After receiving the document decoding result, the client can extract the business data set for business logic processing (such as storing it in the database or displaying it on the interface), and at the same time pass the decoding digest signature string to the security module for signature verification to confirm that the XML document has not been tampered with during transmission.

[0094] For example, to help understand the implementation flow of the Extensible Markup Language document encoding / decoding method obtained by combining the first and / or second embodiments described above, please refer to... Figure 3 , Figure 3 The decoding process diagram provided in this application is as follows: Figure 3 As shown, the client passes the preset XML path, field mapping rules and other configuration information to the DecodeConfig configuration object. The system obtains the IDecodeService decoding service object through the configuration object and calls its decode() method to start decoding.

[0095] Furthermore, the system uses dom4j to parse the XML document to be decoded into a document tree model in memory, then extracts the preset root node path from the configuration object, and locates the starting node in the tree model.

[0096] Furthermore, the system performs a depth-first search traversal starting from the root node, determining the node type for each visited tree model node: If it is a multi-packet node, extract all child nodes under the node as the first result set, traverse each sub-packet, and repeatedly perform depth-first search for each sub-packet; If it is a nested node, a recursive depth-first traversal is performed with the current node as the root to continue processing its internal child nodes; If it is a leaf node, the text value or attribute value of the current node is directly extracted as the node data.

[0097] For the extracted leaf node data, the system fills it into the business data set (such as a JSON object) according to the field mapping rules. At the same time, it determines whether a signature is required according to the signature node rules: if the preset signature node rules require it, the node data is appended to the digest signature string buffer in traversal order.

[0098] After the traversal is complete, the system encapsulates the business data set and the signature string into a DecodeRespDTO result object. The client then obtains the unpacking result and signature string in JSON format from the object for subsequent business processing and integrity verification.

[0099] Based on the above embodiments of this application, a fourth embodiment of this application is proposed. In this fourth embodiment, content that is the same as or similar to that in the above embodiments can be referred to the above description, and will not be repeated hereafter.

[0100] In this embodiment, step S40, which involves performing a depth-first search algorithm traversal on the business data to be encoded based on the encoding request and the configuration object to generate Extensible Markup Language document elements, may include steps S41 to S43: Step S41: Based on the encoding request, deserialize the business data to be encoded into a tree structure representation and create an empty tree model; Business data to be encoded refers to the data provided by the client in the encoding request that needs to be converted into an Extensible Markup Language document; an empty tree model refers to a document object model tree (such as a Document object in dom4j) that does not yet contain any nodes and is used to finally build an XML document.

[0101] Specifically, the system first extracts the business data to be encoded from the encoding request. If the data is a JSON string, the system calls a JSON parser (such as Jackson's ObjectMapper.readTree method) to parse it into a JsonNode tree structure. If the data is a Map or a Java object, the system recursively converts it into a tree structure representation (for example, converting each key-value pair of the Map into a node, and recursively converting the value to a Map).

[0102] Furthermore, the system creates an empty XML document object (e.g., via dom4j's DocumentHelper.createDocument() method), which currently does not contain any elements.

[0103] Step S42: Add the root node represented by the tree structure to the empty tree model to obtain the Extensible Markup Language document tree structure; The root node in a tree structure refers to the top-level node in the tree structure obtained after deserialization, such as the root object in JsonNode.

[0104] Specifically, the system creates the root element in an empty tree model (Document object) based on the root node XML element name defined in the configuration object. Further, the system associates the root node representing the tree structure of the business data with this newly created XML root element for subsequent data extraction. After the root node is added, the system obtains an XML document tree containing the root element; subsequent steps will add child elements based on this tree.

[0105] Step S43: Based on the Extensible Markup Language (XML) document path in the encoding service object, perform a depth-first search algorithm to traverse the tree structure representation to generate XML document elements.

[0106] An encoding service object refers to a class instance that implements an encoding interface (such as IEncodeService). This object internally encapsulates a configuration object (containing XML path mappings, node type definitions, etc.). An Extensible Markup Language document path refers to the path string defined in the configuration object, used to locate the corresponding XML position of each node in the business data tree structure.

[0107] Specifically, the system performs a depth-first search traversal of the tree structure representation of the business data, starting from the root node. During the traversal, the system maintains the XML path of the current node (the path from the root element to the current node). For each node visited, the system looks up the corresponding node type in the configuration object based on the path, and calls the corresponding Extensible Markup Language (XML) document element generation step according to the node type (leaf node, multi-package node, nested node).

[0108] In this embodiment, the business data to be encoded is deserialized into a tree structure and an empty XML tree is created. Then, XML elements are generated by depth-first traversal based on the configured path, achieving a high-fidelity conversion from business data to an XML document. This process ensures that any nested level and repetitive structure can be accurately reconstructed, forming a symmetrical traversal order with the decoding stage, thereby guaranteeing the reversibility of encoding and decoding and data consistency. At the same time, configuration decoupling reduces maintenance costs.

[0109] Furthermore, based on this embodiment, in a feasible implementation, step S43, which involves performing a depth-first search algorithm traversal on the tree structure representation based on the Extensible Markup Language (XML) document path in the encoding service object to generate XML document elements, may include steps S431-S434: Step S431: Based on the Extensible Markup Language document path in the encoding service object, perform a depth-first search traversal of the tree structure representation to determine the node type of each tree structure representation node in the tree structure representation; During the depth-first search traversal, for the currently accessed business data node, the system calculates its complete path string starting from the root node and calls the lookup interface of the configuration object in the coding service object to obtain a predefined node type enumeration based on the path. If the path is not explicitly defined in the configuration, the system can infer the default type based on the actual type of the business data node (such as whether it is an array or an object): if the node value is an array, it is considered a multi-package node; if the node value is an object, it is considered a nested node; otherwise, it is considered a leaf node.

[0110] Step S432: Under the condition that the node type of the tree structure representation node is a multi-package node, extract the second result set under the current multi-package node from the tree structure representation, and traverse the second result set to generate Extensible Markup Language document elements corresponding to each sub-package in the second result set. A multi-package node refers to a node in the business data tree structure that corresponds to an array or list type, and its value contains multiple elements. The second result set refers to the collection of child elements held by the current multi-package node (e.g., all elements in a JSON array). A child package refers to each independent element in the result set; each child package can be a simple value (string, number, etc.) or an object (containing multiple fields).

[0111] After determining that the current node is a multi-package node, the system retrieves the value of that node in the business data tree structure (usually an array or list) as the second result set. The system then iterates through each sub-package in the second result set. For each sub-package, the system generates the corresponding XML element group based on the sub-package XML structure defined in the configuration object (e.g., the XML element names corresponding to the sub-package, the internal leaf node mappings, etc.).

[0112] Step S433: Under the condition that the node type of the tree structure representation node is a leaf node, extract the Extensible Markup Language document element corresponding to the current tree structure representation node from the tree structure representation; Given that the node type of the tree structure representing the node is a leaf node, the system searches for the XML element name corresponding to the path of the current business data node in the tree structure from the configuration object, creates a new XML element, converts the value of the current node into a string and sets it as the text content of the element, thereby obtaining the Extensible Markup Language document element corresponding to the current tree structure representing the node.

[0113] Step S434: Under the condition that the node type of the tree structure representation node is a nested node, perform a depth-first search recursive traversal with the current tree structure representation node as the root to generate the Extensible Markup Language document element of the current tree structure representation node.

[0114] Given that the node type of the tree structure representing the node is a nested node, the system first retrieves the XML element name corresponding to the current business data node from the configuration object based on the path of the current business data node. The system creates a new XML element, and further, uses this new element as the parent element, recursively calling the depth-first search function, passing in the current business data node (as the new root) and this newly created XML element (as the current parent container). During the recursive call, the system continues to determine the type of child nodes and generate corresponding child elements, which are then added to the newly created XML element. After the recursion returns, the system returns the currently generated XML element (including all its child elements) as the Extensible Markup Language (XML) document element representing the current tree structure node.

[0115] In this implementation, the business data tree structure is differentiated by identifying multi-package, leaf, and nested node types: multi-package nodes traverse sub-packages to generate repeating elements, leaf nodes extract basic values ​​to generate XML tags, and nested nodes recursively expand deep structures. This mechanism ensures that the encoding process accurately restores the hierarchical relationship and repeating order of the XML, symmetrical to the decoding stage, providing reliable guarantees for high-fidelity data conversion and synchronous signing.

[0116] Furthermore, based on this embodiment, in a feasible implementation, step S50, which involves filling the Extensible Markup Language (XML) document elements into a pre-built XML document tree structure to obtain the document encoding result, may include steps S51 to S53: Step S51: Based on the hierarchical relationship of the nodes in the current tree structure representation, fill the Extensible Markup Language (XML) document elements into the pre-built XML document tree structure. During the depth-first search traversal, the system maintains a stack or recursive call context to record the currently processed XML parent element. When a new XML element is generated, the system determines its parent element based on the current recursion depth: if the current node is a direct child of the root node, the parent element is the root element created in step S42; if the current node is a child within a nested node, the parent element is the nested element generated in the previous level of recursion. The system calls the parent element's addElement or add method to add the newly generated element as a child node. Through layer-by-layer filling, the final document tree structure completely corresponds to the tree structure of the business data.

[0117] Step S52: Append the Extensible Markup Language document element to the encoded digest signature string according to the preset signature node rules; During the depth-first search traversal, whenever an XML element corresponding to a leaf node (or a nested node that needs to be signed according to the configuration) is generated, the system first obtains the path of the current node in the business data tree structure.

[0118] Further, the system queries the preset signature node rules to determine if the path is in the signature set. If it is, the data of that node (e.g., the text value of a leaf node) is appended to the encoded digest signature string buffer according to predetermined formatting rules (e.g., direct concatenation, adding delimiters, or "key=value" format). For sub-packets under multi-packet nodes, the system appends the data of the signature nodes within each sub-packet in the order of sub-packet traversal. The encoded digest signature string buffer uses the same string builder as the signature buffer in the decoding stage to ensure that the format of the final generated signature string is consistent.

[0119] Step S53: Serialize the Extensible Markup Language (XML) document tree structure into an XML document, and obtain the document encoding result based on the XML document and the encoded digest signature string.

[0120] After generating and populating all XML elements, the system calls the serialization method of the document tree object to output the Document object as a string. During serialization, options such as character encoding, indentation format, and empty element styles need to be handled.

[0121] The system determines the output format based on configuration or request parameters. For example, for scenarios requiring bandwidth conservation, it outputs compact, unindented XML; for scenarios requiring manual reading, it outputs formatted XML with indentation and line breaks. After serialization, the system creates a result object, sets the XML string as the `document` field of the result object, and sets the obtained encoded digest signature string as the `signature` field.

[0122] In this implementation, the complete output of the encoded result is achieved by filling XML elements into the document tree according to the hierarchical relationship, synchronously appending the signature string, and finally serializing it into an XML document. This process ensures the hierarchical correctness of the XML structure and the consistency of the element order, while generating an integrated encoded digest signature string that is symmetrical to the signature string in the decoding stage. This ensures the integrity of data exchange and the reversibility of encoding and decoding, improving processing efficiency and security.

[0123] For example, to help understand the implementation flow of the Extensible Markup Language document encoding / decoding method obtained in this embodiment in conjunction with the above embodiments, please refer to... Figure 4 , Figure 4 The coding process diagram provided for this application is as follows: Figure 4 As shown, the client passes the preset XML path, field mapping rules and other configuration information to the EncodeConfig configuration object. The system obtains the IEncodeService encoding service object through the configuration object and calls its encode() method to start encoding.

[0124] The system deserializes the client-provided business data (such as JSON strings or Maps) into an in-memory JsonNode tree structure. Further, it creates an empty Document object using dom4j as the XML document tree to be built. The root node path is obtained from the configuration object, and the corresponding root element is created in the empty Document, completing the initialization of the XML document tree structure.

[0125] Furthermore, the system performs a depth-first search traversal starting from the root node of the tree structure representation (JsonNode) of the business data. For each accessed tree structure representation node, its node type is determined based on the XML path in the encoded service object. If it is a multi-package node, extract all child elements under the node as the second result set, traverse each sub-package, and generate the corresponding XML element group for each sub-package; If it is a nested node, a recursive depth-first traversal is performed with the current node as the root to generate the XML elements corresponding to all its child nodes, and these elements are then attached to the XML parent element corresponding to the current node. If it is a leaf node, extract the value of the current node (string, number, etc.) and generate the corresponding XML element according to the configuration.

[0126] For each generated XML element, the system correctly adds it to the corresponding parent element of the pre-built XML document tree according to the hierarchical relationship of the current node in the business data tree. Furthermore, the system determines whether the current node needs to be signed according to the preset signature node rules: if it does, the node data is appended to the encoded digest signature string buffer in depth-first traversal order.

[0127] After traversal, the system serializes the completed XML document tree structure (Document object) into a standard XML string, and encapsulates the XML string and the encoded digest signature string into an EncodeRespDTO result object. The client retrieves the XML document (packet assembly result) and signature string from this object for subsequent transmission and integrity verification.

[0128] This application also provides an Extensible Markup Language (Extreme Markup Language) document encoding / decoding device; please refer to... Figure 5 The Extensible Markup Language document encoding / decoding apparatus includes: Loading module 10 is used to obtain encoding requests and / or decoding requests sent by the client, and load pre-parsed configuration objects from the preset configuration management module; Decoding module 20 performs a depth-first search algorithm to traverse the tree model in the Extensible Markup Language document to be decoded based on the decoding request and the configuration object to extract node data; the node data is then filled into the corresponding business data set and decoding digest signature string to obtain the document decoding result; The encoding module 30 is used to perform a depth-first search algorithm traversal on the business data to be encoded based on the encoding request and the configuration object to generate Extensible Markup Language (XML) document elements; and to fill the XML document elements into a pre-built XML document tree structure to obtain the document encoding result.

[0129] The Extensible Markup Language (XML) document encoding / decoding apparatus provided in this application, employing the XML document encoding / decoding method described in the above embodiments, can solve the technical problems of XML document encoding / decoding. Compared with the prior art, the beneficial effects of the XML document encoding / decoding apparatus provided in this application are the same as those of the XML document encoding / decoding method provided in the above embodiments, and other technical features in the XML document encoding / decoding apparatus are the same as those disclosed in the methods of the above embodiments, and will not be repeated here.

[0130] This application provides an Extensible Markup Language (XML) document encoding / decoding device, which includes: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, which are executed by the at least one processor to enable the at least one processor to perform the XML document encoding / decoding method in Embodiment 1 above.

[0131] The following is for reference. Figure 6 This document illustrates a structural schematic diagram of a Scalable Markup Language (SML) document encoding / decoding device suitable for implementing embodiments of this application. The SML document encoding / decoding device in the embodiments of this application may include, but is not limited to, mobile terminals such as mobile phones, laptops, digital broadcast receivers, PDAs (Personal Digital Assistants), PADs (Portable Application Description), PMPs (Portable Media Players), in-vehicle terminals (e.g., in-vehicle navigation terminals), and fixed terminals such as digital TVs and desktop computers. Figure 6 The Extensible Markup Language document encoding / decoding device shown is merely an example and should not impose any limitations on the functionality and scope of use of the embodiments of this application.

[0132] like Figure 6 As shown, the Extensible Markup Language (XML) document encoding / decoding device may include a processing unit 1001 (e.g., a central processing unit, a graphics processing unit, etc.) that can perform various appropriate actions and processes according to a program stored in read-only memory 1002 or a program loaded from storage device 1003 into random access memory 1004. The random access memory 1004 also stores various programs and data required for the operation of the XML document encoding / decoding device. The processing unit 1001, read-only memory 1002, and random access memory 1004 are interconnected via bus 1005. Input / output interface 1006 is also connected to the bus. Typically, the following systems can be connected to input / output interface 1006: input devices 1007 including, for example, touchscreens, touchpads, keyboards, mice, image sensors, microphones, accelerometers, gyroscopes, etc.; output devices 1008 including, for example, liquid crystal displays (LCDs), speakers, vibrators, etc.; storage devices 1003 including, for example, magnetic tapes, hard disks, etc.; and communication devices 1009. Communication device 1009 allows the Scalable Markup Language (SML) document codec device to communicate wirelessly or wiredly with other devices to exchange data. While the figure shows SML document codec devices with various systems, it should be understood that implementation or possession of all the systems shown is not required. More or fewer systems may be implemented alternatively.

[0133] Specifically, according to the embodiments disclosed in this application, the processes described above with reference to the flowcharts can be implemented as computer software programs. For example, embodiments disclosed in this application include a computer program product comprising a computer program carried on a computer-readable medium, the computer program containing program code for performing the methods shown in the flowcharts. In such embodiments, the computer program can be downloaded and installed from a network via a communication device, or installed from storage device 1003, or installed from read-only memory 1002. When the computer program is executed by processing device 1001, it performs the functions defined in the methods of the embodiments disclosed in this application.

[0134] The Extensible Markup Language (XML) document encoding / decoding device provided in this application, employing the XML document encoding / decoding method described in the above embodiments, can solve the technical problems of XML document encoding / decoding. Compared with the prior art, the beneficial effects of the XML document encoding / decoding device provided in this application are the same as those of the XML document encoding / decoding method provided in the above embodiments, and other technical features in this XML document encoding / decoding device are the same as those disclosed in the previous embodiment method, and will not be repeated here.

[0135] It should be understood that the various parts disclosed in this application can be implemented using hardware, software, firmware, or a combination thereof. In the description of the above embodiments, specific features, structures, materials, or characteristics can be combined in any suitable manner in one or more embodiments or examples.

[0136] The above description is merely a specific embodiment of this application, but the scope of protection of this application is not limited thereto. Any variations or substitutions that can be easily conceived by those skilled in the art within the scope of the technology disclosed in this application should be included within the scope of protection of this application. Therefore, the scope of protection of this application should be determined by the scope of the claims.

[0137] This application provides a computer-readable storage medium having computer-readable program instructions (i.e., a computer program) stored thereon, the computer-readable program instructions being used to execute the Extensible Markup Language document encoding and decoding method in the above embodiments.

[0138] The computer-readable storage medium provided in this application may be, for example, a USB flash drive, but is not limited to, electrical, magnetic, optical, electromagnetic, infrared, or semiconductor systems or devices, or any combination thereof. More specific examples of computer-readable storage media may include, but are not limited to: electrical connections having one or more wires, portable computer disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fiber, portable compact disk read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination thereof. In this embodiment, the computer-readable storage medium may be any tangible medium containing or storing a program that can be used by or in conjunction with an instruction execution system or device. The program code contained on the computer-readable storage medium may be transmitted using any suitable medium, including but not limited to: wires, optical cables, RF (Radio Frequency), etc., or any suitable combination thereof.

[0139] The aforementioned computer-readable storage medium may be included in an Extensible Markup Language (XML) document encoding / decoding device; or it may exist independently and not be assembled into an XML document encoding / decoding device.

[0140] The aforementioned computer-readable storage medium carries one or more programs. When these programs are executed by an Extensible Markup Language (XML) document encoding / decoding device, the XML document encoding / decoding device performs the following actions: It acquires encoding and / or decoding requests sent by a client and loads a pre-parsed configuration object from a preset configuration management module; it performs a depth-first search algorithm traversal on the tree model in the XML document to be decoded based on the decoding request and the configuration object to extract node data; it fills the node data into the corresponding business data set and decoding digest signature string to obtain the document decoding result; it performs a depth-first search algorithm traversal on the business data to be encoded based on the encoding request and the configuration object to generate XML document elements; and it fills the XML document elements into a pre-constructed XML document tree structure to obtain the document encoding result.

[0141] Computer program code for performing the operations of this application can be written in one or more programming languages ​​or a combination thereof, including object-oriented programming languages ​​such as Java, Smalltalk, and C++, as well as conventional procedural programming languages ​​such as "C" or similar programming languages. The program code can be executed entirely on the user's computer, partially on the user's computer, as a standalone software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In cases involving remote computers, the remote computer can be connected to the user's computer via any type of network—including a local area network (LAN) or a wide area network (WAN)—or can be connected to an external computer (e.g., via the Internet using an Internet service provider).

[0142] The flowcharts and block diagrams in the accompanying drawings illustrate the architecture, functionality, and operation of possible implementations of systems, methods, and computer program products according to various embodiments of this application. In this regard, each block in a flowchart or block diagram may represent a module, segment, or portion of code containing one or more executable instructions for implementing a specified logical function. It should also be noted that in some alternative implementations, the functions indicated in the blocks may occur in a different order than those indicated in the drawings. For example, two consecutively indicated blocks may actually be executed substantially in parallel, and they may sometimes be executed in reverse order, depending on the functions involved. It should also be noted that each block in the block diagrams and / or flowcharts, and combinations of blocks in the block diagrams and / or flowcharts, can be implemented using a dedicated hardware-based system that performs the specified function or operation, or using a combination of dedicated hardware and computer instructions.

[0143] The modules described in the embodiments of this application can be implemented in software or hardware. The names of the modules do not necessarily limit the functionality of the unit itself.

[0144] The readable storage medium provided in this application is a computer-readable storage medium that stores computer-readable program instructions (i.e., a computer program) for executing the above-described Extensible Markup Language (XML) document encoding and decoding method, thereby solving the technical problem of XML document encoding and decoding. Compared with the prior art, the beneficial effects of the computer-readable storage medium provided in this application are the same as those of the XML document encoding and decoding method provided in the above embodiments, and will not be repeated here.

[0145] This application also provides a computer program product, including a computer program that, when executed by a processor, implements the steps of the Extensible Markup Language document encoding / decoding method described above.

[0146] The computer program product provided in this application can solve the technical problem of Extensible Markup Language (XML) document encoding and decoding. Compared with the prior art, the beneficial effects of the computer program product provided in this application are the same as those of the XML document encoding and decoding method provided in the above embodiments, and will not be repeated here.

[0147] The above description is only a part of the embodiments of this application and does not limit the patent scope of this application. All equivalent structural transformations made under the technical concept of this application and using the contents of the specification and drawings of this application, or direct / indirect applications in other related technical fields, are included in the patent protection scope of this application.< / item>

Claims

1. A method for encoding and decoding Extensible Markup Language (Extreme Markup Language) documents, characterized in that, The Extensible Markup Language document encoding / decoding method includes: Obtain the encoding and / or decoding requests sent by the client, and load the pre-parsed configuration object from the preset configuration management module; Based on the decoding request and the configuration object, a depth-first search algorithm is used to traverse the tree model in the Extensible Markup Language document to be decoded in order to extract node data; The node data is filled into the corresponding business data set and the decoding digest signature string to obtain the document decoding result; Based on the encoding request and the configuration object, a depth-first search algorithm is used to traverse the business data to be encoded in order to generate Extensible Markup Language document elements; The Extensible Markup Language (XML) document elements are populated into a pre-built XML document tree structure to obtain the document encoding result.

2. The Extensible Markup Language document encoding and decoding method as described in claim 1, characterized in that, The steps of obtaining the encoding request and / or decoding request sent by the client and loading the pre-parsed configuration object from the preset configuration management module include: Obtain the encoding and / or decoding requests sent by the client; The configuration management module loads the Extensible Markup Language document paths and field mapping rules from the client; Based on the encoding request and / or the decoding request, the Extensible Markup Language document path and the field mapping rules are passed to the configuration object in the preset configuration management module.

3. The Extensible Markup Language document encoding and decoding method as described in claim 1, characterized in that, The configuration object includes a decoding service object. The step of performing a depth-first search algorithm traversal on the tree model in the Extensible Markup Language document to be decoded based on the decoding request and the configuration object to extract node data includes: Based on the decoding request, the Extensible Markup Language document to be decoded is converted into a tree model; Extract the root node of the tree model from the decoding service object; A depth-first search algorithm is used to traverse the tree model from the root node to extract node data.

4. The Extensible Markup Language document encoding and decoding method as described in claim 3, characterized in that, The step of using a depth-first search algorithm to traverse the tree model from the root node to extract node data includes: A depth-first search algorithm is used to traverse the tree model from the root node and determine the node type of each tree model node. Given that the node type of the tree model node is a multi-packet node, extract the first result set under the current multi-packet node from the tree model, and traverse the first result set to extract node data for each sub-packet in the result set. Given that the node type of the tree model node is a leaf node, extract the node data corresponding to the current tree model node from the tree model; Given that the node type of the tree model node is a nested node, a depth-first search recursive traversal is performed with the current tree model node as the root to extract the node data of the current tree model node.

5. The Extensible Markup Language document encoding and decoding method as described in claim 3, characterized in that, The step of filling the node data into the corresponding business data set and decoding digest signature string to obtain the document decoding result includes: Based on the traversal order of the depth-first search algorithm and the field mapping rules in the decoding service object, the node data is filled into a preset business data set; The node data is formatted into a decoded digest signature string according to the preset signature node rules, and the decoded digest signature string is appended to the signature buffer; The business data set and the decoding digest signature string are used as the document decoding result.

6. The Extensible Markup Language document encoding and decoding method as described in claim 1, characterized in that, The configuration object includes an encoding service object. The step of performing a depth-first search algorithm traversal on the business data to be encoded based on the encoding request and the configuration object to generate Extensible Markup Language document elements includes: Based on the encoding request, the business data to be encoded is deserialized into a tree structure representation, and an empty tree model is created; Add the root node represented by the tree structure to the empty tree model to obtain the Extensible Markup Language document tree structure; Based on the Extensible Markup Language (XML) document path in the encoding service object, a depth-first search algorithm is performed on the tree structure representation to generate XML document elements.

7. The Extensible Markup Language document encoding and decoding method as described in claim 6, characterized in that, The step of performing a depth-first search algorithm to traverse the tree structure representation based on the Extensible Markup Language (XML) document path in the encoding service object to generate XML document elements includes: Based on the Extensible Markup Language document path in the encoding service object, a depth-first search traversal is performed on the tree structure representation to determine the node type of each tree structure representation node in the tree structure representation; Given that the node type of the tree structure representation node is a multi-package node, extract the second result set under the current multi-package node from the tree structure representation, and traverse the second result set to generate Extensible Markup Language document elements corresponding to each sub-package in the second result set; Given that the node type of the node in the tree structure representation is a leaf node, extract the Extensible Markup Language document element corresponding to the current tree structure representation node from the tree structure representation; Given that the node type of the tree structure representation node is a nested node, a depth-first search recursive traversal is performed with the current tree structure representation node as the root to generate the Extensible Markup Language document element of the current tree structure representation node.

8. The Extensible Markup Language document encoding and decoding method as described in claim 6, characterized in that, The document encoding result is obtained by filling the Extensible Markup Language (XML) document elements into a pre-built XML document tree structure. Based on the hierarchical relationship of the nodes in the current tree structure representation, the Extensible Markup Language (XML) document elements are populated into the pre-built XML document tree structure. The Extensible Markup Language document elements are appended to the encoded digest signature string according to the preset signature node rules; The Extensible Markup Language (XML) document tree structure is serialized into an XML document, and the document encoding result is obtained based on the XML document and the encoded digest signature string.

9. A storage medium, characterized in that, The storage medium is a computer-readable storage medium, and a computer program is stored on the storage medium. When the computer program is executed by a processor, it implements the steps of the Extensible Markup Language document encoding and decoding method as described in any one of claims 1 to 8.

10. A computer program product, characterized in that, The computer program product includes a computer program that, when executed by a processor, implements the steps of the Extensible Markup Language document encoding / decoding method as described in any one of claims 1 to 8.