Summary of the invention
For solving the problems of the technologies described above, the embodiment of the present invention provides a kind of XML message processing method and device, can provide a kind of general, extendability strong, be easy to the XML message parsing method safeguarded.
On the one hand, a kind of method that the embodiment of the present invention provides XML message to process, comprising:
Preserve in advance the corresponding relation of node configuration information, interface identifier and node configuration information that each interface comprises and to the general XML analysis program of total interface; Wherein, described interface is for transmission, swap data, and the data structure that distinct interface is corresponding is different, the interface identifier that each interface is corresponding unique;
Receive XML message, according to described XML Receive message interface identifier, the unique identification that described interface identifier is interface;
According to the described interface identifier prestoring and the corresponding relation of node configuration information, obtain the node configuration information corresponding with described interface identifier;
According to described node configuration information, use described general XML analysis program to resolve described XML message.
Preferably, describedly according to described node configuration information, use described general XML analysis program to resolve to described XML message:
According to described node configuration information, use described general XML analysis program to resolve item by item each node in described XML message, obtain the value that each node is corresponding.
Preferably, describedly according to described node configuration information, each node in described XML message is resolved item by item, obtains the value that each node is corresponding and comprise:
According to the order information in described node configuration information, obtain node corresponding to configuration information in the first order, using described node as present node;
Obtain the configuration information of present node;
According to the configuration information of present node, judge whether present node has attribute;
If judgement present node, without attribute, directly obtains the value of present node; If judgement present node has attribute, obtain value that the attribute of described present node is corresponding and the value of present node;
According to node corresponding to next configuration information of sequential processes corresponding to described order information, it is processed as present node, until handle all nodes.
Preferably, describedly according to described node configuration information, each node in described XML message is resolved item by item, obtains the value that each node is corresponding and comprise:
According to described node configuration information, choose a node as present node;
Obtain the configuration information of present node;
According to the configuration information of present node, judge whether present node has attribute, if had, the value that getattr is corresponding, enters next step;
If judgement present node, without attribute, judges whether present node has child node, if had, obtain the configuration information of described child node, using child node as present node, enter the step of the configuration information that obtains present node;
If judgement present node does not have child node, obtain the value of present node;
Judge whether present node is last node, if not, chooses a untreated node, described node is processed as present node, until handle last node.
Preferably, describedly according to described node configuration information, each node in described XML message is resolved item by item, obtains the value that each node is corresponding and comprise:
According to described node configuration information, choose a node as present node;
Obtain the configuration information of present node;
According to the configuration information of present node, judge whether present node has child node, if had, using child node as present node, enter the step of the configuration information that obtains present node;
If nothing, judges whether present node has attribute;
If judgement present node, without attribute, obtains the value of present node; If had, obtain value that current attribute is corresponding and the value of present node;
Judge whether present node is last node, if not, choose a untreated node and process as present node, until handle last node.
Preferably, described according to described node configuration information, choose a node and as present node be:
According to described node configuration information, obtain root node, using described root node as present node.
Preferably, described according to described node configuration information, choose a node and as present node be:
According to described node configuration information, using node corresponding to article one configuration information as present node.
Preferably, before obtaining the value of present node, described method also comprises:
Judge whether present node is necessary node;
If judgment result is that to be, judge whether described XML message comprises described node;
If comprise described node in described XML message, enter the step of the value of obtaining present node; If not, return to error message.
Preferably, described method also comprises:
With the formal output analysis result of key-value pair, the value that the nodename of wherein take is key, node is value composition key-value pair.
Preferably, described method also comprises:
When revising interface definition, upgrade the node configuration information corresponding with described interface.
On the one hand, the embodiment of the present invention also provides a kind of XML message process device, comprising again:
Setting unit, for preserving in advance the corresponding relation of node configuration information, interface identifier and node configuration information that each interface comprises and to the general XML analysis program of total interface; Wherein, described interface is for transmission, swap data, and the data structure that distinct interface is corresponding is different, the interface identifier that each interface is corresponding unique;
Receiver module, for receiving XML message, according to described XML Receive message interface identifier, the unique identification that described interface identifier is interface;
Acquisition module, for obtaining the node configuration information corresponding with described interface identifier according to the described interface identifier prestoring with the corresponding relation of node configuration information;
Parsing module, for being used described general XML analysis program to resolve described XML message according to described node configuration information.
Preferably, described parsing module also, for using described general XML analysis program to resolve item by item each node of described XML message according to described node configuration information, obtains the value that each node is corresponding.
Preferably, described parsing module is that the first parsing module is for obtain node corresponding to configuration information in the first order according to the order information of described node configuration information, using described node as present node; Obtain the configuration information of present node; According to the configuration information of present node, judge whether present node has attribute; If judgement present node, without attribute, directly obtains the value of present node; If judgement present node has attribute, obtain value that the attribute of described present node is corresponding and the value of present node; According to node corresponding to next configuration information of sequential processes corresponding to described order information, it is processed as present node, until handle all nodes.
Preferably, described parsing module is the second parsing module, for according to described node configuration information, chooses a node as present node; Obtain the configuration information of present node; According to the configuration information of present node, judge whether present node has attribute, if had, the value that getattr is corresponding also enters and judges whether present node has the step of child node; If judgement present node, without attribute, judges whether present node has child node, if had, obtain the configuration information of described child node, using child node as present node, enter the step of the configuration information that obtains present node; If judgement present node does not have child node, obtain the value of present node; Judge whether present node is last node, if not, chooses a untreated node, described node is processed as present node, until handle last node.
Preferably, described parsing module is the 3rd parsing module, for according to described node configuration information, chooses a node as present node; Obtain the configuration information of present node; According to the configuration information of present node, judge whether present node has child node, if had, using child node as present node, enter the step of the configuration information that obtains present node; If nothing, judges whether present node has attribute; If judgement present node, without attribute, obtains the value of present node; If had, obtain value that current attribute is corresponding and the value of present node; Judge whether present node is last node, if not, choose a untreated node and process as present node, until handle last node.
Preferably, described device also comprises:
Output module, for the formal output analysis result with key-value pair, the value that the nodename of wherein take is key, node is value composition key-value pair.
Preferably, described device also comprises:
Update module, for when revising interface definition, upgrades the node configuration information corresponding with described interface.
The beneficial effect that the embodiment of the present invention can reach is: in the method providing in the embodiment of the present invention, preserved in advance the configuration information of the node that each interface comprises, after receiving XML message, according to the XML Receive message interface identifier receiving, and obtain the node configuration information corresponding with described interface identifier according to the interface identifier prestoring and the corresponding relation of node configuration information; Finally according to described node configuration information, described XML message is resolved.Due in embodiments of the present invention, abstract, extracted general analysis program, and the part changing for XML message is the different field (node) of distinct interface definition, the nodal information that the mode saving interface of employing preservation node configuration information comprises, and give unique interface identifier in order to distinguish distinct interface for each interface, and obtain the node configuration information corresponding with interface according to interface identifier, according to described node configuration information, use general XML analysis program to resolve.Like this, can for the message of distinct interface, provide general analytic method, be easy to safeguard, extensibility is strong.
Embodiment
XML is a kind of structurized text label language, with a series of simple marks, carrys out data of description.It is corresponding with the data of certain type that user can define XML tag symbol, then creates XML document.During concrete application, can resolve the XML document creating, to obtain the value being associated with label and attribute.General XML document mainly consists of label, label value, attribute, property value, annotation etc., wherein a node in the corresponding file structure model of XML label.For example, want to describe certain series products in XML document, definable Product labelling is " mobile phone ", can also define the attribute of this label, such as " brand " attribute, " model " attribute, " price " attribute, " color " attribute etc.Each attribute field can have concrete property value, and for example the value of " brand " attribute is " Samsung ", and the value of " model " attribute is " I9000 ", and the value of " price " attribute is " 3000 ", and the value of " color " attribute is " black " etc.The process that XML is resolved is to obtain the value of each label (node) correspondence and the value corresponding to attribute, attribute of label (node).
In the prior art, general analytic method is SAX and DOM.But no matter be SAX or DOM, all need the XML message of each request to carry out independent parsing.And in complicated service logic, can define a plurality of interfaces for transmission, swap data, and interface is different, the data structure of XML message also can be different, and corresponding required parameter also can be different.Therefore, for different interfaces, need to work out different analysis programs XML message is resolved, just can obtain the data of needs to carry out follow-up business processing.Like this, along with the expansion of service logic, business interface is also more and more, and the size of code of analysis program also can be expansion type and increase, not easy care.And every increase or modification interface all need to increase or revise analysis program code, the extensibility of analysis program, versatility are not strong.
In order to solve the problems referred to above of prior art, the embodiment of the present invention provides a kind of XML message processing method and device, can provide a kind of general, extendability strong, be easy to the XML message parsing method safeguarded.The message data structure corresponding due to distinct interface in prior art is different, and the message field (MFLD) comprising (node) is also different, therefore needs different analysis programs to resolve it.In embodiments of the present invention, abstract, extracted general analysis program, and for the part changing, be the different field (node) of distinct interface definition, the nodal information that the mode saving interface of employing preservation node configuration information comprises, and give unique interface identifier in order to distinguish distinct interface for each interface, and obtain the node configuration information corresponding with interface according to interface identifier, according to described node configuration information, use general XML analysis program to resolve.Like this, can for the message of distinct interface, provide general analytic method, be easy to safeguard, extensibility is strong.
In order to make those skilled in the art person understand better the technical scheme in the present invention, below in conjunction with the accompanying drawing in the embodiment of the present invention, technical scheme in the embodiment of the present invention is clearly and completely described, obviously, described embodiment is only the present invention's part embodiment, rather than whole embodiment.Embodiment based in the present invention, those of ordinary skills, not making the every other embodiment obtaining under creative work prerequisite, should belong to the scope of protection of the invention.
Referring to Fig. 1, XML message processing method the first embodiment process flow diagram for the embodiment of the present invention provides, comprising:
S101, receives XML message, according to described XML Receive message interface identifier, the unique identification that described interface identifier is interface.
The method that the embodiment of the present invention provides can be applied in transaction processing system, for analyzing XML message or XML document, also can be suitable for separately.Conventionally, between XML message transmitting party and XML message take over party or calling service side and business provider, can arrange an interface protocol, the information such as the field (node) comprising for defining interface, the structure of data, form, both sides carry out data interaction by the interface message of agreement.In embodiments of the present invention, for each interface provides a unique sign, for distinguishing different interfaces.In the XML message sending, comprise interface identifier, take over party is after receiving XML message, by analyzing XML Receive message interface identifier.
S102, obtains the node configuration information corresponding with described interface identifier according to the described interface identifier prestoring and the corresponding relation of node configuration information.
In embodiments of the present invention, preserved in advance the node configuration information of interface.The node configuration information of interface can be preserved with the form of configuration file, also can be kept in database.Because interface protocol is arranged jointly by calling service side and business provider, generally can not revise easily, in order to improve the handling property of system, node configuration information can be kept in buffer memory, without all read node configuration information from database at every turn, improved system handling property like this.
In embodiments of the present invention, preserve in advance the corresponding relation of interface identifier and node configuration information, according to described corresponding relation, can obtain the node configuration information corresponding with interface identifier.
S103, resolves described XML message according to described node configuration information.
The process that XML message is resolved, is according to node configuration information, each node in described XML message to be resolved item by item, obtains the process of the value that each node is corresponding.If node also has attribute, correspondingly, obtain the value corresponding to attribute of node.Preferably, with the formal output analysis result of key-value pair.Wherein, take the value that nodename is key, node is that value forms key-value pair output.If node also has attribute, further comprise that take attribute is that value forms another group key-value pair output as key, the value of attribute of take.
Preferably, when revising interface definition, upgrade the node configuration information corresponding with described interface.In embodiments of the present invention, when the definition of business provider and calling service side's docking port is modified, when increased, revising or deleting field (node), upgrade the node configuration information corresponding with described interface, increase, revise or delete the configuration information that corresponding node is corresponding.Like this, without changing XML handling procedure, can resolve XML message corresponding to amended interface.The method that the embodiment of the present invention provides, for the system that has a large number of services interface, has increased the dirigibility of system.The modification of each docking port, revises code without programmer and works out special analysis program, greatly reduces maintenance cost.
Referring to Fig. 2, XML message processing method the second embodiment process flow diagram for the embodiment of the present invention provides, comprising:
S201, receives XML message, according to described XML Receive message interface identifier, the unique identification that described interface identifier is interface.
S202, obtains the node configuration information corresponding with described interface identifier according to the described interface identifier prestoring and the corresponding relation of node configuration information.
In embodiments of the present invention, preserved in advance the node configuration information of interface.The node configuration information of interface can be preserved with the form of configuration file, also can be kept in database.Because interface protocol is arranged jointly by calling service side and business provider, generally can not revise easily, in order to improve the handling property of system, node configuration information can be kept in buffer memory, without all read node configuration information from database at every turn, improved system handling property like this.The node configuration information of corresponding same interface identifier can be kept at together, also can separately preserve.Each node configuration information is information sequential storage in order, also can store at random.The present invention does not limit this.
In second embodiment of the invention, node configuration information can comprise:
(1) interface identifier (XMLID), the unique identification of the interface that node is corresponding;
(2) message nodename (XMLNames), the title of the XML message node of corresponding requests.
(3) output node title (DataNames), to depositing the nodename of the value of XML after reply XML packet parsing.
(4) father node title (ParentName), the title of the upper level father node of this node.
(5) child node information, for representing whether present node has child node.Concrete, can indicate with 1, with 0, represent not have.Can certainly represent with other numerical value or sign.
(6) attribute information, for representing whether present node has attribute.Concrete, can indicate with 1, with 0, represent not have.Can certainly represent with other numerical value or sign.
(7) necessity information, for representing whether this node is the necessary node that must exist.Concrete, can indicate with 1, with 0, represent not have.Can certainly represent with other numerical value or sign.
(8) order information, for the order that represents that this node occurs at XML message.The node of order 1 correspondence is generally root node.
(9) service identification.Further, also can comprise the service identification that this node is corresponding.
As shown in table 1, be the example of one section of XML message.
Table 1XML message example
Take message shown in table 1 as example, and the interface identifier of the interface that shown in supposing, message is corresponding is 01, and the node configuration information corresponding with this interface is as shown in table 2.
Table 2 node configuration information example
In this step, after getting the interface identifier of message, take out the node configuration information corresponding with described interface identifier.Specific to above-mentioned example, take out interface identifier and be 9 configuration informations of 01.
S203, according to described node configuration information, chooses a untreated node as present node.
Concrete, can be according to the node configuration information corresponding with interface identifier obtaining, choose arbitrarily wherein node that configuration information is corresponding as present node.Preferably, can be using node corresponding to article one configuration information as present node.
S204, obtains the configuration information of present node.
S205, judges according to the configuration information of present node whether present node has attribute; If had, enter step S206, if nothing enters step S207.
S206, obtains the value that described attribute is corresponding, enters step S207.
Concrete, before mention, XML message is generally comprised of label, generally has the label of beginning and end-tag.The example of several XML message formats below:
1、<a>value</a>
2、<a/>
3、<a?property=”value2”>value1</a>
In the first form, the character string (value) starting in label <a> and end-tag </a> is the value of node.In the second form, there is not the value of node.In the third form, node has attribute property, and the character string in double quotation marks is the value that attribute is corresponding.At this moment, when system judgement present node has attribute, can obtain this character string as value corresponding to attribute.
The message described in table 1 of take is example, suppose that present node is address, by node configuration information corresponding to address, system judgement address has attribute, at this moment value A corresponding to getattr class in <address class=" A " the >nanshan</addressGreatT.GreaT .GT from message.At this moment, take attribute as key, with the value composition key-value pair of attribute, preserve.
S207, judges whether present node has child node.If had, obtain the configuration information of child node, using child node as present node, enter step S204.If present node has a plurality of child nodes, from described child node, choose a child node as present node, enter step S204.Handle after one of them child node of present node, then other child nodes of Recursion process present node.
S208, if judgement present node does not have child node, obtains the value of present node.
Before mention, XML message generally has and starts label and end-tag, the character string (value) starting in label <a> and end-tag </a> is the value of node.The message described in table 1 of take is example, suppose that current processing node is XMLid, at this moment from message <xmlid>01</xmlid >, take out to start value 01 between label and end-tag as the value of present node xmlid.At this moment, with output node name, be called key, the value of present node of take is preserved as value forms key-value pair.Here, output node title can be identical with message nodename, also can be different.XML message may exist message nodename identical, but the different situation of value of taking out, the i.e. corresponding a plurality of values of message node.In order to distinguish, can define output node title, to distinguish the identical message node with different value.
S209, judges whether present node is last node, if not, enters step S203, chooses a untreated node, described node is processed as present node, until handle last node.
If also there is untreated node, there is untreated node configuration information, choose node that untreated configuration information is corresponding as present node, the processing procedure of repeating step S203 to S207, until last node processing is complete.
S210, output analysis result.
The output node name of take is called key, nodal value as value composition key-value pair, exports the key-value pair information that each node is corresponding.If node has attribute, further output take attribute as key, property value be the key-value pair information of value composition.
Further, at step S208 judgement present node, there is no child node, before obtaining the value of present node, further comprise and judge whether present node is the step of necessary node.If judgment result is that to be, judge whether described XML message comprises described node; If comprise described node in described XML message, enter the step of the value of obtaining present node; If not, return to error message.
In second embodiment of the invention, interface identifier by obtaining message to be to obtain the node configuration information corresponding with described interface identifier, and chooses a node as present node according to described node configuration information, judges whether present node has attribute, if there is attribute, getattr value; If nothing, further judges whether present node has child node, if had, child node is carried out to dissection process.Like this, travel through all nodes and resolve, and export analysis result.In second embodiment of the invention, when choosing present node and resolving, can start to resolve from any configuration information, flexible because of the method, be convenient to application, improved the efficiency of resolving.
Referring to Fig. 3, XML message processing method the 3rd embodiment process flow diagram for the embodiment of the present invention provides, comprising:
S301, receives XML message, according to described XML Receive message interface identifier, the unique identification that described interface identifier is interface.
S302, obtains the node configuration information corresponding with described interface identifier according to the described interface identifier prestoring and the corresponding relation of node configuration information.
In this step, after getting the interface identifier of message, take out the node configuration information corresponding with described interface identifier.Specific to the example in table 1, take out interface identifier and be 9 configuration informations of 01.
S303, according to described node configuration information, obtains root node, using described root node as present node.
In third embodiment of the invention, when choosing a node as present node according to described node configuration information, be preferentially to choose root node as the node of first processing.Can from root node, travel through all nodes like this and carry out dissection process, can optimization process flow.
Concrete, obtain the mode of root node, can be according to father node name information in node configuration information, obtain father node name and be called without node corresponding to (null) as root node.Optionally, a sign also can be set in node configuration information for identifying root node, then according to this sign, obtain the configuration information that root node is corresponding.
S304, obtains the configuration information of present node.
S305, judges according to the configuration information of present node whether present node has attribute; If had, enter step S306, if nothing enters step S307.
S306, obtains the value that described attribute is corresponding, enters step S307.
S307, judges whether present node has child node.If had, obtain the configuration information of child node, using child node as present node, enter step S304.If present node has a plurality of child nodes, from described child node, choose a child node as present node, enter step S304.Handle after one of them child node of present node, then other child nodes of Recursion process present node.
S308, if judgement present node does not have child node, judges whether present node is necessary node.If judgment result is that to be, enter step S309; If the determination result is NO, enter step S310.
S309, judges that whether described XML message comprises described node, if so, enters step S310; If not, return to error message.Enter step S311.
S310, obtains the value of present node.
S311, judges that whether present node is last node, if not, enters step S312.If so, enter step S313.
S312, chooses a untreated node, and described node is processed as present node, enters step S304, until handle last node.
Generally speaking, if start to process from root node, process item by item the every child node under root node, can travel through all nodes.Optionally, in third embodiment of the invention, also further comprise that step S311 judges whether present node is the step of last node.If also there is untreated node, there is untreated node configuration information, choose node that untreated configuration information is corresponding as present node, the processing procedure of repeating step S304 to S310, until last node processing is complete.
S313, output analysis result.
The output node name of take is called key, nodal value as value composition key-value pair, exports the key-value pair information that each node is corresponding.If node has attribute, further output take attribute as key, property value be the key-value pair information of value composition.
In third embodiment of the invention, interface identifier by obtaining message to be to obtain the node configuration information corresponding with described interface identifier, and chooses root node as present node according to described node configuration information, judges whether present node has attribute, if there is attribute, getattr value; If nothing, further judges whether present node has child node, if had, child node is carried out to dissection process.Like this, from root node, trigger all nodes of traversal and resolve, and export analysis result.In third embodiment of the invention, when choosing present node and resolving, from root node, start to resolve, travel through each node, therefore can improve the efficiency of parsing.
Referring to Fig. 4, XML message processing method the 4th embodiment process flow diagram providing for the embodiment of the present invention.
In XML message, father node likely has attribute information, also may there is no attribute information.For arrange father node in interface protocol, there is no a class message of attribute information, can also take the method shown in fourth embodiment of the invention to process.
S401, receives XML message, according to described XML Receive message interface identifier, the unique identification that described interface identifier is interface.
S402, obtains the node configuration information corresponding with described interface identifier according to the described interface identifier prestoring and the corresponding relation of node configuration information.
In this step, after getting the interface identifier of message, take out the node configuration information corresponding with described interface identifier.Specific to the example in table 1, take out interface identifier and be 9 configuration informations of 01.
S403, according to described node configuration information, chooses a node as present node.
In fourth embodiment of the invention, choosing a node both can be for having chosen root node as present node as present node, also can choose node that article one configuration information is corresponding as present node, also can choose node that any configuration information is corresponding as present node.
S404, obtains the configuration information of present node.
S405, judges according to the configuration information of present node whether present node has child node, if had, obtains the configuration information of child node, using child node as present node, enters step S404.If present node has a plurality of child nodes, from described child node, choose a child node as present node, enter step S404.Handle after one of them child node of present node, then other child nodes of Recursion process present node.
S406, if judgement present node does not have child node, further judges whether present node has attribute; If had, enter step S407, if nothing enters step S408.
S407, obtains the value that described attribute is corresponding, enters step S408.
S408, judges whether present node is necessary node.If judgment result is that to be, enter step S409; If the determination result is NO, enter step S410.
S409, judges that whether described XML message comprises described node, if so, enters step S410; If not, return to error message.Enter step S411.
S410, obtains the value of present node.
S411, judges that whether present node is last node, if not, enters step S412; If so, enter step S413.
S412, chooses a untreated node, processes and enters step S404, until handle last node using described node as present node.
S413, output analysis result.
The output node name of take is called key, nodal value as value composition key-value pair, exports the key-value pair information that each node is corresponding.If node has attribute, further output take attribute as key, property value be the key-value pair information of value composition.
In fourth embodiment of the invention, different with the 3rd embodiment from the second embodiment is, obtain after present node, first judge whether present node has child node, judge again whether present node has attribute, for father node, there is no a class message of attribute, saved and judged whether father node has the step of attribute, further optimize treatment scheme, improved packet parsing efficiency.
Referring to Fig. 5, XML message processing method the 5th embodiment process flow diagram providing for the embodiment of the present invention.
Before mention, in node configuration information, can comprise order information, for the order that represents that this node occurs at XML message.The node of order 1 correspondence is generally root node.Order as described in Table 2, to occur with each node of 1-9 sign XML message.In fifth embodiment of the invention, the order that we can occur according to node in message is resolved each node item by item.
S501, receives XML message, according to described XML Receive message interface identifier, the unique identification that described interface identifier is interface.
S502, obtains the node configuration information corresponding with described interface identifier according to the described interface identifier prestoring and the corresponding relation of node configuration information.
At this moment, can take out all node configuration informations corresponding with described interface identifier, also can only take out the node configuration information in the first order, be generally the configuration information that root node is corresponding.
S503, obtains node corresponding to configuration information in the first order according to the order information in described node configuration information, using described node as present node.
S504, obtains the configuration information of present node.
S505, judges according to the configuration information of present node whether present node has attribute.If had, enter step S506, if nothing enters step S507.
S506, obtains the value that described attribute is corresponding, enters step S507.
S507, obtains the value of present node.
Optionally, before entering step S507, can further include and judge the whether step of necessary node of present node.If judgment result is that to be, judge whether described XML message comprises described node; If comprise described node in described XML message, enter step S507; If not, return to error message.
S508, judges that whether present node is last node, if not, enters step 509; If so, enter step S510.
S509, according to node corresponding to next configuration information of sequential processes corresponding to described order information, processes it as present node, the treatment step of repeating step S504 to S507, until handle all nodes.
S510, output analysis result.
The output node name of take is called key, nodal value as value composition key-value pair, exports the key-value pair information that each node is corresponding.If node has attribute, further output take attribute as key, property value be the key-value pair information of value composition.
In fifth embodiment of the invention, utilize the node sequence information in node configuration information, according to described order, item by item node is resolved, saved the step whether decision node has child node, further optimized treatment scheme, improved analyzing efficiency.
Referring to Fig. 6, the XML message process device schematic diagram providing for the embodiment of the present invention.
Described device comprises:
Receiver module 601, for receiving XML message, according to described XML Receive message interface identifier, the unique identification that described interface identifier is interface.
Acquisition module 602, for obtaining the node configuration information corresponding with described interface identifier according to the described interface identifier prestoring with the corresponding relation of node configuration information.
Parsing module unit 603, for resolving described XML message according to described node configuration information.
Preferably, described parsing module also, for according to described node configuration information, each node of described XML message being resolved item by item, obtains the value that each node is corresponding.
In one embodiment of the invention, described parsing module is specially the first parsing module, for obtain node corresponding to configuration information in the first order according to the order information of described node configuration information, using described node as present node; Obtain the configuration information of present node; According to the configuration information of present node, judge whether present node has attribute; If judgement present node, without attribute, directly obtains the value of present node; If judgement present node has attribute, obtain value that the attribute of described present node is corresponding and the value of present node; According to node corresponding to next configuration information of sequential processes corresponding to described order information, it is processed as present node, until handle all nodes.
Concrete, described the first parsing module comprises:
The first acquiring unit, for obtain node corresponding to configuration information in the first order according to the order information of described node configuration information, using described node as present node.
Second acquisition unit, for obtaining the configuration information of present node.
The first judging unit, for judging according to the configuration information of present node whether present node has attribute.When the determination result is NO, enter the 3rd acquiring unit.
The 3rd acquiring unit, for receiving the judged result of the first judging unit, when judgment result is that while being, obtains the value corresponding to attribute of present node; Enter the 4th acquiring unit.
The 4th acquiring unit, for obtaining the value of present node.
The second judging unit, be used for judging whether last node of present node, if not, according to node corresponding to next configuration information of sequential processes corresponding to described order information, using it as present node, enter the first acquiring unit, until handle last node.
In another embodiment of the present invention, described parsing module is specially the second parsing module, for according to described node configuration information, chooses a node as present node; Obtain the configuration information of present node; According to the configuration information of present node, judge whether present node has attribute, if had, the value that getattr is corresponding also enters and judges whether present node has the step of child node; If judgement present node, without attribute, judges whether present node has child node, if had, obtain the configuration information of described child node, using child node as present node, enter the step of the configuration information that obtains present node; If judgement present node does not have child node, obtain the value of present node; Judge whether present node is last node, if not, chooses a untreated node, described node is processed as present node, until handle last node.
The second parsing module specifically can comprise:
The 5th acquiring unit, for according to described node configuration information, chooses a node as present node.
The 6th acquiring unit, for obtaining the configuration information of present node.
The 3rd judging unit, for judging according to the configuration information of present node whether present node has attribute.When the determination result is NO, enter the 4th judging unit.
The 7th acquiring unit, for receiving the judged result of the 3rd judging unit, when judgment result is that while being, the value that getattr is corresponding, enters the 4th judging unit.
The 4th judging unit, for judging whether present node has child node.
The 8th acquiring unit, for receiving the judged result of the 4th judging unit, when judgment result is that while being, using child node as present node, enters the 6th acquiring unit.
The 9th acquiring unit, for receiving the judged result of the 4th judging unit, when the determination result is NO, obtains the value of present node.
The 5th judging unit, for judging whether present node is last node, if not, chooses a untreated node, enters the 6th acquiring unit, until handle last node using described node as present node.
In another embodiment of the present invention, described parsing module is specially the 3rd parsing module, for according to described node configuration information, chooses a node as present node; Obtain the configuration information of present node; According to the configuration information of present node, judge whether present node has child node, if had, using child node as present node, enter the step of the configuration information that obtains present node; If nothing, judges whether present node has attribute; If judgement present node, without attribute, obtains the value of present node; If had, obtain value that current attribute is corresponding and the value of present node; Judge whether present node is last node, if not, choose a untreated node and process as present node, until handle last node.
Described the 3rd parsing module specifically can comprise:
The tenth acquiring unit, for according to described node configuration information, chooses a node as present node.
The 11 acquiring unit, user obtains the configuration information of present node.
The 6th judging unit, has child node for the configuration information judgement present node according to present node.
The 12 acquiring unit, for receiving the judged result of the 6th judging unit, when judgment result is that while being, using child node as present node, enters the 11 acquiring unit.
The 7th judging unit, for receiving the judged result of the 4th judging unit, when the determination result is NO, judges whether present node has attribute.If not, enter the 14 acquiring unit.
The 13 acquiring unit, for receiving the judged result of the 7th judging unit, when judgment result is that while being, the value that getattr is corresponding, enters the 14 acquiring unit.
The 14 acquiring unit, for obtaining the value of present node.
The 8th judging unit, for judging whether present node is last node, if not, chooses a untreated node, enters the 11 acquiring unit, until handle last node using described node as present node.
Concrete, described device also comprises:
Output module, for the formal output analysis result with key-value pair, the value that the nodename of wherein take is key, node is value composition key-value pair.
Concrete, described device also comprises:
Update module, for when revising interface definition, upgrades the node configuration information corresponding with described interface.In embodiments of the present invention, when the definition of business provider and calling service side's docking port is modified, during as increase, modification or deletion field (node), update module upgrades the node configuration information corresponding with described interface, increases, revises or delete the configuration information that corresponding node is corresponding.
It should be noted that, in this article, relational terms such as the first and second grades is only used for an entity or operation to separate with another entity or operational zone, and not necessarily requires or imply and between these entities or operation, have the relation of any this reality or sequentially.And, term " comprises ", " comprising " or its any other variant are intended to contain comprising of nonexcludability, thereby the process, method, article or the equipment that make to comprise a series of key elements not only comprise those key elements, but also comprise other key elements of clearly not listing, or be also included as the intrinsic key element of this process, method, article or equipment.The in the situation that of more restrictions not, the key element being limited by statement " comprising ... ", and be not precluded within process, method, article or the equipment that comprises described key element and also have other identical element.
The present invention can describe in the general context of the computer executable instructions of being carried out by computing machine, for example program module.Usually, program module comprises the routine carrying out particular task or realize particular abstract data type, program, object, assembly, data structure etc.Also can in distributed computing environment, put into practice the present invention, in these distributed computing environment, by the teleprocessing equipment being connected by communication network, be executed the task.In distributed computing environment, program module can be arranged in the local and remote computer-readable storage medium that comprises memory device.
The above is only the specific embodiment of the present invention; it should be pointed out that for those skilled in the art, under the premise without departing from the principles of the invention; can also make some improvements and modifications, these improvements and modifications also should be considered as protection scope of the present invention.