XML Standardization (2)
The previous article introduced how to standardize XML files through an example, this article mainly tells some of the issues that the XML file subset is regulated. When we extract some of the content from an XML file, we generally separate a child node from its parent node. We call this child node as an orphan node, and the extracted file is called a document subset. If the namespace of the orphan node declares in its parent node, the original namespace context may be lost. Here is an example in an example.
Document 1 XML Version = "1.0"?>
File 2
In view of the above reasons, two rules defined in the XML normalization rules to handle subdocument extraction: 1 The parent namespace declaration of the neglected in document subset is added to the document subset. 2 XML namespace properties also need to be added to the document subset. After using these two standardized rules, the extracted documents are shown in File 3. File 3 The package SOAP is an XML-based, simple protocol for exchanging structured and type information on the web, which defines the format of the XML data packaged in the envelope. Let's go back and look at the file 1, it will be packaged in the SOAP: Body element in SOAP: body element. Document 1 describes a simple packaging mechanism: The information passed is packaged in the SOAP: body element, the entire SOAP: body element is also packaged in the SOAP: envelope element. Let's take a look at a situation in which problems. A tourist wants to understand the details of the travel through the web service provided by the travel agency, so this visitors have sent an XML information to the travel agency. In the information, the location and time of his plan is planned, all the information is placed in a SOAP envelope. Of course, this XML information is generated by the client's program, which is not necessary to learn about XML and SOAP. After the travel agency receives this SOAP envelope, its web service extracts the tourist location and time information from the envelope, and then re-encapsulates this information, then sending this information to several different hotels and car rentals. Here, the travel agency's Web service needs to generate a new SOAP envelope. According to the same manner, after the travel agency receives the information returned by the hotel and the car rental company, it reinages these information and then sends back to the passenger. File 4 is a SOAP information such as a hotel to return to the travel agency. Document 4 XML Version = "1.0"?> Document 5 As shown in Figure 1, passengers have received the SOAP envelope of the travel agency, and the guest's Web Services open the SOAP envelope, extract and verify information. First, extract the booking element from the file 1 as described above, the extracted document subset is file 3; then, the program generates a summary of the file 3 and compares it with the received information summary. Obviously, the result will be a failed verification. At this time, the passenger will consider that the information is illegally modified, but in fact, this information is not modified. Such a scenario is very common in a joint web service. In order to deal with these issues, W3C specializes in another standardized rule "Special XML Standardization Rule", which is only used when the standardized document is set.