The present invention relates to a document processing technique, and particularly to a document processing apparatus and a document processing method for processing a structured document having a hierarchical structure.
The XML (Extensible Markup Language) has been attracting attention as a format that allows the user to share data with other users via a network. This promotes the development of applications for creating, displaying, and editing XML documents (see Patent document 1, for example). The XML documents are created based upon a vocabulary (tag set) defined according to a document format definition.
XML permits the user to use multiple vocabularies in a single document. However, in some cases, such multiple vocabularies have the same element names or the same attribute names. In such a case, different elements having the same element name or different attributes having the same attribute name clash with one another. That is to say, this leads to a problem in that the vocabulary to which the element type or the attribute type belongs cannot be identified. In order to solve such a problem, XML introduced the “namespace” concept, which describes the vocabulary to which the element types and the attribute types used in a document belong.
However, a problem remains in such a technique as follows. That is to say, in a case that a description is missing or erroneous, the namespace cannot be identified, leading to a situation in which the document cannot be properly processed.
Japanese Patent Application Laid-open No. 2001-290804
The present invention has been made in view of the aforementioned problems. Accordingly, it is an object of the present invention to provide a technique for performing proper processing for a structured document even if the information such as the namespace cannot be identified, thereby allowing such a document to be displayed and edited smoothly.
An aspect according to the present invention relates to a document processing apparatus. The document processing apparatus comprises: a namespace detection unit for detecting a namespace to which elements included in a document described in a markup language belong; and a namespace identifying unit having a function whereby, in a case that the correct namespace has not been detected, multiple document display files are applied to the document, and the display candidates thus created are displayed so as to allow the user to input an instruction to select a display candidate, thereby enabling the namespace to be identified. With such an arrangement, the document is displayed based upon the namespace, identified by the namespace detection unit or the namespace identifying unit, in a manner that allows the user to edit the document thus displayed.
The “markup language” may be a kind of XML, e.g., XHTML (Extensible HyperText markup Language), SVG (Scalable Vector Graphics), MathML (Mathematical Markup Language), etc. Also, examples of the markup languages include SGML (Standard Generalized Markup Language), HTML (HyperText Markup Language), etc. On the other hand, examples of the “multiple document display files” include: a file in which a definition has been described for translating a structured document such as an XML document such that it is displayed in the form of an XHTML document; a file for translating such a structured document such that it is displayed in the form of an SVG document; and a file for translating such a structured document such that it is displayed in the form of a MathML document; etc. Also, the “document display file” may be an executable program file such as a plug-in etc., for displaying a structured document such as an XML document etc. Examples of such executable program files include: a plug-in for displaying an XHTML document; a plug-in for displaying an SVG document; a plug-in for displaying a MathML document; etc.
Also, with the document processing apparatus, the namespace identifying unit may extract keywords from the document based upon a predetermined condition, and may narrow down the namespace candidates based upon the keywords thus extracted. Furthermore, the namespace identifying unit may apply the multiple document display files, which correspond to the respective namespace candidates, to the document. Also, the document processing apparatus may further comprise a namespace information storage unit for storing the information with respect to the relation between the keyword and corresponding namespace, and which is used as a reference when the namespace identifying unit narrows down the namespace candidates. Here, the keyword may be the element name (tag name), the attribute name, or the like, which has been described in the document, and which allows the namespace to be presumed.
The namespace information storage unit may store the information with respect to the relation between the namespace to which the elements included in a document belong, and the keywords included in the document, for every prior document each time a document is processed.
Another aspect according to the present invention relates to a document processing method. The document processing method comprises: a step for detecting a namespace to which elements included in a document described in a markup language belong; a step whereby, in a case that the correct namespace has not been detected, multiple document display files are applied to the document, and display is performed; and a step for identifying the namespace by receiving a selection instruction from the user with respect to the screen thus displayed. With such an arrangement, the document is displayed based upon the namespace thus detected or identified in a manner that allows the user to edit the document.
Note that any combination of the aforementioned components or any manifestation of the present invention realized by replacement of a system, a recording medium, and so forth, is effective as an embodiment of the present invention.
The present invention provides a technique for supporting appropriate processing for an structured document.
a) is a diagram which shows an example of a definition file used for mapping the XML document shown in
b) is a diagram which shows an example of a definition file used for mapping the XML document shown in
Description will be made below regarding the background technique for the present invention before detailed description of the present embodiment.
The main control unit 22 provides for the loading of a plug-in or a framework for executing a command. The editing unit 24 provides a framework for editing XML documents. Display and editing functions for a document in the document processing apparatus 20 are realized by plug-ins, and the necessary plug-ins are loaded by the main control unit 22 or the editing unit 24 according to the type of document under consideration. The main control unit 22 or the editing unit 24 determines which vocabulary or vocabularies describes the content of an XML document to be processed, by referring to a name space of the document to be processed, and loads a plug-in for display or editing corresponding to the thus determined vocabulary so as to execute the display or the editing. For instance, an HTML unit 50, which displays and edits HTML documents, and an SVG unit 60, which displays and edits SVG documents, are implemented in the document processing apparatus 20. That is, a display system and an editing system are implemented as plug-ins for each vocabulary (tag set), so that when an HTML document and an SVG document are edited, the HTML unit 50 and the SVG unit 60 are loaded, respectively. As will be described later, when compound documents, which contain both the HTML and SVG components, are to be processed, both the HTML unit 50 and the SVG unit 60 are loaded.
By implementing the above structure, a user can select so as to install only necessary functions, and can add or delete a function or functions at a later stage, as appropriate. Thus, the storage area of a recording medium, such as a hard disk, can be effectively utilized, and the wasteful use of memory can be prevented at the time of executing programs. Furthermore, since the capability of this structure is highly expandable, a developer can deal with new vocabularies in the form of plug-ins, and thus the development process can be readily facilitated. As a result, the user can also add a function or functions easily at low cost by adding a plug-in or plug-ins.
The editing unit 24 receives an event, which is an editing instruction, from the user via the user interface. Upon reception of such an event, the editing unit 24 notifies a suitable plug-in or the like of this event, and controls the processing such as redoing this event, canceling (undoing) this event, etc.
The DOM unit 30 includes a DOM provider 32, a DOM builder 34 and a DOM writer 36. The DOM unit 30 realizes functions in compliance with a document object model (DOM), which is defined to provide an access method used for handling data in the form of an XML document. The DOM provider 32 is an implementation of a DOM that satisfies an interface defined by the editing unit 24. The DOM builder 34 generates DOM trees from XML documents. As will be described later, when an XML document to be processed is mapped to another vocabulary by the VC unit 80, a source tree, which corresponds to the XML document in a mapping source, and a destination tree, which corresponds to the XML document in a mapping destination, are generated. At the end of editing, for example, the DOM writer 36 outputs a DOM tree as an XML document.
The CSS unit 40, which provides a display function conforming to CSS, includes a CSS parser 42, a CSS provider 44 and a rendering unit 46. The CSS parser 42 has a parsing function for analyzing the CSS syntax. The CSS provider 44 is an implementation of a CSS object and performs CSS cascade processing on the DOM tree. The rendering unit 46 is a CSS rendering engine and is used to display documents, described in a vocabulary such as HTML, which are laid out using CSS.
The HTML unit 50 displays or edits documents described in HTML. The SVG unit 60 displays or edits documents described in SVG. These display/editing systems are realized in the form of plug-ins, and each system is comprised of a display unit (also designated herein as a “canvas”) 56 and 66, which displays documents, a control unit (also designated herein as an “editlet”) 52 and 62, which transmits and receives events containing editing commands, and an edit unit (also designated herein as a “zone”) 54 and 64, which edits the DOM according to the editing commands. Upon the control unit 52 or 62 receiving a DOM tree editing command from an external source, the edit unit 54 or 64 modifies the DOM tree and the display unit 56 or 66 updates the display. These units have a structure similar to the framework of the so-called MVC (Model-View-Controller). With such a structure, in general, the display units 56 and 66 correspond to “View”. On the other hand, the control units 52 and 62 correspond to “Controller”, and the edit units 54 and 64 and DOM instance corresponds to “Model”. The document processing apparatus 20 according to the background technique allows an XML document to be edited according to each given vocabulary, as well as providing a function of editing the HTML document in the form of tree display. The HTML unit 50 provides a user interface for editing an HTML document in a manner similar to a word processor, for example. On the other hand, the SVG unit 60 provides a user interface for editing an SVG document in a manner similar to an image drawing tool.
The VC unit 80 includes a mapping unit 82, a definition file acquiring unit 84 and a definition file generator 86. The VC unit 80 performs mapping of a document, which has been described in a particular vocabulary, to another given vocabulary, thereby providing a framework that allows a document to be displayed and edited by a display/editing plug-in corresponding to the vocabulary to which the document is mapped. In the background technique, this function is called a vocabulary connection (VC). In the VC unit 80, the definition file acquiring unit 84 acquires a script file in which the mapping definition is described. Here, the definition file specifies the correspondence (connection) between the nodes for each node. Furthermore, the definition file may specify whether or not editing of the element values or attribute values is permitted. Furthermore, the definition file may include operation expressions using the element values or attribute values for the node. Detailed description will be made later regarding these functions. The mapping unit 82 instructs the DOM builder 34 to generate a destination tree with reference to the script file acquired by the definition file acquiring unit 84. This manages the correspondence between the source tree and the destination tree. The definition file generator 86 offers a graphical user interface which allows the user to generate a definition file.
The VC unit 80 monitors the connection between the source tree and the destination tree. Upon reception of an editing instruction from the user via a user interface provided by a plug-in that handles a display function, the VC unit 80 first modifies a relevant node of the source tree. As a result, the DOM unit 30 issues a mutation event indicating that the source tree has been modified. Upon reception of the mutation event thus issued, the VC unit 80 modifies a node of the destination tree corresponding to the modified node, thereby updating the destination tree in a manner that synchronizes with the modification of the source tree. Upon reception of a mutation event that indicates that the destination tree has been modified, a plug-in having functions of displaying/editing the destination tree, e.g., the HTML unit 50, updates a display with reference to the destination tree thus modified. Such a structure allows a document described in any vocabulary, even a minor vocabulary used in a minor user segment, to be converted into a document described in another major vocabulary. This enables such a document described in a minor vocabulary to be displayed, and provides an editing environment for such a document.
An operation in which the document processing apparatus 20 displays and/or edits documents will be described herein below. When the document processing apparatus 20 loads a document to be processed, the DOM builder 34 generates a DOM tree from the XML document. The main control unit 22 or the editing unit 24 determines which vocabulary describes the XML document by referring to a name space of the XML document to be processed. If the plug-in corresponding to the vocabulary is installed in the document processing apparatus 20, the plug-in is loaded so as to display/edit the document. If, on the other hand, the plug-in is not installed in the document processing apparatus 20, a check shall be made to see whether a mapping definition file exists or not. And if the definition file exits, the definition file acquiring unit 84 acquires the definition file and generates a destination tree according to the definition, so that the document is displayed/edited by the plug-in corresponding to the vocabulary which is to be used for mapping. If the document is a compound document containing a plurality of vocabularies, relevant portions of the document are displayed/edited by plug-ins corresponding to the respective vocabularies, as will be described later. If the definition file does not exist, a source or tree structure of a document is displayed and the editing is carried out on the display screen.
Here, the document processing apparatus 20 according to the background technique does not have a plug-in which conforms to or handles the display/editing of marks managing vocabularies. Accordingly, before displaying such a document in a manner other than the source display manner or the tree display manner, the above-described VC function is used. That is, there is a need to prepare a definition file for mapping the document, which has been described in the marks managing vocabulary, to another vocabulary, which is supported by a corresponding plug-in, e.g., HTML or SVG. Note that description will be made later regarding a user interface that allows the user to create the user's own definition file. Now, description will be made below regarding a case in which a definition file has already been prepared.
a) and
On the screen as shown in
Viewers or editors which can handle major vocabularies such as XHTML, MathML and SVG have already been developed. However, it does not serve any practical purpose to develop dedicated viewers or editors for such documents described in the original vocabularies as shown in
For example, when the source display and tree-view display are implemented by dedicated plug-ins, the source-display plug-in and the tree-display plug-in execute their respective displays by directly referring to the source tree without involving the destination tree. In this case, when the editing is done in any area of the screen, the source-display plug-in and the tree-display plug-in update the screen by referring to the modified source tree. Also, the HTML unit 50 in charge of displaying the area 96 updates the screen by referring to the destination tree, which has been modified following the modification of the source tree.
The source display and the tree-view display can also be realized by utilizing the VC function. That is to say, an arrangement may be made in which the source and the tree structure are laid out in HTML, an XML document is mapped to the HTML structure thus laid out, and the HTML unit 50 displays the XML document thus mapped. In such an arrangement, three destination trees in the source format, the tree format and the table format are generated. If the editing is carried out in any of the three areas on the screen, the VC unit 80 modifies the source tree and, thereafter, modifies the three destination trees in the source format, the tree format and the table format. Then, the HTML unit 50 updates the three areas of the screen by referring to the three destination trees.
In this manner, a document is displayed on a single screen in a plurality of display formats, thus improving a user's convenience. For example, the user can display and edit a document in a visually easy-to-understand format using the table 90 or the like while understanding the hierarchical structure of the document by the source display or the tree display. In the above example, a single screen is partitioned into a plurality of display formats, and they are displayed simultaneously. Also, a single display format may be displayed on a single screen so that the display format can be switched according to the user's instructions. In this case, the main control unit 22 receives from the user a request for switching the display format and then instructs the respective plug-ins to switch the display.
The displayed menu may be switched corresponding to the position of the cursor (carriage) during the editing of a document. That is, when the cursor lies in an area where an SVG document is displayed, the menu provided by the SVG unit 60, or a command set which is defined in the definition file for mapping the SVG document, is displayed. On the other hand, when the cursor lies in an area where the XHTML document is displayed, the menu provided by the HTML unit 50, or a command set which is defined in the definition file for mapping the HTML document, is displayed. Thus, an appropriate user interface can be presented according to the editing position.
In a case that there is neither a plug-in nor a mapping definition file suitable for any one of the vocabularies according to which the compound document has been described, a portion described in this vocabulary may be displayed in source or in tree format. In the conventional practice, when a compound document is to be opened where another document is embedded in a particular document, their contents cannot be displayed without the installation of an application to display the embedded document. According to the background technique, however, the XML documents, which are composed of text data, may be displayed in source or in tree format so that the contents of the documents can be ascertained. This is a characteristic of the text-based XML documents or the like.
Another advantageous aspect of the data being described in a text-based language, for example, is that, in a single compound document, a part of the compound document described in a given vocabulary can be used as reference data for another part of the same compound document described in a different vocabulary. Furthermore, when a search is made within the document, a string of characters embedded in a drawing, such as SVG, may also be search candidates.
In a document described in a particular vocabulary, tags belonging to other vocabularies may be used. Though such an XML document is generally not valid, it can be processed as a valid XML document as long as it is well-formed. In such a case, the tags thus inserted that belong to other vocabularies may be mapped using a definition file. For instance, tags such as “Important” and “Most Important” may be used so as to display a portion surrounding these tags in an emphasized manner, or may be sorted out in the order of importance.
When the user edits a document on an edit screen as shown in
Depending on the contents of the editing, modification of the display by the HTML unit 50 may change the overall layout. In such a case, the layout is updated by a screen layout management mechanism, e.g., the plug-in that handles the display of the highest node, in increments of display regions which are displayed according to the respective plug-ins. For example, in a case of expanding a display region managed by the HTML unit 50, first, the HTML unit 50 renders a part managed by the HTML unit 50 itself, and determines the size of the display region. Then, the size of the display area is notified to the component that manages the screen layout so as to request the updating of the layout. Upon receipt of this notice, the component that manages the screen layout rebuilds the layout of the display area for each plug-in. Accordingly, the display of the edited portion is appropriately updated and the overall screen layout is updated.
Let us say that an information processing apparatus according to an embodiment of the present invention is configured on the basis of the aforementioned background technique, and the information processing apparatus according to the present embodiment includes the document processing apparatus according to the aforementioned background technique in the form of a part of the present embodiment. Now, description will be made in the present embodiment regarding an arrangement that provides a function of processing a document file structured with XML, which is an example of a structured document.
Examples of the keywords used for narrowing down the namespace candidates include the file type extension included in the file name of a processing target XML document. Also, such examples include a combination of the file type extension, the tag names, and the attribute names.
Also, an arrangement may be made in which, in a case that the namespace has not been detected based upon the tag names in S30, the candidate screen display unit 314 displays the source code or the tree structure of the XML document. In this case, such an arrangement may notify the user to the effect that the namespace cannot be detected. Also, an arrangement may be made which allows the user to directly edit the XML document, e.g., which allows the user to insert the namespace URI into the XML document.
Such an arrangement has a function of automatically narrowing down the namespace candidates, and providing the namespace candidates thus narrowed down, even if the description with respect to the information that allows the namespace to be identified is missing or erroneous. This enables the user to perform the document processing smoothly by without troublesome operations, e.g., a manual search for the portion where the namespace is missing, a manual search for the namespace, etc. Thus, such an arrangement reduces the time cost. Furthermore, the present embodiment can be employed as a technique for avoiding the system crashes which often occur in reading out such an XML document. Such an arrangement allows the user to restore the document while validating it by eye, thereby offering a user-friendly document processing apparatus which is easy to understand.
With the background technique of the present embodiment, an XML document is mapped to HTML or SVG using the VC function based upon the definition file that corresponds to the vocabulary of the XML document, thereby enabling the document to be edited and displayed using the plug-in for the mapping destination.
Description has been made with reference to
Examples of the methods for searching for the namespace include a rule-based technique, and probabilistic methods such as the SVM, the Bayes theorem, etc.
On the other hand, the probabilistic method provides probability calculation based upon a tag name count. The probabilistic method is based upon the fact that an XHTML document has a number of “p” tags and “div” tags, and a MathML document has a number of “mi” tags and “mo” tags, for example. Before the search for the namespace using the probabilistic method, documents for which the namespace has been confirmed are read out beforehand in the form of teacher data, and the namespaces of the documents, the tag names included in the documents, and the tag name counts of the tag names included in the documents are stored in the namespace information storage unit 316. In these processing steps, the namespace detection unit 310 and the namespace identifying unit 312 provide the tag name extraction function. That is to say, these processing steps are achieved by transporting data from the namespace detection unit 310 and the namespace identifying unit 312 to the namespace information storage unit 316. Now, let us consider a case in which an XML document for which the namespace cannot be identified is processed. In this case, the tag names extracted from the processing target document by the namespace identifying unit 312 are compared with the tag names which have been extracted from the teacher data and which have been stored in the namespace information storage unit 316. Then, a predetermined calculation is performed while referring to each namespace to which the tag name extracted by the comparison belongs. Also, an arrangement may be made employing a rule in which the probability is weighted with an weighting factor adjusted for each layer such that the shallower the tag name layer is, the greater the weighting factor is. This improves the probability precision.
Also, an arrangement may be made in which the information with respect to the XML document is stored in the namespace information storage unit 316 in the form of teacher data each time an XML document, including a description that allows the namespace to be identified, is processed. Such an arrangement enables the namespace information to be stored corresponding to the way the individual user tends to operate his/her own document processing apparatus. At the same time, the least probable namespace candidates are eliminated from the candidates. Such an arrangement allows the namespace candidate to be effectively narrowed down.
Description has been made regarding the present invention with reference to the embodiments. The above-described embodiments have been described for exemplary purposes only, and are by no means intended to be interpreted restrictively. Rather, it can be readily conceived by those skilled in this art that various modifications may be made by making various combinations of the aforementioned components or processes, which are also encompassed in the technical scope of the present invention. Some of such possible modifications will be listed below.
Description has been made in the embodiment regarding an arrangement for processing an XML document. Also, the document processing apparatus 300 has a function of processing other markup languages, e.g., SGML, HTML, etc.
Also, an arrangement may be made in which the namespace identifying unit 312 applies all the plug-ins that can be installed to the processing target document, and displays all the screens that can be displayed such that they conform to the vocabulary of the processing target document, on the candidate screen display unit 314 without narrowing down the namespace candidates. After the display candidates are displayed, such an arrangement allows the user to input an instruction to select the screen display candidate in the same way as the above-described technique, thereby identifying the namespace. Such an arrangement reduces calculation costs for the step of narrowing down the namespace candidates. Such an arrangement is effectively applied to a case for handling a small total number of plug-ins. Also, an arrangement may be made in which all the definition files, based upon the background technique, that can be read out are applied to the processing target document, and all the screens that can be displayed are displayed so as to allow the user to input an instruction to select the display candidate. With such an arrangement, the definition files may be stored at positions that differ from one another according to the processing type. Furthermore, such an arrangement may allow the user to specify the reference position before the definition file is applied to the document. Such an arrangement provides the same advantages as those provided by the aforementioned arrangement in which the definition files that are to be applied to the document are narrowed down. Accordingly, such an arrangement allows the document to be effectively displayed and edited even if the document is an XML document having no information that would allow the namespace to be identified, and having no declared definition file. Also, XSLT (Extensible Stylesheet Language Transformations) or other XML display scripts may be applied to the document, in addition to the definition files based upon the background technique. With such an arrangement, in a case that any of the display candidates thus created can be displayed, determination is made that the namespace that corresponds to the display candidate that can be displayed is a namespace that conforms to the vocabulary of the translated document. In this case, such an arrangement provides an option to display and edit the processing target XML document using the plug-in that corresponds to the namespace thus determined.
The present invention can be applied to a document processing apparatus for processing a structured document.
Number | Date | Country | Kind |
---|---|---|---|
2004-187910 | Jun 2004 | JP | national |
Filing Document | Filing Date | Country | Kind | 371c Date |
---|---|---|---|---|
PCT/JP05/11666 | 6/24/2005 | WO | 00 | 12/22/2006 |