Method and apparatus for comparison of structured documents

Abstract: A document difference extraction method and apparatus which is used for extracting the difference between structured documents properly meeting the sense of a document editor taking the logical meaning and structure of the structured documents into consideration. Structured documents are edited and stored in a memory unit by a document editing program (104). With reference to a comparison criterion (107) set for the logical structure of each structured document before and after edition, the logical structure of the structural documents before and after edition read from the memory unit is analyzed by a structured document parsing program (105), and the difference between the structured documents is extracted by a structured document difference extraction program (106) in such a manner as to satisfy the comparison criterion in accordance with the result of parsing. The comparison criterion (107) assumes the form of a table containing a plurality of tags representing logical structures and types of tags for the comparison criterion. The tag types for comparison criterion include tags having contents which are compared only when the particular tags are coincident with each other, tags having contents which are ignored at the time of comparison, a set of tags having the same logical meaning, and a set of tags having contents which are not compared with each other.

Description: BACKGROUND OF THE INVENTION The present invention relates to a structured document difference string extraction method and apparatus for a document processor such as a word processor capable of extracting a difference character string between structured documents stored as an electronic file. A structured document is defined as one having embedded therein, i.e., containing information on the logical structure of a document, that is, information such as "this portion of the document constitutes a chapter" or "this portion makes up a title". The difference extraction between documents is defined as detecting a most coincident combination of elements constituting each document including paragraphs, lines and characters and extracting non-coincident elements as a difference. Suppose that two documents for which the difference is to be detected are "ABCDEFG" and "ACDAEFH". When the two documents are compared in terms of elements thereof including A, B, C, D, E, F, G and H, the most coincident combination is detected as "correspondence of ACDEF". Also, the difference is detected in the form of "B is deleted", "A is inserted after D" or "G is changed to H". A conventional method for difference extraction is disclosed in JP-A-2-255964, in which comparison is made in terms of punctuation marks, lines, words and characters. According to this method, a character string representing a logical structure contained in the documents is compared in the same manner as other character strings are compared in the documents. However, extraction of a difference in a structured document by the same means as in a normal document may be inappropriate since the result may be non-coincident with the logical structure of the document. An example will be explained below. (Prior art example 1) With reference to the structured documents shown in Figs. 3A and 3B, the case will be explained in which documents having non-coincident logical structures are erroneously matched with each other in the process of difference extraction, thereby leading to an extraction result inappropriate to the document editor. The structured documents in Figs. 3A and 3B are described by SGML (Standard Generalized Markup Language; ISO 8879), indicating that a character string sandwiched by marks, for example, <A> and </A> called tags is associated with a logical structure A. In other words, the character string "TARO HEISEI" sandwiched between "<NAME>" and "</NAME>" of Fig. 3A is associated with the logical structure "NAME". HTML (Hypertext Markup Language) which is used in WWW (World Wide Web) is an application of SGML and is applicable to the present invention as well. Another name of the mark representing this logical structure is a tag. "<A>" and "</A>" thus are alternatively called a start tag and an end tag, respectively. The result of extracting a difference character string between two structured documents in Figs. 3A and 3B by the conventional technique is shown in Figs. 4A and 4B. Fig. 4B shows the result of extracting difference character strings of the structured document in Fig. 3B relative to the structured document in Fig. 3A. Fig. 4A shows the result of extracting difference character strings of the structured document in Fig. 3A relative to the structured document in Fig. 3B. As seen from Figs. 4A and 4B, "HEISEI" associated with "<NAME>" and "HEISEI" associated with "<TRANSMISSION DATE>" are not extracted as the difference. This is due to the fact that "HEISEI" was coincident and erroneously matched with each each other. This correspondence of "HEISEI" not coincident in logical structure is obviously meaningless to the document editor. (Prior art example 2) With reference to the structured documents shown in Figs. 5A and 5B, the case will be explained in which character strings are matched erroneously over different document structures in the process of difference extraction due to the insertion of a document structure, thereby leading to an extraction result not proper to the document editor. Fig. 5A shows a structured document having Chapter 1, and Fig. 5B a structured document with one other chapter inserted before Chapter 1. Figs. 6A, 6B show an example of extracting a difference character string between the two structured documents of Figs. 5A, 5B. Figs. 6A, 6B show a case similar to Figs. 4A, 4B, in which Fig. 6B shows the result of extracting a difference character string of Fig. 5B relative to Fig. 5A. Fig. 6A, on the other hand, shows the result of extracting a difference character string of Fig. 5A relative to Fig. 5B. As seen from Fig. 6A, Chapter 1 of Fig. 6A is matched over Chapter 1 and Chapter 2 of Fig. 6B in spite of the fact that Chapter 1 of Fig. 6A is identical to Chapter 2 of Fig. 6B. This is another case inappropriate to the document editor. Dual appearance in Fig. 5B of the same character string "STRUCTURED DOCUMENT" unlike in Fig. 5A leads to the erroneous decision in Fig. 6B that the first "STRUCTURED DOCUMENT" is coincident while the second "STRUCTURED DOCUMENT" is non-coincident, so that the second "STRUCTURED DOCUMENT" and extracted as a difference. This is true with each of subsequent cases of difference extraction. (Prior art example 3) With reference to the structured documents of Figs. 7A, 7B, explanation will be made of the case in which the difference in marks representing the logical structure of a document makes it impossible to match the contents of documents with each other in spite of the identical logical meaning of the documents, resulting in the extraction inappropriate to the document editor. In Figs. 7A, 7B, a tag <FIRST ITEM> is attached to only the item that first appears in spite of the fact that the logical meaning of the document remains the same and "ITEM". Figs. 8A, 8B show the case in which difference character strings between two structured documents of Figs. 7A and 7B are extracted by the conventional technique. Figs. 8A, 8B represent a case similar to Figs. 4A, 4B, in which Fig. 8B shows the result of extracting difference character strings of Fig. 7B as compared with Fig. 7A, while Fig. 8A shows the result of extracting difference character strings of Fig. 7A as compared with Fig. 7B. From Figs. 8A, 8B, it is seen that "FIRST ITEMs" are matched with each other and the character strings associated with them are compared with each other as the contents thereof. The logical meaning of "FIRST ITEM" and "ITEM" are the same for the document editor, and therefore the contents of the tags are required to be matched in priority over the tags. In extracting the difference between structured documents, comparison between them is required taking into consideration the logical meaning and the structure of the structured documents. This requirement is not met by the conventional method in which character strings indicating a logical structure are compared in similar fashion to other character strings in the document. In "identifying syntactic differences between two programs", published in Software Practice a nd Experience, Vol. 21, No. 7, pp 739-755, by Wuu Yang, it is proposed to extract the differences between two program codes taking into account the grammatical syntax of the programming language. However, no reference to tags or mark-up languages is made. SUMMARY OF THE INVENTION An object of the present invention is to provide a method and an apparatus for extracting a difference character string between structured HTML or SGML documents in a manner suited to the linguistic sense of the document editor. Another object of the present invention is to provide a method and an apparatus for managing the edition of a structured document for a document processing system capable of managing the edition on the basis of comparison and discrimination of the logical structures of structured documents. In order to achieve the above-mentioned objects there is provided a structured document difference extraction method according to claim 1 and a structured document difference extraction apparatus according to claim 4. The subclaims relate to preferred embodiments thereof. The comparison criterion includes tags indicating logical structures and types of comparison criterion corresponding to the tags with the contents thereof being stored in a table. The tags are defined to be ones of the following four types of comparison criterion: (1) Tags having the contents which are compared only when the particular tags are coincident with each other (identity tags) (2) Tags having the contents the difference of which is ignored at the time of comparison (ignoring tags) (3) A set of tags identical to each other in logical meaning (equivalence tags, such as "FIRST ITEM" and "ITEM") (4) A set of tags having the contents which are not compared with each other (no-comparison tags) Furthermore, a document tree representing the structure of each structured document is produced and the difference between the structured documents is extracted by comparison between the nodes of the respective document trees. In the case where given nodes are non-coincident with each other, the difference is extracted between the nodes by comparison between the characters of the nodes. In addition, in producing a document tree or hierarchy representing each document structure the allocation of the nodes of the document trees is altered in accordance with the comparison criterion described above. With the solutions as described above, structured documents are edited, the logical structure of the structured documents edited is analyzed by the structured document parsing means, a comparison criterion used for extracting the difference corresponding to the logical structure is set in advance, and a difference character string between the structured documents before and after edition is extracted in such a manner as to meet the comparison criterion. The more relevant difference conforming with the linguistic sense of the editor can thus be automatically extracted in accordance with the logical structure. Also, the difference is extracted by node between document trees, whereas the difference between non-coincident nodes is extracted by character, so that an erroneous extraction of the difference over different structures can be eliminated. BRIEF DESCRIPTION OF THE DRAWINGS Fig. 1 is a block diagram showing the configuration of an embodiment of the present invention. Fig. 2A is a diagram showing the processing steps according to an embodiment of the invention. Fig. 2B is a flowchart showing a detailed example of steps of producing a document tree shown in Fig. 2A. Figs. 3A, 3B are diagrams showing a first example of structured documents before and after edition, respectively. Figs. 4A, 4B are diagrams showing the first example of the structured documents before and after difference extraction, respectively according to the prior art. Figs. 5A, 5B are diagrams showing a second example of structured documents before and after edition, respectively. Figs. 6A, 6B are diagrams showing the second example of the structured documents before and after difference extraction, respectively according to the prior art. Figs. 7A, 7B are diagrams showing a third example of structured documents before and after edition, respectively. Figs. 8A, 8B are diagrams showing the third example of the structured documents before and after difference extraction, respectively according to the prior art method. Fig. 9 shows an example comparison criterion table for the first example of structured documents according to the present invention. Figs. 10A, 10B are diagrams showing document trees produced from the first example of structured documents before and after edition shown in Figs. 3A, 3B on the basis of the comparison criterion table of Fig. 9. Fig. 10C is a flow diagram showing production procedure for document tree of Fig. 10A. Figs. 11A, 11B are diagrams showing the first example of the structured documents before and after difference extraction, respectively based on the comparison criterion table of Fig. 9. Fig. 12 shows an example comparison criterion table for the second example of the structured documents shown in Fig. 5. Figs. 13A, 13B are diagrams showing document trees produced from the second example of the structured documents before and after edition shown in Figs. 5A, 5B, respectively on the basis of the comparison criterion table of Fig. 12. Figs. 14A, 14B are diagrams showing the second example of the structured documents of Figs. 5A, 5B before and after difference extraction, respectively based on the comparison criterion table of Fig. 12. Fig. 15 shows an example comparison criterion table for a third example of the structured documents shown in Figs. 7A, 7B. Figs. 16A, 16B are diagrams showing document trees produced from the third example of the structured documents before and after edition shown in Figs. 7A, 7B, respectively on the basis of the comparison criterion table of Fig. 15. Figs. 17A, 17B are diagrams showing the third example of structured documents of Figs. 7A, 7B before and after difference extraction, respectively based on the comparison criterion table of Fig. 15. Figs. 18A, 18B are diagrams showing a fourth example of structured documents before and after edition, respectively. Fig. 19 shows an example comparison criterion table for the fourth example of the structured documents shown in Fig. 18. Figs. 20A, 20B are diagrams showing document trees produced from the fourth example of the structured documents before and after edition, respectively shown in Fig. 18 on the basis of the comparison criterion table of Fig. 19. Figs. 21A, 21B are diagrams showing the fourth example of structured documents shown in Fig. 18 before and after difference extraction, respectively based on the comparison criterion table of Fig. 19. Fig. 22 is a flowchart showing another embodiment of the invention. Figs. 23A, 23B are diagrams showing an example comparison of documents to be compared according to the embodiment of Fig. 22. Figs. 24A, 24B are diagrams showing an example result of comparison between the structured documents of Figs. 23A, 23B, respectively. Fig. 25 is a diagram showing an example structured document representing the structured document difference data. Figs. 26A, 26B are diagrams showing an example of structured documents displayed on the screen before and after edition, respectively. Fig. 27 is a diagram showing an example of a structured document difference data displayed on the screen. DESCRIPTION OF THE PREFERRED EMBODIMENTS Embodiments of the invention will be described below with reference to the accompanying drawings. Fig. 1 shows the configuration of an embodiment of the invention. In Fig. 1, a reference numeral 101 designates a CPU, numeral 102 a terminal device including an input/output device, a display device and a program storage loading device 103A on which a processing program storing medium such as a floppy disk or the like is mounted, and numeral 103 a memory unit for storing documents and/or a processing program, capable of functioning as a program storage alternative to the floppy disk. The CPU 101 has executably set therein a document editing program 104 for editing documents, a structured document parsing program 105 for converting each structured document into a tree configuration, a structured document difference extraction program 106 for extracting non-coincident portions of the structured documents as a difference, and a comparison criterion table 107 for storing comparison criteria for extraction of difference character strings. These programs can be supplied to the CPU 101 in a form stored in the floppy disk in advance. Each of the structured documents according to this embodiment assumes the form of an SGML document. SGML, as described above, is defined as a document description language set as an ISO world standard of marked structured documents. SGML documents have the logical structure thereof defined in advance by the document type definition (DTD). Nevertheless, it should be understood that the present embodiment is applicable also to the processing of structured documents having a function analogous to SGML. Specific processing steps according to the present embodiment will be described with reference to the flowcharts of Figs. 2A and 2B. Step 201: Structured documents are edited by the document editing program 104 Step 202: The comparison criterion table 107 corresponding to the DTD of the SGML documents to be compared is read into the work area of the CPU 101. In the absence of a comparison criterion table corresponding to the DTD of the SGML documents, an appropriate table is prepared and entered in advance. This comparison criterion table is one including tags satisfying the following four criteria: (1) Identity tag: It represents different tags allowing the respective contents thereof, i.e., the characters sandwiched between the start and end ones of the respective tags to be compared with each other only when the tag pairs are coincident with each other (2) Ignoring tag: It represents a tag having the contents the difference of which is ignored at the time of comparison (3) Equivalence tags: These represent a set of apparently different tags having the same logical meaning (4) No-comparison tags: These represent a set of tags which negate the comparison of the contents thereof with each other Step 203: When the difference extraction program 106 is called in Fig. 2A, the structured documents are analyzed by the structured document parsing program 105 by reference to the comparison criterion table 107 thereby to prepare document trees. The steps of an parsing program for the structured documents are shown in detail in Fig. 2B. In the process, the elements allocated to each node of the document tree are determined according to the rules established as follows: Rule 1: Allocate each tag to a node. Rule 2: Allocate the character strings sandwiched between a start tag and an end tag to a child node of the start tag. Rule 3: Allocate each end tag to a child node of the start tag associated with the particular end tag. Rule 4: Allocate the character strings sandwiched between identity tags to a single node together with the starting and end tags thereof. Rule 5: Don't allocate ignoring tags and the character strings sandwiched between the ignoring tags to any node. Rule 6: Allocate equivalence tags to nodes by converting the apparently different names thereof into an identical tag name. Step 204: The document trees prepared by the above-mentioned steps are compared by node with each other and the difference is extracted by node. In the case where the tags to be compared are no-comparison tags, the particular nodes and underlying nodes (child nodes) are not compared. Step 205: The difference is extracted, this time, by character, only for the nodes found non-coincident. For a node of an identity tag, however, comparison by character is made only when the leading character (string) constituting a tag of the node is coincident. The ignoring tags that were not compared at step 204 are compared at the present step. Step 206: The difference extraction output of step 205 is displayed on the display unit of the terminal device 102 (step 206A). At the same time, the same difference output can be supplied to a difference data utilization device in parallel to the display unit. The CPU 101 can automatically execute such processes as updating and revision of relevant parameters in accordance with the difference output. These functions can be considered as a review. Fig. 2B shows the process of parsing structured documents in steps 301 to 311. Processing Example 1 A specific example of processing according to the embodiment having an identity tag is described below with reference to the example documents shown in Figs. 3A and 3B. Step 201: The structured documents are edited by the document editing program 104 (Fig. 1). The document of Fig. 3B is assumed to have been edited from that of Fig. 3A. Step 202: The comparison criterion table 107 corresponding to the DTD of the SGML documents to be compared is read out to the CPU 101. In the absence of a corresponding comparison criterion table, an appropriate table is first produced and entered. A comparison criterion table as shown in Fig. 9, for example, is produced from Figs. 3A and 3B. Specifically, "<NAME>" and "<TRANSMISSION DATE>" are defined as identity tags, which means that character strings are not matched unless the tags are coincident between the documents to be compared. Step 203: Once the difference extraction program 106 is called, the structured documents to be compared are analyzed by the structured document parsing program 105 while referring to the comparison criterion table 107, thereby producing corresponding document trees. By applying the rules described above with reference to an embodiment, the document trees of Figs. 10A, 10B are produced from the structured documents of Figs. 3A, 3B respectively by referring to the comparison criterion table of Fig. 9. Structured documents 1001, 1002 in Figs. 10A, 10B have identity tags and therefore the tags and content characters thereof are allocated collectively to a single node according to Rule 4. The process of producing document trees of Figs. 10A, 10B for difference extraction is shown as steps 401 to 406 in Fig. 10C. Step 204: The difference is extracted by node between the document trees. Since comparison is made by node, " <NAME> " and "<TRANSMISSION DATE>" which are identity tags are not matched as long as the particular tags and the character strings of the contents thereof are both coincident with each other. In such a case, due to the non-coincidence between the tags 1001 and 1002, both the tags and the contents thereof are extracted as a difference. Step 205: The difference between non-coincident nodes is extracted by character. Nodes having an identity tag, however, are compared by character only in the case where the leading character string constituting each of the tags of the respective nodes is coincident. Step 206: The resulting difference is displayed on the terminal device 102. An example result of difference extraction between the documents of Figs. 3A and 3B is shown in Fig. 11. Fig. 11B shows the result of extracting difference character strings taken of the structured document of Fig. 3B as compared with the structured document of Fig. 3A. Fig. 11A, on the other hand, shows the result of extracting difference character strings taken of the structured document of Fig. 3A as compared with the structured document of Fig. 3B. In Fig. 11B, the tag marks "<NAME>" and "<TRANSMISSION DATE>" of nodes 1001 and 1002 fail to coincide with each other, and therefore the character string "<TRANSMISSION DATE> NOVEMBER 20, SIXTH YEAR OF HEISEI .</TRANSMISSION DATE>" of node 1002 is extracted in its entirety as a difference. Also, since Fig. 3A contains no description of "ARE YOU FINE" in Fig. 3B, "ARE YOU FINE" is extracted as a difference. If the difference extraction is executed according to the above-mentioned steps, as long as a tag containing the characters the comparison of which is meaningless in the absence of tag coincidence is entered as an identity tag, structured documents of non-coincident logical structures are not matched with each other. A more appropriate difference extraction result thus can be presented to the editor. Processing Example 2 The document examples of Figs. 5A, 5B will be explained as a second specific process according to the embodiment with reference to the case having both an identity tag and an ignoring tag and involving a structural displacement. Step 201: Structured documents are edited by the document editing program 104. The document of Fig. 5B is assumed to have been edited from the document of Fig. 5A. Step 202: The comparison criterion table 107 corresponding to the DTD of the SGML document to be compared is read at this step. In the absence of a corresponding comparison criterion table, an appropriate table is produced and entered. In the case of Figs. 5A, 5B, for example, a comparison criterion table as shown in Fig. 12 is produced. Specifically, "<AUTHOR NAME>" is defined as an identity tag. In this case, as described above, the character strings are compared with each other only when the tags are coincident with each other. Also, "<CHAPTER NUMBER>" is defined as an ignoring tag. In this case, the difference in chapter number is ignored. This is because it has no effect on difference extraction. Step 203: Once the difference extraction program 106 is called, the SGML documents are analyzed by the structured document parsing program 105, and corresponding document trees are produced while referring to the comparison criterion table 107. By application of the rules explained with reference to an embodiment above, the document trees of Figs. 13A, 13B are produced by referring to the comparison criterion table of Fig. 12 from the documents of Figs. 5A, 5B. "<CHAPTER NUMBER>" providing an ignoring tag is not allocated as a node according to Rule 5 above. Step 204: The difference between document trees is extracted by node. The ignoring tags, which are not present as a node, are not compared and have no effect on the whole process of difference extraction. Step 205: The difference between non-coincident nodes is extracted by character string. The ignoring tags and the contents thereof that were not compared at step 204 are also compared at this step. Step 206: The resulting difference is displayed on the terminal device 102. An example result of difference extraction between the documents of Figs. 5A and 5B is shown in Figs. 14A, 14B. Fig. 14B shows the result of extracting a difference character string taken of the structured document of Fig. 5B as compared with the structured document of Fig. 5A. Fig. 14A, on the other hand, is a diagram showing the result of extracting a difference character string taken of the structured document of Fig. 5A as compared with the structured document of Fig. 5B. Explanation will be made about the case in which the difference is taken of the structured document of Fig. 5B as compared with the structured document of Fig. 5A and the result of extracting the difference character string is obtained as shown in Fig. 14B. In the difference extraction by node between document trees at step 204, "<TREATISE>", "</TREATISE>", "<AUTHOR NAME> TARO HEISEI </AUTHOR NAME>", and "<CHAPTER> STRUCTURED DOCUMENT DIFFERENCE EXTRACTION METHOD </CHAPTER>" are determined to be coincident in Figs. 13A, 13B, so that they are displayed as coincident parts in Fig. 14B. Since step 204 decides that "<CHAPTER> STRUCTURED DOCUMENT DIFFERENCE EXTRACTION METHOD </CHAPTER>" is coincident, step 205 decides that "<CHAPTER NUMBER> and </CHAPTER NUMBER>" associated with the coincident part is also coincident. On the other hand, "CHAPTER 2", which is not coincident with "CHAPTER 1", is extracted as a difference and displayed as shown in Fig. 14B. Also, due to the decision at step 204 that "<CHAPTER> WHAT IS STRUCTURED DOCUMENT? </CHAPTER>" in Fig. 13B is not coincident, this "<CHAPTER> WHAT IS STRUCTURED DOCUMENT? </CHAPTER>" and "<CHAPTER NUMBER> CHAPTER 1 </CHAPTER NUMBER>" associated with the particular non-coincident part are extracted as a difference and displayed as shown in Fig. 14B. In the difference extraction according to the steps described above, document trees are compared by node, i.e., by structure, and therefore nodes 1301 and 1302, for example, are matched in this process. As a result, it is seen that an erroneous matching does not occur over different structures as shown in Fig. 6. Since comparison of document trees by node includes no comparison between ignoring tags, any difference in the contents of the ignoring tags is seen to have no effect on the difference extraction process as a whole. Processing Example 3 A third specific processing example according to an embodiment having an identity tag and an equivalence tag will be explained with reference to the example documents of Figs. 7A, 7B. Step 201: Structured documents are edited by the document editing program 104. It is assumed that the document of Fig. 7B is edited from the document of Fig. 7A. Step 202: A comparison criterion table 107 corresponding to the DTD of the SGML documents to be compared is read at this step. In the absence of a corresponding comparison criterion table, an appropriate table is produced and entered. In the case of Figs. 7A, 7B, a comparison criterion table as shown in Fig. 15 is produced. In other words, "<AUTHOR NAME>" is defined as an identity tag. In this case, as long as given tags fail to coincide with each other, the character strings associated with them are not matched. Also, "<ITEM>" and "<FIRST ITEM>" are defined as equivalence tags. In the last case, "<ITEM>" and "<FIRST ITEM>" are considered to have the same logical structure. Step 203: Once the difference extraction program 106 is called, the SGML document is analyzed by the structured document parsing program 105 and document trees are produced while referring to the comparison criterion table 107. Application of the rules described above with reference to an embodiment permits the document trees of Figs. 16A, 16B to be produced from the documents of Figs. 7A, 7B respectively by reference to the comparison criterion table of Fig. 15. Nodes 1601, 1602, 1603 in Fig. 16 are converted into the same tag name under Rule 6. Step 204: The difference between the document trees is extracted by node. The equivalence tags are given the same tag name and therefore are not extracted as a difference. Step 205: Only those tags which are found non-coincident with each other are extracted, this time, by character. Step 206: The resulting difference is displayed on the terminal device 102. An example of extracting the difference between the documents of Figs. 7A, 7B is shown in Figs. 17A, 17B. Fig. 17B shows the result of extracting difference character strings taken of the structured document of Fig. 7B as compared with the structured document of Fig. 7A, and Fig. 17A is the result of extracting difference character strings taken of the structured document of Fig. 7A as compared with the structured document of Fig. 7B. Explanation will be made about the case in which the difference is taken of the structured document of Fig. 7B as compared with the structured document of Fig. 7A and the extraction result of Fig. 17B is obtained. In extracting the difference between the document trees by node at step 204, it is decided in Figs. 16A, 16B that "<TREATISE>", "</TREATISE>", "<AUTHOR NAME> TARO HEISEI </AUTHOR NAME>", and "<ITEM> STRUCTURED DOCUMENT DIFFERENCE EXTRACTION METHOD </ITEM>" are determined to be coincident, and are displayed as coincident parts in Fig. 17B. Next, due to the decision at step 204 that "<ITEM> WHAT IS STRUCTURED DOCUMENT? </ITEM>" is non-coincident, step 205 extracts the difference of the non-coincident part by character, so that "<ITEM> WHAT IS STRUCTURED DOCUMENT ? </ITEM>" is extracted as a difference and displayed as shown in Fig. 17B. Upon extraction of the difference according to the steps described above, the documents having the same logical structure are seen to be matched with each other despite the difference in tag name. Processing Example 4 A fourth specific processing example according to an embodiment will be explained with reference to the documents of Figs. 18A, 18B having a no-comparison tag. Step 201: A structured document is edited by the document editing program 104. The document of Fig. 18B is assumed to be edited from the document of Fig. 18A. Step 202: A comparison criterion table 107 is read in which corresponds to the DTD of the SGML document to be compared. In the absence of a corresponding comparison criterion table, an appropriate table is produced and entered. In the case of Figs. 18A, 18B, for example, a comparison criterion table as shown in Fig. 19 is produced. In other words, "<SENDER>" and "<RECEIVER>" are assumed to have a no-comparison tag. In this case, "<SENDER>" and "<RECEIVER>" are not compared in contents. Step 203: Once the difference extraction program 106 is called, the SGML document is analyzed by the structured document parsing program 105 and a document tree is produced while referring to the comparison criterion table 107. By applying the rules described above with reference to an embodiment, the document trees of Figs. 20A, 20B are completed from the documents of Figs. 18A, 18B by referring to the comparison criterion table of Fig 19. Step 204: The difference between document trees is extracted by node. "<SENDER>" and "<RECEIVER>" have tags of no-comparison type, and therefore underlying nodes, that is, "<ORGANIZATION>" and " <NAME> providing child nodes, are not compared. Step 205: The difference between only those nodes which are non-coincident with each other is extracted, this time, by character. Step 206: The resulting difference is displayed on the terminal device 102. An example of extracting the difference between the documents of Figs. 18A, 18B is shown in Fig. 21. Fig. 21B shows the result of extracting the difference character string taken of the structured document of Fig. 18B as compared with the structured document of Fig. 18A, and Fig. 21A the result of extracting the difference character string taken of the structured document of Fig. 18A as compared with the structured document of Fig. 18B. Explanation will be made about the case in which the difference is taken of the structured document of Fig. 18B as compared with the structured document of Fig. 18A thereby to obtain the result of extracting the difference character string shown in Fig. 21B. In extracting the difference between the document trees by node at step 204, as shown in Figs. 18A, 18B, "<MEMO>", "</MEMO>", "<TEXT>" and "</TEXT>" are determined to be coincident with each other, while "<RECEIVER>", "</RECEIVER>" and the contents thereof including "<ORGANIZATION> 00 BANK </ORGANIZATION>" and "<NAME> TARO HEISEI </NAME>" are determined to be a difference, since "<SENDER>" and "<RECEIVER>" are a no-comparison tag. "HELLOW, ARE YOU FINE? " is determined to be non-coincident. Due to the non-coincidence decision on "HELLOW, ARE YOU FINE?" at step 204, step 205 extracts the difference by character for the non-coincident part, so that "ARE YOUR FINE?" is extracted as a difference. As a consequence, the document as shown in Fig. 21B is displayed. In the difference extraction following the steps described above, once tags with the contents thereof not compared are entered as no-comparison tags, underlying nodes (child nodes) are not compared, and therefore the organizations and the names contained in "<SENDER>" and "<RECEIVER>" are not matched with each other, thereby making it possible to present a more appropriate result of difference extraction to the editor. Another embodiment of the invention is shown in Fig. 22. The difference information which is extracted as a change between structured documents before and after edition using the scheme as disclosed in the above-mentioned embodiments has the following features different from comparison between non-structrured documents: (1) the change of the structure per se and the change of character strings in the structure are involved; and (2) the difference information has a logical structure. This will be described with reference to structured documents shown in Figs. 23A and 23B. Fig. 24A shows an example result of comparing a structured document a before edition with a structured document a ' after edition shown in Figs. 23A and 23B. Item 1 (601) and item 3 (603) represent an example in which the character strings in a structure are altered without altering the document structures including "<NAME>" and "<TEXT>". Item number 2 (602) shows an example in which the structure of "<ORGANIZATION>" is newly inserted. Now, an example will be explained in which the difference information between structured documents has a logical structure. For example, item number 1 (601) and item number 3 (603) represent an alteration in character string. If the difference information is to be expressed by specifying a structure, for example, to the effect that the character string alteration is one occurring in the structure of "<NAME>" and "<TEXT>" respectively, then the difference data is required to have structural information. Also, item number 2 (602) has structural information that the inserted "<ORGANIZATION>", which lies within the framework of the logical structure "<SENDER>", is a child structure of "<SENDER>". According to the prior art method, however, these characteristics of the difference data of structured documents could not be displayed effectively. According to the prior art method, even if an alteration is one of information relating to the logical structure of a document, it is displayed by altering the display attribute of the character indicating the structure without discriminating it from an alteration in the character string. The resulting problem is that it is difficult for the user to determine whether the structure or the content of the structure is altered. This problem is described with reference to a specific example. Fig. 24B shows an example display of difference data according to a comparative example of JP-A-7-200370. In this display method, the structural information is ignored without discriminating the alteration of a structure from that of a character string in the structure. Consequently, the actual alteration that is executed cannot be easily understood by the user who edits the structured document by means of a document editing software or the like. Also, in the case where the document editing software or the like uses a dedicated display program by expressing the structural information in a tree for displaying a structured document, a separate display program is required for displaying the difference data such as shown in Figs. 24A, 24B, thereby inconveniently complicating the program. The embodiment of Fig. 22, as compared with the embodiment of Fig.1 in which the altered parts between structured documents are extracted on the basis of logical structure information, is different in that step 507 is added for displaying and storing (editing) the difference information from a structured difference information output step 505. Steps 501 to 506, therefore, are substantially similar to steps 201 to 206 in Fig. 1. Step 507 displays the resulting difference on the terminal device 102 according to a display/preserve program 110, and stores the structured difference data in a secondary memory unit 103. Since the difference data as illustrated in Fig. 25 is output in SGML form, the difference data can be displayed directly using an editor or a viewer exclusive to SGML. Figs. 26A and 26B show an example structured document displayed on a dedicated SGML editor, and Fig. 27 an example display of the difference data. In Figs. 26A, 26B, numeral 2301 designates a window for displaying the structure, and numeral 2302 a window for displaying the character strings in the structure. Fig. 27 shows an example window displaying the difference data of Fig. 25 in structured form. In the process, an alteration of a structure is displayed by altering the color or type of the mark representing the structure, by defining the altered part by a solid line or by otherwise discriminating the altered part. An altered part of a character string is also displayed in discrimination from other character strings in similar fashion. These discriminated display may be highlighted. With the foregoing steps, the difference data can be directly displayed in structured form by incorporating this scheme in the SGML document edition software as a document comparison function. By discriminating an alteration in a structure from that of a character string in a structure, for example, the actual alteration can be easily understood by the user editing the structured document by means of the document edition software or the like. Also, even in the case where the document edition software or the like uses a dedicated program for indicating structural information by a tree when displaying a structured document, an altered part can be displayed without any independent display program. Similarly to the embodiment of Fig. 2A, the structured difference data may be used to update and/or revise structured documents to be edited in the step 507 or after completion of editing using known document (update) processing programs. It will thus be understood from the foregoing description that according to the present invention, a comparison criterion corresponding to a logical structure of a structured document is defined, and the difference of a structured document to be compared is extracted in such a manner as to meet the comparison criterion, whereby a difference conforming with the sense of the editor is extracted in accordance with the meaning of the logical structure. Also, the difference between document trees representing structures is extracted by node, and any difference between the non-coincident nodes of the documents to be compared is extracted by character. Consequently, a difference over different structures, if any, is not extracted, with the result that the editor can grasp the difference suitable for the particular logical structure, thereby improving the efficiency of editing a structured document. The present invention is effectively applicable to automatic updating of documents likely to be revised including various legal documents and operation manuals described in SGML or the like language. Further, the efficient edition according to the invention is effective for managing plates of documents which are required to be updated frequently.

Claims: A structured document difference extraction method in which structured documents before and after editing including deletion, insertion or change are stored in a memory unit (103), and a character string non-coincident between the structured documents before and after said editing is extracted as a difference by a processor(101), said method comprising the steps of: editing and storing (201) structured documents before and after editing in said memory unit (103); defining (202) a comparison criterion for the logical structure of each of said structured documents before and after editing, said comparison criterion having at least one tag representing a logical structure and a type of comparison criterion for said at least one tag; parsing (203) a logical structure of each of the structured documents before and after editing read from said memory unit (103) on the basis of said comparison criterion; and extracting (204, 205) a difference between the structured documents which can satisfy said comparison criterion with respect to the result of said parsing. The method of claim 1, further comprising the steps of: producing (203) a document tree representing a document structure by parsing each of said structured documents; extracting (204) the difference between the document trees by node as the difference between the structured documents; and extracting (205) the difference by character between non-coincident nodes. The method of claim 2, further comprising the step of altering the method of allocating the nodes of a document tree representing the document structure in accordance with said comparison criterion at the time of producing said document tree by parsing said structured document. A structured document difference extraction apparatus comprising a memory unit (103) for storing structured documents before and after executing editing including deletion, insertion or change, and a processor (101) for extracting a non-coincident character string between the two structured documents before and after editing as a difference, wherein said processor includes: means (104) for editing and storing the structured documents in said memory unit (103); means for defining a comparison criterion for the logical structure of each of said structured documents before and after editing, said comparison criterion having at least one tag representing a logical structure and a type of comparison criterion for said at least one tag; means (105) for parsing a logical structure of the structured documents before and after editing read from said memory unit (103) on the basis of said comparison criterion; and means (106) for extracting a difference between the structured documents so as to satisfy said comparison criterion in accordance with the result of parsing of the structured documents. The method of claim 1 or the apparatus of claim 4, wherein said comparison criterion is stored into a table (107). The method or apparatus of claim 5, wherein the tags are defined to have one of at least four types of comparison criterion including: tags having contents which are compared only when the particular tags are coincident with each other, tags having contents the difference of which is ignored at the time of comparison, a set of tags having the same logical meaning, and a set of tags having contents which are not compared with each other. The apparatus of any one of claims 4 to 6, wherein said structured document parsing means (105) is adapted to produce at least one document tree representing the document structure, and said structured document difference extraction means (106) is adapted to extract the difference between the document trees by node as the difference between the structured documents, the difference being extracted by character between non-coincident nodes. The apparatus of claim 7, wherein said structured document parsing means (105) is adapted to alter the allocation of the nodes of a document tree representing the document structure in accordance with said comparison criterion at the time of producing the document tree. The apparatus of claim 4, further comprising: structured document display means (102) for outputting the result of a difference extracted by said structured document difference extraction means (106), as difference information to display the difference result on the basis of the structured difference information; and document update means (103A) for updating/revising structured documents to be updated/revised on the basis of said structured difference information produced by said structured document difference extraction means (106). A processor-readable medium storing program codes for allowing a computer comprising a memory unit (103) and a processor (101) to extract a non-coincident character string between structured documents before and after editing by executing the method of any one of claims 1, 2, 3, 5 or 6. The medium of claim 10, further comprising a program code section (206, 506) for causing the computer to apply to a utilisation means the extracted difference between the structured documents.

Inventors: AOYAMA YUKI, HIGASHINO JUNICHI, AOYAMA, YUKI, HIGASHINO, JUNICHI, Aoyama, Yuki, Rumieru Miyamaedaira 306
Applicants: HITACHI LTD, HITACHI, LTD.
Application year: 1996
Main classification: G06F17
IPC codes: G06F17