JP2012073706A - Structured document storage device, structured document storage method and structured document storage program - Google Patents
Structured document storage device, structured document storage method and structured document storage program Download PDFInfo
- Publication number
- JP2012073706A JP2012073706A JP2010216420A JP2010216420A JP2012073706A JP 2012073706 A JP2012073706 A JP 2012073706A JP 2010216420 A JP2010216420 A JP 2010216420A JP 2010216420 A JP2010216420 A JP 2010216420A JP 2012073706 A JP2012073706 A JP 2012073706A
- Authority
- JP
- Japan
- Prior art keywords
- node
- search
- structured document
- order
- value
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Pending
Links
Images
Landscapes
- Machine Translation (AREA)
- Document Processing Apparatus (AREA)
- Information Retrieval, Db Structures And Fs Structures Therefor (AREA)
Abstract
Description
本発明は構造化文書格納装置、構造化文書格納方法及び構造化文書格納プログラムに係り、特にXML(拡張可能なマーク付け言語;Extensible Markup Language)に代表される構造化文書を格納する構造化文書格納装置、構造化文書格納方法及び構造化文書格納プログラムに関する。 The present invention relates to a structured document storage device, a structured document storage method, and a structured document storage program, and more particularly to a structured document that stores a structured document represented by XML (Extensible Markup Language). The present invention relates to a storage device, a structured document storage method, and a structured document storage program.
XMLに代表される構造化文書を格納し、格納した構造化文書を構成する要素を高速に検索する方法として、構造化文書を表形式のテーブルから成るリレーショナルデータベースに格納する方法がある。 As a method of storing a structured document represented by XML and searching for elements constituting the stored structured document at high speed, there is a method of storing the structured document in a relational database composed of tabular tables.
例えば、特許文献1には、XMLデータの各エレメントの内容及び属性値の項目と、データ間のリンク関係をテーブルに格納するとともに、データの出現順に順番号を割り当て、データの順番号と親エレメントの順番号をテーブルに格納するXMLデータの格納方法が開示されている。この特許文献1記載のXMLデータ、すなわち構造化文書の格納方法では、テーブルに格納されているエレメントの順番号及びそのエレメントの親エレメントの順番号により、エレメント間の親子関係を高速に判別できるとともに、データ間の階層関係についても判別可能である。
For example, in
しかしながら、特許文献1に記載の構造化文書の格納方法では、エレメント間の先祖・子孫関係を即座に判別することができない。あるいは、エレメント間の親子関係を順次判別しながらエレメントを辿ることにより先祖・子孫関係を判別する方法も考えられるが、その方法では高速に判別することはできないことが課題である。
However, the structured document storage method described in
本発明は上記の点に鑑みなされたもので、構造化文書を構成するノード間の先祖・子孫関係を高速に判別することを可能とする構造化文書格納装置、構造化文書格納方法及び構造化文書格納プログラムを提供することを目的とする。 The present invention has been made in view of the above points, and provides a structured document storage device, a structured document storage method, and a structured document that can quickly determine an ancestor-descendant relationship between nodes constituting a structured document. An object is to provide a document storage program.
上記目的を達成するため、第1の発明の構造化文書格納装置は、構造化文書を解析して、その構造化文書に含まれるノードに関する情報を出力する構造化文書解析手段と、構造化文書のノードに関する情報が格納されるノードテーブルを有する記憶手段と、構造化文書解析手段から出力された構造化文書のノードに関する情報中の対象ノードの出現順を表す順番号を決定すると共に、対象ノードより後に情報中に出現するノードのうち対象ノードの子孫ノードを除いて最も先に出現するノードの順番号を対象ノードに付す次番号として決定し、対象ノードに関する情報と共に順番号と次番号とをノードテーブルに格納する格納手段と、供給される検索手順リストに従い、ノードテーブルの格納情報を参照して検索結果を出力する検索手段とを備え、検索手段は、格納情報中の比較元ノードの順番号が比較先ノードの順番号より大きく、かつ、比較元ノードの順番号が比較先ノードの次番号より小さいときに、比較元ノードが比較先ノードの子孫ノードであると判断する子孫ノード検索手段を有することを特徴とする。 In order to achieve the above object, a structured document storage device according to a first aspect of the invention comprises a structured document analyzing means for analyzing a structured document and outputting information about nodes included in the structured document, and a structured document. A storage means having a node table for storing information relating to the nodes of the node, a sequence number representing the order of appearance of the target nodes in the information relating to the nodes of the structured document output from the structured document analyzing means, and a target node The order number of the node that appears first in the information excluding the descendant node of the target node is determined as the next number to be assigned to the target node, and the order number and the next number together with the information about the target node are determined. Storage means for storing in the node table and search means for outputting the search result by referring to the storage information of the node table according to the supplied search procedure list When the order number of the comparison source node in the stored information is larger than the order number of the comparison destination node and the order number of the comparison source node is smaller than the next number of the comparison destination node, the search means It is characterized by having descendant node search means for judging that it is a descendant node of the comparison destination node.
また、上記の目的を達成するため、第2の発明の構造化文書格納装置は、第1の発明における上記構造化文書が、出現順が定義される第1のノードと、出現順が定義されない第2のノードとを含み、格納手段が、第1のノードの順番号に、その第1のノードの出現順に2ずつ増加する0以上の整数を割り当て、第2のノードの順番号に、その第2のノードの一つ上位のノードである親ノードの順番号に1を加算した値を割り当て、子孫ノード検索手段が、比較元ノードの順番号が比較先ノードの順番号に1を加算した値より大きく、かつ、比較元ノードの順番号が比較先ノードの次番号より小さいときに、比較元ノードが比較先ノードの子孫ノードであると判断することを特徴とする。 In order to achieve the above object, the structured document storage device according to the second aspect of the invention is characterized in that the structured document in the first aspect is not defined with the first node in which the order of appearance is defined and the order of appearance. And the storage means assigns an integer greater than or equal to 0 that increases by 2 in the order of appearance of the first node to the order number of the first node, and the order number of the second node A value obtained by adding 1 to the order number of the parent node that is one node above the second node is assigned, and the descendant node search means adds the order number of the comparison source node to the order number of the comparison destination node. The comparison source node is determined to be a descendant node of the comparison destination node when the value is larger than the value and the order number of the comparison source node is smaller than the next number of the comparison destination node.
また、上記の目的を達成するため、第3の発明の構造化文書格納方法は、構造化文書を解析して、その構造化文書に含まれるノードに関する情報を出力する構造化文書解析ステップと、構造化文書解析ステップにより解析して得られた構造化文書のノードに関する情報中の対象ノードの出現順を表す順番号を決定すると共に、対象ノードより後に情報中に出現するノードのうち対象ノードの子孫ノードを除いて最も先に出現するノードの順番号を対象ノードに付す次番号として決定し、対象ノードに関する情報と共に順番号と次番号とを、構造化文書のノードに関する情報が格納されるノードテーブルに格納する格納ステップと、供給される検索手順リストに従い、ノードテーブルの格納情報を参照して検索結果を出力する検索ステップとを備え、検索ステップは、格納情報中の比較元ノードの順番号が比較先ノードの順番号より大きく、かつ、比較元ノードの順番号が比較先ノードの次番号より小さいときに、比較元ノードが比較先ノードの子孫ノードであると判断する子孫ノード検索ステップを含むことを特徴とする。 In order to achieve the above object, a structured document storage method according to a third aspect of the invention comprises a structured document analysis step of analyzing a structured document and outputting information on nodes included in the structured document; A sequence number representing the appearance order of the target node in the information related to the node of the structured document obtained by the structured document analysis step is determined, and the target node among the nodes appearing in the information after the target node is determined. A node in which the order number of the node that appears first except for the descendant node is determined as the next number to be assigned to the target node, and the order number and the next number are stored together with the information about the target node, and the information about the node of the structured document is stored. A storage step for storing in the table, and a search step for outputting the search result by referring to the storage information of the node table according to the supplied search procedure list. In the search step, when the sequence number of the comparison source node in the stored information is larger than the sequence number of the comparison destination node and the sequence number of the comparison source node is smaller than the next number of the comparison destination node, the comparison source node The method includes a descendant node search step for determining that the node is a descendant node of the comparison destination node.
また、上記の目的を達成するため、第4の発明の構造化文書格納方法は、第3の発明における構造化文書が、出現順が定義される第1のノードと、出現順が定義されない第2のノードとを含み、格納ステップが、第1のノードの順番号に、その第1のノードの出現順に2ずつ増加する0以上の整数を割り当て、第2のノードの順番号に、その第2のノードの一つ上位のノードである親ノードの順番号に1を加算した値を割り当て、子孫ノード検索ステップが、比較元ノードの順番号が比較先ノードの順番号に1を加算した値より大きく、かつ、比較元ノードの順番号が比較先ノードの次番号より小さいときに、比較元ノードが比較先ノードの子孫ノードであると判断することを特徴とする。
In order to achieve the above object, the structured document storage method according to the fourth aspect of the present invention is the structured document according to the third aspect, in which the first node in which the order of appearance is defined and the order in which the order of appearance is not defined. And the storing step assigns an integer greater than or equal to 0 increasing in order of appearance of the first node to the sequence number of the first node, and assigns the sequence number of the second node to the sequence number of the first node. A value obtained by adding 1 to the order number of the parent node that is one node higher than the
また、上記の目的を達成するため、第5の発明の構造化文書格納プログラムは、コンピュータに、第3の発明の構造化文書格納方法における構造化文書解析ステップ、格納ステップ、及び子孫ノード検索ステップを含む検索ステップを実行させることを特徴とする。 In order to achieve the above object, a structured document storage program according to a fifth aspect of the present invention provides a computer with a structured document analysis step, a storage step, and a descendant node search step in the structured document storage method of the third aspect of the invention. A search step including: is executed.
更に、上記の目的を達成するため、第6の発明の構造化文書格納プログラムは、第5の発明における構造化文書が、出現順が定義される第1のノードと、出現順が定義されない第2のノードとを含み、格納ステップが、第1のノードの順番号に、その第1のノードの出現順に2ずつ増加する0以上の整数を割り当て、第2のノードの順番号に、その第2のノードの一つ上位のノードである親ノードの順番号に1を加算した値を割り当て、上記子孫ノード検索手段が、比較元ノードの順番号が比較先ノードの順番号に1を加算した値より大きく、かつ、比較元ノードの順番号が比較先ノードの次番号より小さいときに、比較元ノードが比較先ノードの子孫ノードであると判断する構成である。
Furthermore, to achieve the above object, the structured document storage program according to the sixth aspect of the invention is the structured document according to the fifth aspect, in which the appearance order is not defined in the first node in which the order of appearance is defined. And the storing step assigns an integer greater than or equal to 0 increasing in order of appearance of the first node to the sequence number of the first node, and assigns the sequence number of the second node to the sequence number of the first node. A value obtained by adding 1 to the order number of the parent node that is one node higher than the
本発明によれば、格納された構造化文書のノード間の先祖・子孫関係を検索する手順を従来に比べて短時間で行うことができ、その結果、従来に比べて構造化文書の検索を高速に行うことができる。 According to the present invention, the procedure for searching the ancestor-descendant relationship between the nodes of the stored structured document can be performed in a short time compared to the conventional method. As a result, the structured document can be searched compared with the conventional method. It can be done at high speed.
以下、発明を実施するための形態について図面と共に詳細に説明する。 DESCRIPTION OF EMBODIMENTS Hereinafter, embodiments of the present invention will be described in detail with reference to the drawings.
図1は、本発明になる構造化文書格納装置の一実施の形態のブロック図を示す。 FIG. 1 shows a block diagram of an embodiment of a structured document storage apparatus according to the present invention.
図1に示すように、本実施の形態の構造化文書格納装置1は、XML解析部101と、格納部102と、リレーショナルデータベース103と、クエリ(XQuery)解析部104と、検索部105と、XML成形部106とから構成されている。この構造化文書格納装置1は、入力された構造化文書であるXML文書をリレーショナルデータベース103に格納するとともに、入力された検索クエリに従ってXML文書内を検索部105で検索し、検索クエリに合致するノードのリストを検索結果として出力する構造化文書格納装置である。
As shown in FIG. 1, the structured
XML解析部101は、テキストデータとして入力されたXML文書を解析し、XML文書を構成する各ノードに対応するオブジェクトを木構造に配置したDOM(文書オブジェクトモデル;Document Object Model)データを生成して格納部102へ供給する。
The XML analysis unit 101 analyzes an XML document input as text data, and generates DOM (Document Object Model) data in which objects corresponding to each node constituting the XML document are arranged in a tree structure. The data is supplied to the
ここで、XML文書の概要について説明する。周知のように、XML文書では、「<要素名>」で表される開始タグと「</要素名>」で表される終了タグとの間にテキストや要素の集合を記述する。また、1つのタグで完結する要素は、空要素と呼ばれる。また、開始タグ、または空要素タグの中に「<要素名 属性名=“属性値”>」のように属性を記述することができる。また、構造化文書であるXML文書は、XMLの論理構造に基づいて木構造に変換できる。XML文書の各要素、属性やテキストは、木構造においてノードと呼ばれる。 Here, an outline of the XML document will be described. As is well known, in an XML document, a set of text and elements is described between a start tag represented by “<element name>” and an end tag represented by “</ element name>”. An element completed with one tag is called an empty element. In addition, an attribute can be described as “<element name attribute name =“ attribute value ”>” in the start tag or empty element tag. An XML document that is a structured document can be converted into a tree structure based on the XML logical structure. Each element, attribute, and text of the XML document is called a node in the tree structure.
このノードにおいて、「親ノード」、「子ノード」、「子孫ノード」、「先祖ノード」という表現が用いられることがある。「親ノード」は、処理対象ノードの一つ上位のノードであり、「子ノード」は、処理対象ノードの一つ下位のノードであり、「子孫ノード」は、処理対象ノードの全下位ノードを示し、「先祖ノード」は、処理対象ノードの全上位ノードを示す。なお、要素はノードの一種であるので、開始タグは「<ノード名>」、終了タグは「</ノード名>」で表されると表現することもできる。 In this node, the expressions “parent node”, “child node”, “descendant node”, and “ancestor node” may be used. The “parent node” is a node one level higher than the processing target node, the “child node” is a node one level lower than the processing target node, and the “descendant node” is all the lower level nodes of the processing target node. “Ancestor node” indicates all upper nodes of the processing target node. Since the element is a kind of node, the start tag can be expressed as “<node name>” and the end tag can be expressed as “</ node name>”.
格納部102は、XML解析部101からDOMデータが供給されると、供給されたDOMデータによって表わされるXML文書をリレーショナルデータベース103に格納するものであり、その機能上、ノードID決定手段102aと、順番号決定手段102bと、ノードデータ挿入手段102cと、属性データ挿入手段102dと、属性格納手段102eと、子ノード格納手段102fとを備える。
When the DOM data is supplied from the XML analysis unit 101, the
ノードID決定手段102aは、処理対象ノードを一意に識別するノードIDを決定する。具体的には、ノードID決定手段102aは、リレーショナルデータベース103内のノードテーブル2に格納されている、いずれのノードIDとも一致しない0以外の正の整数を選択し、それを処理対象ノードのノードIDとする。
The node ID determination unit 102a determines a node ID that uniquely identifies the processing target node. Specifically, the node ID determination unit 102a selects a positive integer other than 0 that does not match any of the node IDs stored in the node table 2 in the
順番号決定手段102bは、処理対象ノードに対し、ノードの出現順を表す順番号を決定する。さらに、順番号決定手段102bは、処理対象ノードに対し、処理対象ノードより後に出現するノードのうち処理対象ノードの子孫ノードを除いて最も先に出現するノードの順番号である次番号を決定する。ただし、処理対象ノードより後に出現するノードが全て処理対象ノードの子孫ノードである場合、次番号は、処理対象ノードより後に処理対象ノードの子孫ノードではない仮想ノードが存在すると仮定した場合の仮想ノードの順番号となる。 The order number determination unit 102b determines the order number representing the order of appearance of the nodes for the processing target node. Further, the sequence number determination unit 102b determines the next number, which is the sequence number of the node that appears first, excluding the descendant nodes of the node to be processed among the nodes that appear after the node to be processed. . However, if all nodes that appear after the processing target node are descendant nodes of the processing target node, the next number is a virtual node when it is assumed that there is a virtual node that is not a descendant node of the processing target node after the processing target node It becomes order number.
ノードデータ挿入手段102cは、処理対象ノードのノードデータをリレーショナルデータベース103内のノードテーブル2に挿入する。属性データ挿入手段102dは、処理対象ノードがノードの一種である属性である場合に、処理対象属性の属性データをリレーショナルデータベース103内のノードテーブル2に挿入する。
The node data insertion unit 102 c inserts the node data of the processing target node into the node table 2 in the
属性データ挿入手段102eは、処理対象ノードが保持する属性、すなわち処理対象ノードの子ノードである属性を格納する処理を行う。子ノード格納手段102fは、処理対象ノードの属性以外の子ノードを格納する処理を行う。 The attribute data insertion unit 102e performs processing for storing an attribute held by the processing target node, that is, an attribute that is a child node of the processing target node. The child node storage unit 102f performs processing for storing child nodes other than the attribute of the processing target node.
リレーショナルデータベース103は、例えばハードディスク等の記憶装置と、記憶装置を読み書きしてリレーショナルデータベースとしての機能を提供する処理部とにより構成され、表形式のノードテーブル2を有し、ノードテーブル2に格納されたデータを検索する機能を備える。
The
XQuery解析部104は、XQuery(XMLクエリ言語;XML Query Language)の形式で記述された検索クエリが入力されると、入力された検索クエリを解析し、検索処理を実行するための検索手順リストを生成して検索部105へ供給する。XQueryは、XMLデータを検索する問い合わせ言語として策定されている。
When a search query described in the XQuery (XML Query Language) format is input, the
検索部105は、XQuery解析部104から検索手順リストが供給されると、供給された検索手順リストに従ってリレーショナルデータベース103に格納されているXML文書に対する検索を実行し、検索結果であるサブツリーデータのリストをXML成形部106へ供給するものであり、その機能上、検索制御手段105aと、ノード型検索手段105bと、ノード名検索手段105cと、ノード値検索手段105dと、子ノード検索手段105eと、親ノード検索手段105fと、子孫ノード検索手段105gと、先祖ノード検索手段105hと、サブツリーデータ抽出手段105iとを備える。
When the search procedure list is supplied from the
検索制御手段105aは、検索部105における検索処理の全体を制御する。ノード型検索手段105bは、検索手順がノード型検索である場合に、ノード型による検索を実行する。ノード名検索手段105cは、検索手順がノード名検索である場合に、ノード名による検索を実行する。ノード値検索手段105dは、検索手順がノード値検索である場合に、ノード値による検索を実行する。
The search control unit 105 a controls the entire search process in the
子ノード検索手段105eは、検索手順が子ノード検索である場合に、子ノードの検索を実行する。親ノード検索手段105fは、検索手順が親ノード検索である場合に、親ノードの検索を実行する。子孫ノード検索手段105gは、検索手順が子孫ノード検索である場合に、子孫ノードの検索を実行する。先祖ノード検索手段105hは、検索手順が先祖ノード検索である場合に、先祖ノードの検索を実行する。 The child node search means 105e executes a child node search when the search procedure is a child node search. When the search procedure is a parent node search, the parent node search unit 105f executes a parent node search. The descendant node search means 105g executes a search for a descendant node when the search procedure is a descendant node search. The ancestor node search means 105h executes ancestor node search when the search procedure is ancestor node search.
サブツリーデータ抽出手段105iは、検索結果のノードリストの各ノードのサブツリーデータをリレーショナルデータベース103から読み出し、読み出したサブツリーデータをノードデータに含まれる順番号の順に並び替えてXML成形部106へ供給する。「ノードのサブツリーデータ」とは、XML文書の木構造において、対象ノードと、対象ノードの下位となる全てのノード(子孫ノード)を含むサブツリーの各ノードのノードデータである。
The subtree data extraction unit 105i reads the subtree data of each node in the node list of the search result from the
なお、検索部105は、XQueryによって記述できる検索手順のうち、本発明に直接関係する検索手順、及び代表的な検索手順を実行するための各検索手段105b乃至105hを備える構成となっているが、XQueryによって記述できるその他の検索手順を実行するための検索手段をも備える構成とするのが望ましい。
The
XML成形部106は、検索部105からサブツリーデータのリストが供給されると、供給されたサブツリーデータをテキストデータとして記述されたXML文書の形式に成形し、検索結果として出力する。
When the subtree data list is supplied from the
次に、構造化文書格納装置1のリレーショナルデータベース103におけるノードデータを格納するための表形式のノードテーブルの構成について説明する。
Next, the configuration of a tabular node table for storing node data in the
図2は、リレーショナルデータベース103におけるノードテーブルの構成を示す。図2において、ノードテーブル2の「列名」の欄はテーブルの各列の名前を示し、「内容」の欄は各列に格納するデータの内容を示す。
FIG. 2 shows the configuration of the node table in the
ノードテーブル2は、id列201と、type列202と、parent列203と、order列204と、next列205と、name列206と、value列207とにより構成される。
The node table 2 includes an
id列201は、対象ノードを一意に識別するノードIDである0以外の正の整数を格納する列である。type列202は、対象ノードのノード型(type)を表す数値を格納する列である。parent列203は、対象ノードの親ノードのノードIDである「0」以外の整数、または親ノードが存在しないことを示す数値「0」を格納する列である。
The
order列204は、対象ノードの順番号を格納する列である。なお、XMLではノードの種別によって出現順が定義されるノードと定義されないノードがあるが、order列204に格納される順番号は、出現順が定義されるノードに対してはその出現順に「0」から始まる2つおきの整数を割り振った偶数の値となり、出現順が定義されないノードに対してはその親ノードの出現順に「1」を加えた奇数の値となる。
The
next列205は、対象ノードの次番号を格納する列である。ただし、対象ノードが出現順が定義されないノードである場合は順番号と同じ値を格納する。name列206は、対象ノードのノード名(name)を格納する列である。ただし、対象ノードのノード種別がノード名を持たないものである場合、name列206は空(ヌル)となる。value列207は、対象ノードのノード値(value)を格納する列である。ただし、対象ノードのノード種別がノード値を持たないものである場合、value列207は空(ヌル)となる。
The
次に、図2の本発明の一実施形態である構造化文書格納装置1のノードテーブル2におけるtype列202に格納されるノード型を表す数値について説明する。
Next, numerical values representing the node types stored in the
図3は、ノードテーブル2におけるtype列202に格納されるノード型の一覧を示す。図3の「type値」の欄はノードテーブル2におけるtype列202に格納されるノード型を表す数値を示し、「ノード型」の欄は「type値」に対応するノード型を示すものである。
FIG. 3 shows a list of node types stored in the
ノード型には、要素(Element)301と、属性(Attribute)302と、テキストノード(Text Node)303と、CDATAセクション(CDATA Section)304と、エンティティ参照(Entity Reference)305と、エンティティ(Entity)306と、処理命令(Processing Instruction)307と、コメント(Comment)308と、文書(Document)309と、文書型(Document Type)310と、文書断片(Document Fragment)311と、表記法(Notation)312とがある。これらの各ノード型に対して、「type値」欄に示す数値が割り振られる。
The node type includes an element 301, an
なお、XMLにおいて、属性302以外のノード型はノードの出現順が定義されるが、属性302は出現順が定義されないものである。すなわち、同一のノードで構成される2つのXML文書において、属性302以外のノードの出現順が異なる場合は異なるXML文書となるが、属性302の見かけ上の出現順が異なる場合は同一のXML文書となる。
In XML, a node type other than the
また、XMLにおいて、属性302を含む一部のノード型は子ノードを持たないものである。また、XMLにおいて、処理対象ノードの子孫ノードには、処理対象ノードの保持する属性、すなわち処理対象ノードの子ノードとなる属性は含まれない。
Also, in XML, some node types including the
次に、本発明の一実施形態である構造化文書格納装置1の格納部102における文書格納処理の詳細について説明する。
Next, details of document storage processing in the
図4は、本実施の形態の構造化文書格納装置1の格納部102における文書格納処理を説明するフローチャートを示す。
FIG. 4 is a flowchart for explaining document storage processing in the
格納部102のノードID決定手段102aは、XML解析部101からDOMデータが供給されると、文書格納処理を開始し、変数pに「0」を代入する(ステップS401)。なお、変数pは親ノードのノードIDを記憶しておくための変数である。次に、格納部102の順番号決定手段102bは、変数oに「0」を代入する(ステップS402)。なお、変数oは順番号を記憶しておくための変数である。
When the DOM data is supplied from the XML analysis unit 101, the node ID determination unit 102a of the
次に、格納部102の子ノード格納手段102fは、ルートノードを処理対象ノードとする(ステップS403)。なお、ルートノードは親ノードを持たないノードであり、ノードテーブル2におけるparent列203の値が「0」となるものである。そして、格納部102は、後述するノード格納処理を実行する(ステップS404)。なお、ステップS401で値を代入した変数p、ステップS402で値を代入した変数o、及びステップS403で決定した処理対象ノードはノード格納処理に引き継ぐ。
Next, the child node storage unit 102f of the
次に、図4の構造化文書格納装置1の格納部102における文書格納処理のステップS404のノード格納処理の詳細について説明する。
Next, details of the node storage process in step S404 of the document storage process in the
図5は、本実施の形態の構造化文書格納装置1の格納部102におけるノード格納処理を説明するフローチャートを示す。
FIG. 5 is a flowchart for explaining node storage processing in the
格納部102のノードID決定手段102aは、ノード格納処理を開始すると、ステップS403またはステップS515で決定した処理対象ノードのノードIDを決定し、決定したノードIDを変数iに代入する(ステップS501)。具体的には、ノードテーブル2のid列201に格納されているいずれのノードIDとも一致しない「0」以外の正の整数を選択し、ノードIDとする。
When the node ID determination unit 102a of the
次に、格納部102のノードID決定手段102aは、変数pの値を処理対象ノードの親ノードID、すなわちノードテーブル2のparent列203に挿入すべき値とする(ステップS502)。次に、格納部102の順番号決定手段102bは、変数oの値を処理対象ノードの順番号、すなわちノードテーブル2のorder列204に挿入すべき値とする(ステップS503)。
Next, the node ID determination unit 102a of the
次に、格納部102のノードデータ挿入手段102cは、処理対象ノードの次番号以外のノードデータをノードテーブル2に挿入する(ステップS504)。具体的には、ステップS501で変数iに代入したノードIDをid列201のノードIDの値とし、処理対象ノードのDOMオブジェクトからノード型を取得して、ノード型一覧3におけるそのノード型に対応するtype値をtype列202の値とする。また、ステップS502で決定した親ノードIDをparent列203の値とし、ステップS503で決定した順番号をorder列204の値とする。更に、処理対象ノードのDOMオブジェクトからノード名を取得して、そのノード名をname列206の値とし、処理対象ノードのDOMオブジェクトからノード値を取得して、その値をvalue列207の値として、ノードテーブル2に新たな行を追加する。なお、追加する行のnext列205は空(ヌル)にしておく。
Next, the node data insertion unit 102c of the
次に、格納部102のノードID決定手段102aは、変数iの値を変数pに代入する(ステップS505)。次に、格納部102の順番号決定手段102bは、変数oの値に「1」を加算して変数oに代入する(ステップS506)。次に、格納部102の属性格納手段102eは、処理対象ノードが持つ属性、すなわち処理対象ノードの子ノードである属性の数を変数Naに代入し、変数aに「0」を代入する(ステップS507)。続いて、格納部102の属性格納手段102eは、変数aの値が変数Naの値より小さいか否かを判定する(ステップS508)。変数aの値が変数Naの値より小さいと判定された場合、ステップS509へ処理を移行し、変数Naの値より小さくない、すなわち変数Naの値以上であると判定された場合、ステップS511へ処理を移行する。
Next, the node ID determination unit 102a of the
ステップS508において、変数aの値が変数Naの値より小さいと判定された場合、格納部102の属性格納手段102eは、変数aの値に「1」を加算して変数aに代入する(ステップS509)。続いて、格納部102の属性格納手段102eは、加算後の変数a番目の属性を処理対象とし、後述する属性格納処理を実行する(ステップS510)。なお、あるノードの持つ属性の間には順番が定義されていないので、例えば属性をノード名の辞書順に並べ、それを属性の順番とすればよい。また、変数pと変数o、及びこのステップで決定した処理対象属性は属性格納処理に引き継ぐ。
If it is determined in step S508 that the value of the variable a is smaller than the value of the variable Na, the attribute storage unit 102e of the
一方、ステップS508において、変数aの値が変数Naの値より小さくない、すなわち変数Na以上であると判定された場合、格納部102の順番号決定手段102bは、変数oの値に「1」を加算して変数oに代入する(ステップS511)。
On the other hand, if it is determined in step S508 that the value of the variable a is not smaller than the value of the variable Na, that is, greater than or equal to the variable Na, the sequence number determination unit 102b of the
次に、格納部102の子ノード格納手段102fは、処理対象ノードの属性以外の子ノードの数を変数Ncに代入して、変数cに「0」を代入する(ステップS512)。続いて、子ノード格納手段102fは、変数cの値が変数Naの値より小さいか否かを判定する(ステップS513)。変数cの値が変数Ncの値より小さいと判定された場合、ステップS514へ処理を移行し、変数Ncの値より小さくない、すなわち変数Ncの値以上であると判定された場合、ステップS516へ処理を移行する。
Next, the child node storage unit 102f of the
ステップS513において、変数cの値が変数Ncの値より小さいと判定された場合、格納部102の子ノード格納手段102fは、変数cの値に「1」を加算して変数cに代入する(ステップS514)。続いて、子ノード格納手段102fは、加算後の変数c番目の子ノードを処理対象とし、ノード格納処理を再帰的に実行する(ステップS515)。このとき、処理対象ノードの子ノードを出現順に並べて子ノードの順番とする。また、変数pと変数o、及びこのステップS515で決定した処理対象ノードを再帰的に実行するノード格納処理に引き継ぐ。
When it is determined in step S513 that the value of the variable c is smaller than the value of the variable Nc, the child node storage unit 102f of the
一方、ステップS513において、変数cの値が変数Ncの値より小さくない、すなわち変数Ncの値以上であると判定された場合、格納部102の順番号決定手段102bは、変数oの値を処理対象ノードの次番号とする(ステップS516)。なお、このステップS516における処理対象ノードはノード格納処理開始時の処理対象ノードであり、ステップS515で決定した処理対象ノードではない。
On the other hand, if it is determined in step S513 that the value of the variable c is not smaller than the value of the variable Nc, that is, greater than or equal to the value of the variable Nc, the sequential number determination unit 102b of the
次に、格納部102のノードデータ挿入手段102cは、ノードテーブル2における処理対象ノードの次番号を設定する(ステップS517)。具体的には、ノードテーブル2のid列201に対して変数iに格納されている処理対象ノードのノードIDを用いて検索を行い、id列201のノードIDの値が変数iの値に一致する行のnext列205の値をステップS516で決定した次番号の値に設定する。
Next, the node data insertion unit 102c of the
次に、図5の本実施の形態の構造化文書格納装置1の格納部102におけるノード格納処理のステップS510の属性格納処理の詳細について、図6のフローチャートを参照して説明する。
Next, details of the attribute storage processing in step S510 of the node storage processing in the
格納部102のノードID決定手段102aは、ステップS510の属性格納処理を開始すると、処理対象属性のノードIDを決定する(ステップS601)。具体的な決定方法はステップS501と同様である。続いて、ノードID決定手段102aは、変数pの値を処理対象属性の親ノードID、すなわちノードテーブル2のparent列203に挿入すべき値とする(ステップS602)
次に、格納部102の順番号決定手段102bは、変数oの値を処理対象属性の順番号、すなわちノードテーブル2のorder列204に挿入すべき値とするとともに、同じ値を処理対象属性の次番号、すなわちノードテーブル2のnext列205に挿入すべき値とする(ステップS603)。
The node ID determination unit 102a of the
Next, the sequence number determination unit 102b of the
次に、格納部102の属性データ挿入手段102dは、処理対象属性のノードデータをノードテーブル2に挿入する(ステップS604)。具体的には、ステップS601で決定したノードIDをid列201のノードIDの値とし、ノード型一覧3における属性302に対応するtype値をtype列202の値とし、ステップS602で決定した親ノードIDをparent列203の値とし、ステップS603で決定した順番号をorder列204の値とし、ステップS603で決定した次番号をnext列205の値とし、処理対象属性のDOMオブジェクトからノード名を取得して、そのノード名をname列206の値とし、処理対象属性のDOMオブジェクトからノード値を取得して、そのノード値をvalue列207の値として、ノードテーブル2に新たな行を追加する。
Next, the attribute data insertion unit 102d of the
次に、本発明の一実施形態である構造化文書格納装置1におけるノードテーブル2へ格納されるXML文書の具体例について説明する。
Next, a specific example of the XML document stored in the node table 2 in the structured
図7は、構造化文書格納装置1におけるノードテーブル2へ格納されるXML文書の一具体例を示す。同図に示すXML文書7全体を示す文書がルートノードである。ルートノードの子ノードとして、要素名が「library」である要素が存在する。また、要素名が「book」や「title」等の山括弧で囲まれた部分も要素である。また、要素名が「book」である要素はノード名が「id」である属性を持っている。また、開始タグ「<title>」と終了タグ「</title>」で挟まれた「Title 1」や、開始タグ「<author>」と終了タグ「</author>」で挟まれた「Author 1」等の文字列の部分は、それらの文字列がノード値であるテキストノードである。
FIG. 7 shows a specific example of an XML document stored in the node table 2 in the structured
図8は、本実施の形態の構造化文書格納装置1におけるノードテーブル2の一具体例を示す。この図8に示すノードテーブル例8は、図7に示したXML文書7を格納した状態を示す。すなわち、図8において、id列には「1」を初期値として「1」ずつ増加するノードID値が格納されている。また、図8において、図2に示したようにtype列にはノード型一覧3におけるtype値(すなわち、ノード型を識別する値)が格納されている。また、parent列には親ノードIDの値が、order列には順番号が、next列には次番号が、name列にはノード名(要素名)が、value列にはノード値がそれぞれ格納されている。
FIG. 8 shows a specific example of the node table 2 in the structured
例えば、XML文書7の1行目の開始タグ「<library>」については、id列のノードIDの値が「2」、type列のtype値がノード型が要素であることを示す「1」、parent列の親ノードIDの値が「1」が格納される。また、このノードID値「2」の「<library>」は出現順が定義されるノードであり、出現順に偶数の値「2」の順番号がparent列に格納され、次番号としてノードID値「1」と同じ「34」が格納され、ノード名「library」がname列に格納される。
For example, for the start tag “<library>” on the first line of the
XML文書7の2行目の「<book id=“1”>」は、出現が定義されるノード「book」と出現が定義されないノード「id=“1”」からなるので、ノードIDの値が「3」の欄に、type値が「1」、親ノードIDの値が「2」、次の出現順の値「4」の順番号、値「14」の次番号、ノード名「book」が対応して格納される。続くノードIDの値が「4」の欄に、type値が属性を示す「2」、親ノードIDの値が「3」、ノード名「id」、value列のノード値として「1」が格納される。また、この「id=“1”」は出現が定義されていないので順番号はその親ノード「book」の順番号に「1」を加算した「5」となり、また、次番号は「5」となる。
Since “<book id =“ 1 ”>” in the second line of the
なお、図8のノードテーブル例8は、便宜上、各行を対応するノードの出現順に並べて示しているが、リレーショナルデータベース103においてノードテーブル2の行の並び順は不定である。
In the node table example 8 in FIG. 8, for convenience, the rows are arranged in the order in which the corresponding nodes appear, but the order of the rows of the node table 2 in the
次に、本発明の一実施の形態である構造化文書格納装置1のXQuery解析部104が生成する検索手順の詳細について説明する。なお、クエリ(XQuery)を解析して検索手順を生成する処理の詳細については、本発明と直接関係がないため、説明を省略する。
Next, details of a search procedure generated by the
図9は、本実施の形態の構造化文書格納装置1のXQuery解析部104が生成する検索手順の種別の一覧を示す。図9において、「検索種別」の欄は検索手順の種別を示し、「引数」の欄は検索手順に付随する引数を示し、「処理内容」の欄は検索処理の内容を示す。
FIG. 9 shows a list of types of search procedures generated by the
検索手順の種別には、ノード型検索901と、ノード名検索902と、ノード値検索903と、子ノード検索904と、親ノード検索905と、子孫ノード検索906と、先祖ノード検索907とがある。
The types of search procedures include a node type search 901, a
ノード型検索901は、ノード型一覧3のtype値を引数にとり、ノード型を表す数値が引数のtype値に一致するノードを検索する手順である。ノード名検索902は、文字列を引数にとり、ノード名が引数の文字列に一致するノードを検索する手順である。ノード値検索903は、文字列を引数にとり、ノード値が引数の文字列に一致するノードを検索する手順である。
The node type search 901 is a procedure for taking a type value of the
子ノード検索904は、引数をとらず、コンテクストノードの子ノードを検索する手順である。なお、「コンテクストノード」とは、検索手順のリストを実行する過程において、これから実行する検索手順の直前の検索手順を実行することによって検索されたノードである。
The
親ノード検索905は、引数をとらず、コンテクストノードの親ノードを検索する手順である。子孫ノード検索906は、引数をとらず、コンテクストノードの子孫ノードを検索する手順である。先祖ノード検索907は、引数をとらず、コンテクストノードの先祖ノードを検索する手順である。
The parent node search 905 is a procedure for searching for a parent node of a context node without taking an argument. The
なお、検索手順一覧9には、クエリ(XQuery)によって記述できる検索手順のうち、本発明に直接関係する検索手順、及び代表的な検索手順を実行するための検索手順901乃至907が含まれているが、クエリ(XQuery)によって記述できるその他の検索手順を実行するための検索手段をも含めるのが望ましい。
The
次に、本実施の形態の構造化文書格納装置1の検索部105における検索処理の詳細について説明する。
Next, details of the search processing in the
図10は、検索部105における検索処理を説明するフローチャートである。図1に示した検索部105内の検索制御手段105aは、XQuery解析部104から検索手順リストが供給されると、検索処理を開始し、ルートノードのノードIDを取得し、コンテクストノードリストに追加する(ステップS1001)。具体的には、リレーショナルデータベース103内のノードテーブル2におけるparent列203の値が「0」である行を検索し、その行のid列201のノードIDの値をルートノードのノードIDとして取得し、取得したルートノードのノードIDのみからなるコンテクストノードリストを生成する。
FIG. 10 is a flowchart for explaining search processing in the
次に、検索部105内の検索制御手段105aは、XQuery解析部104から供給された検索手順リストに含まれる検索手順の数を変数Nに代入し、変数iに「0」を代入する(ステップS1002)。
Next, the search control means 105a in the
次に、検索部105内の検索制御手段105aは、変数iの値が変数Nの値(すなわち、検索手順リストに含まれる検索手順の数)より小さいか否かを判定する(ステップS1003)。検索制御手段105aは、変数iの値が変数Nの値より小さいと判定された場合、変数iの値に「1」を加算して変数iに代入する(ステップS1004)。続いて、検索制御手段105aは、XQuery解析部104から供給された検索手順リストに含まれる変数i番目の検索手順を実行する(ステップS1005)。ステップS1005の処理後はステップS1003に戻り、再び変数iの値が変数Nの値より小さいか否かを判定する。
Next, the search control means 105a in the
一方、検索制御手段105aは、ステップS1002において、変数iの値が変数Nの値より小さくない、すなわち変数Nの値以上であると判定された場合、検索手順リストに含まれるすべての検索手順について検索手順を実行したと判断し、続いて、コンテクストノードリストに含まれるノード数を変数Mに代入すると共に、変数jに「0」を代入する(ステップS1006)。 On the other hand, when it is determined in step S1002 that the value of the variable i is not smaller than the value of the variable N, that is, the value of the variable N is greater than or equal to the value of the variable N, the search control unit 105a It is determined that the search procedure has been executed. Subsequently, the number of nodes included in the context node list is substituted into the variable M, and “0” is substituted into the variable j (step S1006).
次に、検索制御手段105aは、変数jの値が変数Mの値(すなわち、コンテクストノードリストに含まれるノード数)より小さいか否かを判定する(ステップS1007)。変数Mの値より小さいと判定された場合、検索制御手段105aは、変数jの値に「1」を加算して変数jに代入する(ステップS1008)。続いて、検索制御手段105aは、コンテクストノードリストに含まれる変数j番目のノードのサブツリーデータ抽出処理を後述するように実行する(ステップS1009)。ステップS1009の処理後は、ステップS1007に戻り、変数jの値が変数Mの値より小さいか否かを判定する。 Next, the search control unit 105a determines whether or not the value of the variable j is smaller than the value of the variable M (that is, the number of nodes included in the context node list) (step S1007). When it is determined that the value is smaller than the value of the variable M, the search control unit 105a adds “1” to the value of the variable j and substitutes it for the variable j (step S1008). Subsequently, the search control unit 105a executes a subtree data extraction process of the variable j-th node included in the context node list as described later (step S1009). After the process of step S1009, the process returns to step S1007 to determine whether or not the value of the variable j is smaller than the value of the variable M.
一方、検索制御手段105aは、ステップS1007において、変数jの値が変数Mの値より小さくない、すなわち変数Mの値以上であると判定された場合、コンテクストノードリストに含まれるノード数のすべてについてサブツリーデータ抽出処理を実行したと判断し、ステップS1009で抽出したサブツリーデータをノードの順番号で並び替える(ステップS1010)。具体的には、ステップS1009で抽出した各コンテクストノードに対応する各サブツリーデータに含まれる各コンテクストノードの順番号を用いて、順番号の昇順にサブツリーデータを並び替える。これにより、検索結果のサブツリーデータがXML文書における出現順に並ぶこととなる。 On the other hand, if it is determined in step S1007 that the value of the variable j is not smaller than the value of the variable M, that is, the search control unit 105a determines that the value of the variable M is greater than or equal to the value of the variable M, It is determined that the subtree data extraction processing has been executed, and the subtree data extracted in step S1009 is rearranged by node order number (step S1010). Specifically, the subtree data is rearranged in ascending order of the order numbers using the order numbers of the context nodes included in the subtree data corresponding to the context nodes extracted in step S1009. As a result, the subtree data of the search results are arranged in the order of appearance in the XML document.
次に、図10に示した検索部105によるステップS1005の検索手順実行処理の詳細について、図11のフローチャートを参照して説明する。
Next, details of the search procedure execution processing in step S1005 by the
検索部105の検索制御手段105aは、検索手順実行処理を開始すると、実行する検索手順がノード型検索901か否かを判定する(ステップS1101)。ノード型検索901であると判定された場合、図1に示した検索部105のノード型検索手段105bは、コンテクストノードリストからノード型が条件に合致するノードを選択する(ステップS1102)。具体的には、ノード型検索手段105bは、ノードテーブル2に対して、id列201のノードIDの値がコンテクストノードリストに含まれる各ノードIDに一致し、かつ、type列202のノード型を示す値が検索手順の引数であるtype値に一致する行を検索し、検索に合致した各行のid列201のノードIDの値をノードIDとして読み出し、読み出したノードIDのリストでコンテクストノードリストを置き換える。
When starting the search procedure execution process, the search control unit 105a of the
一方、ステップS1101において、実行する検索手順がノード型検索901ではないと判断された場合、検索制御手段105aは、実行する検索手順がノード名検索902か否かを判定する(ステップS1103)。 On the other hand, if it is determined in step S1101 that the search procedure to be executed is not the node type search 901, the search control unit 105a determines whether or not the search procedure to be executed is the node name search 902 (step S1103).
ステップS1103において、実行する検索手順がノード名検索902であると判断された場合、図1に示した検索部105のノード名検索手段105cは、コンテクストノードリストからノード名が条件に合致するノードを選択する(ステップS1104)。具体的には、ノード名検索手段105cは、ノードテーブル2に対して、id列201のノードIDの値がコンテクストノードリストに含まれる各ノードIDに一致し、かつ、name列206のノード名が検索手順の引数である文字列に一致する行を検索し、検索に合致した各行のid列201のノードIDの値をノードIDとして読み出し、読み出したノードIDのリストでコンテクストノードリストを置き換える。
If it is determined in step S1103 that the search procedure to be executed is the
一方、ステップS1103において、実行する検索手順がノード名検索902ではないと判断された場合、検索部105の検索制御手段105aは、実行する検索手順がノード値検索903か否かを判定する(ステップS1105)。
On the other hand, if it is determined in step S1103 that the search procedure to be executed is not the
ステップS1105において、実行する検索手順がノード値検索903であると判断された場合、図1に示した検索部105のノード値検索手段105dは、コンテクストノードリストからノード値が条件に合致するノードを選択する(ステップS1106)。具体的には、ノード値検索手段105dは、ノードテーブル2に対して、id列201のノードIDの値がコンテクストノードリストに含まれる各ノードIDに一致し、かつ、value列207のノード値が検索手順の引数である文字列に一致する行を検索し、検索に合致した各行のid列201のノードIDの値をノードIDとして読み出し、読み出したノードIDのリストでコンテクストノードリストを置き換える。
If it is determined in step S1105 that the search procedure to be executed is the node value search 903, the node value search unit 105d of the
一方、ステップS1105において、実行する検索手順がノード値検索903ではないと判断された場合、検索部105の検索制御手段105aは、実行する検索手順が子ノード検索904か否かを判定する(ステップS1107)。
On the other hand, if it is determined in step S1105 that the search procedure to be executed is not the node value search 903, the search control unit 105a of the
ステップS1107において、実行する検索手順が子ノード検索904であると判断された場合、図1に示した検索部105の子ノード検索手段105eは、コンテクストノードリストの各ノードの子ノードを検索する(ステップS1108)。具体的には、子ノード検索手段105eは、ノードテーブル2に対して、parent列203の親ノードIDの値がコンテクストノードリストに含まれる各ノードIDに一致する行を検索し、検索に合致した各行のid列201のノードIDの値をノードIDとして読み出し、読み出したノードIDのリストでコンテクストノードリストを置き換える。
If it is determined in step S1107 that the search procedure to be executed is the
一方、ステップS1107において、実行する検索手順が子ノード検索904ではないと判断された場合、検索部105の検索制御手段105aは、実行する検索手順が親ノード検索905か否かを判定する(ステップS1109)。
On the other hand, if it is determined in step S1107 that the search procedure to be executed is not the
ステップS1109において、実行する検索手順が親ノード検索905であると判断された場合、図1に示した検索部105の親ノード検索手段105fは、コンテクストノードリストの各ノードの親ノードを検索する(ステップS1110)。具体的には、親ノード検索手段105fは、ノードテーブル2に対して、id列201のノードIDの値がコンテクストノードリストに含まれる各ノードIDに一致する行を検索し、検索に合致した各行のparent列203の親ノードIDの値をノードIDとして読み出し、読み出したノードIDのリストでコンテクストノードリストを置き換える。
If it is determined in step S1109 that the search procedure to be executed is the parent node search 905, the parent node search means 105f of the
一方、ステップS1109において、実行する検索手順が親ノード検索905ではないと判断された場合、検索部105の検索制御手段105aは、実行する検索手段が子孫ノード検索906か否かを判定する(ステップS1111)。
On the other hand, if it is determined in step S1109 that the search procedure to be executed is not the parent node search 905, the search control means 105a of the
ステップS1111において、実行する検索手順が子孫ノード検索906であると判断された場合、図1に示した検索部105の子孫ノード検索手段105gは、後述する子孫ノード検索処理を実行する(ステップS1112)。一方、ステップS1111において、実行する検索手順が子孫ノード検索906ではないと判断された場合、検索部105の検索制御手段105aは、実行する検索手順が先祖ノード検索907か否かを判定する(ステップS1113)。
If it is determined in step S1111 that the search procedure to be executed is the
ステップS1113において、実行する検索手順が先祖ノード検索907であると判断された場合、図1に示した検索部105の先祖ノード検索手段105hは、後述する先祖ノード検索処理を実行する(ステップS1114)。一方、ステップS1113において、実行する検索手順が先祖ノード検索907ではないと判断された場合、検索部105の検索制御手段105aは、検索手順一覧9に記載しないその他の検索手順を実行する(ステップS1115)。その他の検索手順実行処理の詳細については説明を省略する。
If it is determined in step S1113 that the search procedure to be executed is the
次に、図11に示した検索部105によるステップS1112の子孫ノード検索処理の詳細について図12のフローチャートを参照して説明する。
Next, details of the descendant node search processing in step S1112 by the
検索部105の子孫ノード検索手段105gは、子孫ノード検索処理を開始すると、ノードテーブル2に対して、id列201のノードIDの値がコンテクストノードリストに含まれるノードIDに一致する行を検索する(ステップS1201)。
When the descendant node search unit 105g of the
次に、検索部105の子孫ノード検索手段105gは、ノードテーブル2に対して、order列204の順番号の値がステップS1201で検索された各行のorder列204の順番号の値に「1」を加算した値より大きく、ステップS1201で検索された各行のnext列205の次番号の値より小さい行を子孫ノードとして検索する(ステップS1202)。
Next, the descendant node search unit 105g of the
次に、検索部105の子孫ノード検索手段105gは、ステップS1202で検索された子孫ノードと検索された各行のid列201のノードIDの値を読み出し、読み出したノードIDのリストでコンテクストノードリストを置き換える(ステップS1203)。
Next, the descendant node search unit 105g of the
なお、ステップS1202において、order列204の順番号の値に「1」を加算して検索を行うことにより、コンテクストノードの属性を子孫ノードの検索から除外できる効果がある。
In step S1202, by adding “1” to the order number value in the
次に、図11に示した検索部105によるステップS1114の先祖ノード検索処理の詳細について、図13のフローチャートを参照して説明する。
Next, details of the ancestor node search processing in step S1114 by the
検索部105の先祖ノード検索手段105hは、先祖ノード検索処理を開始すると、ノードテーブル2に対して、id列201のノードIDの値がコンテクストノードリストに含まれるノードIDに一致する行を検索する(ステップS1301)。
When the ancestor node search unit 105h of the
次に、検索部105の先祖ノード検索手段105hは、ノードテーブル2に対して、order列204の順番号の値がステップS1301で検索された各行のorder列204の順番号の値より小さく、next列205の次番号の値がステップS1301で検索された各行のorder列204の順番号の値より大きい行を検索する(ステップS1302)。
Next, the ancestor node search unit 105h of the
次に、検索部105の先祖ノード検索手段105hは、ステップS1302で検索された各行のid列201のノードIDの値を読み出し、読み出したノードIDのリストでコンテクストノードリストを置き換える(S1303)。
Next, the ancestor node search unit 105h of the
次に、図10に示した検索部105によるステップS1009のサブツリーデータ抽出処理の詳細について、図14のフローチャートを参照して説明する。
Next, details of the subtree data extraction processing in step S1009 by the
図1に示した検索部105のサブツリーデータ抽出手段105iは、サブツリーデータ抽出処理を開始すると、ノードテーブル2に対して、id列201のノードIDの値が処理対象ノードのノードIDに一致する行を検索する(ステップS1401)。
When the subtree data extraction unit 105i of the
次に、検索部105のサブツリーデータ抽出手段105iは、ノードテーブル2に対して、order列204の順番号の値がステップS1401で検索された行のorder列204の順番号の値以上であり、ステップS1401で検索された行のnext列205の次番号の値より小さい行を検索する(ステップS1402)。そして、検索部105のサブツリーデータ抽出手段105iは、ステップS1402で検索された各行のid列の値を読み出す(ステップS1403)。
Next, the subtree data extraction unit 105i of the
次に、本発明の一実施の形態の構造化文書格納装置1における検索の具体例について説明する。
Next, a specific example of search in the structured
図15は、本発明の一実施の形態の構造化文書格納装置1内のXQuery解析部104に入力される検索クエリの一例を示す。図15に示す検索クエリ15は、XML文書例7が格納されていることを前提としており、ノード値が「Author 1」に一致するテキストノードを子孫に含む「book」要素を検索するときのものである。
FIG. 15 shows an example of a search query input to the
図16は、XQuery解析部104により生成される検索手順リストの一例を示す。この検索手順リスト16は、検索クエリ15を解析して生成されたものであり、子孫ノード検索、ノード型検索、ノード値検索、先祖ノード検索、ノード型検索、ノード名検索の順からなる6つの検索手順を示す。
FIG. 16 shows an example of a search procedure list generated by the
図17は、本発明の一実施の形態の構造化文書格納装置1の検索部105の検索処理におけるコンテクストノードリストの遷移の例を示す。この例は、図16に示した検索手順リスト16を用いてテキストノードの検索処理を行ったときのコンテクストノードリストの遷移を示したものである。
FIG. 17 shows an example of transition of the context node list in the search process of the
すなわち、図17に170で示すように、コンテクストノードリストは、最初は図8に示したノードテーブル例8のid列の欄の一行目に示されるルートノードのノードID=1のみを含む。 That is, as indicated by 170 in FIG. 17, the context node list initially includes only the node ID = 1 of the root node shown in the first row of the column of the id column of the node table example 8 shown in FIG.
次に、検索部105は図16に示した検索手順1の子孫ノード検索を実行する。これにより、図17に170で示すように、コンテクストノードリストには、図8に示したノードテーブル例8における子孫ノードのノードIDである「2」、「3」、「4」、「5」、「6」、「7」、「8」、「9」、「10」、「11」、「12」、「13」、「14」、「15」、「16」、「17」、「18」、「19」、「20」が記述される。
Next, the
続いて、検索部105は図16に示した検索手順2の引数3のノード型検索を実行する。これにより、図17に171で示すように、コンテクストノードリストには、図8に示したノードテーブル例8において、引数3からtype値が「3」のテキストノードのノード型を示すノードIDである「6」、「8」、「12」、「14」、「18」、「20」が記述される。
Subsequently, the
続いて、検索部105は図16に示した検索手順3の引数「Author1」のノード値検索を実行する。これにより、図17に173で示すように、コンテクストノードリストには、図8に示したノードテーブル例8において、引数「Author1」からノード値を示す「value」が「Author1」である「8」、「20」が記述される。
Subsequently, the
続いて、検索部105は図16に示した検索手順4の先祖ノード検索を実行する。これにより、図17に174で示すように、コンテクストノードリストには、検索手順3の検索結果であるノードID「8」、「20」のうちノードID「8」の先祖ノードである「1」、「2」、「3」、「7」と、ノードD「20」の先祖ノードである「15」、「19」とが記述される。
Subsequently, the
続いて、検索部105は図16に示した検索手順5の引数1のノード型検索を実行する。これにより、図17に175で示すように、コンテクストノードリストには、検索手順4の検索結果のうち、図8に示す引数1(type値が「1」)のテキストノードのノード型を示すノードIDである「2」、「3」、「7」、「15」、「19」が記述される。
Subsequently, the
そして、検索部105は図16に示した最後の検索手順6の引数「book」のノード名検索を実行する。これにより、図17に176で示すように、コンテクストノードリストには、検索手順5の検索結果のうち、図8のname列の欄に示されるノード名が「book」である検索結果のノードID「3」、「15」が記述される。このように、検索部105が検索手順を1つずつ実行する毎に、コンテクストノードリストに含まれるノードIDが変化していき、最終的に検索クエリによる所望の検索結果が得られる。
Then, the
図18は、本発明の一実施の形態の構造化文書格納装置1のXML成形部106から出力される検索結果の一例を示す。この検索結果は、図15に示した検索クエリ15に基づいて得られる図17に示す検索結果を示したものである。
FIG. 18 shows an example of a search result output from the
すなわち、図18の1行目から4行目は、図7に示したXML文書例7において図17の検索結果のノードID「3」が示すノード名「book」を開始タグとし、その後の最初の「/book」を終了タグとするノード値が「Author 1」に一致するテキストノードを示す。また、図18の5行目から8行目は、図7に示したXML文書例7において図17の検索結果のノードID「15」が示すノード名「book」を開始タグとし、その後の最初の「/book」を終了タグとするノード値が「Author 1」に一致するテキストノードを示す。
That is, the first to fourth lines in FIG. 18 use the node name “book” indicated by the node ID “3” in the search result of FIG. 17 in the XML document example 7 shown in FIG. Indicates a text node whose node value whose end tag is “/ book” matches “
このように、本実施の形態の構造化文書格納装置1によれば、構造化文書の対象ノードの出現順を示す順番号と、対象ノードより後に出現するノードのうち、対象ノードの子孫ノードを除くノードのうちで最も先に出現するノードの順番号を示す次番号とをノードテーブル2に格納し、検索部105において、ノードテーブル2を参照して構造化文書の比較元ノードの順番号を比較先ノードの順番号及び次番号と比較して比較元ノードが比較先ノードの子孫ノードであるか否かを判定するようにしたため、検索手順の数は従来と同じであるが、従来に比べて構造化文書のノード間の先祖・子孫関係を検索する手順を短時間で行うことができ、その結果、従来に比べて構造化文書の検索を高速に行うことができる。
As described above, according to the structured
なお、本発明は以上の実施の形態に限定されるものではなく、例えば本実施の形態の構造化文書格納装置1において、XML文書をテキストデータとして入力し格納しているが、XML文書の入力方法はテキストデータによるものに限定されない。XML文書の入力方法を、DOMデータによるものや、その他の方法によるものとしてもよい。また、本実施の形態の構造化文書格納装置1において、検索結果をテキストデータとして出力しているが、検索結果の出力方法はテキストデータによるものに限定されない。検索結果の出力方法を、DOMデータによるものや、その他の方法によるものとしてもよい。
The present invention is not limited to the above embodiment. For example, in the structured
また、本実施の形態の構造化文書格納装置1は、出現順が定義されない属性を含むXML文書を格納するものであるが、全てのノードの出現順が定義される構造化文書を格納するものとしてもよい。この場合、格納部102には、属性データ挿入手段102dと属性格納手段102eとが不要となる。
The structured
また、ノードテーブル2におけるorder列204に格納される順番号は、ノードの出現順に「0」から始まり「1」ずつ増加する整数を割り振った値としてもよい。また、ノードに属性がない場合は図5のノード格納処理におけるステップS506乃至ステップS510が不要となる。また、図12の子孫ノード検索処理のステップS1202において、order列204の値に「1」を加算する処理が不要となる。
The order number stored in the
更に、本発明は上述した構造化文書格納装置1の動作を実現する構造化文書格納方法、及びコンピュータにより構造化文書格納装置1の動作を実行させるための構造化文書格納プログラムも包含する。この構造化文書格納プログラムは、例えば、構造化文書格納プログラムが記憶された記録媒体から読み出され、コンピュータに取り込まれて実行されることにより構造化文書格納装置を構成するようにしてもよいし、通信ネットワークを介して配信されてコンピュータにインストールされて実行されることにより構造化文書格納装置を構成するようにしてもよい。
Furthermore, the present invention also includes a structured document storage method for realizing the operation of the structured
1 構造化文書格納装置
2 ノードテーブル
3 ノード型一覧
7 XML文書例
8 ノードテーブル例
9 検索手順一覧
101 XML解析部
102 格納部
102a ノードID決定手段
102b 順番号決定手段
102c ノードデータ挿入手段
102d 属性データ挿入手段
102e 属性格納手段
102f 子ノード格納手段
103 リレーショナルデータベース
104 XQuery解析部
105 検索部
105a 検索制御手段
105b ノード型検索手段
105c ノード名検索手段
105d ノード値検索手段
105e 子ノード検索手段
105f 親ノード検索手段
105g 子孫ノード検索手段
105h 先祖ノード検索手段
105i サブツリーデータ抽出手段
106 XML成形部
DESCRIPTION OF
Claims (6)
前記構造化文書のノードに関する情報が格納されるノードテーブルを有する記憶手段と、
前記構造化文書解析手段から出力された前記構造化文書のノードに関する情報中の対象ノードの出現順を表す順番号を決定すると共に、前記対象ノードより後に前記情報中に出現するノードのうち前記対象ノードの子孫ノードを除いて最も先に出現するノードの前記順番号を前記対象ノードに付す次番号として決定し、前記対象ノードに関する情報と共に前記順番号と前記次番号とを前記ノードテーブルに格納する格納手段と、
供給される検索手順リストに従い、前記ノードテーブルの格納情報を参照して検索結果を出力する検索手段と
を備え、前記検索手段は、前記格納情報中の比較元ノードの前記順番号が比較先ノードの前記順番号より大きく、かつ、前記比較元ノードの前記順番号が前記比較先ノードの前記次番号より小さいときに、前記比較元ノードが前記比較先ノードの子孫ノードであると判断する子孫ノード検索手段を有することを特徴とする構造化文書格納装置。 A structured document analyzing means for analyzing the structured document and outputting information about nodes included in the structured document;
Storage means having a node table in which information about nodes of the structured document is stored;
Determining a sequence number representing the order of appearance of the target node in the information related to the node of the structured document output from the structured document analyzing means, and the target among the nodes appearing in the information after the target node The order number of the node that appears first except for the descendant nodes of the node is determined as a next number to be assigned to the target node, and the order number and the next number are stored in the node table together with information on the target node. Storage means;
Search means for referring to the stored information in the node table according to the supplied search procedure list and outputting a search result, wherein the search means is configured such that the sequence number of the comparison source node in the storage information is a comparison destination node. A descendant node that determines that the comparison source node is a descendant node of the comparison destination node when the order number of the comparison source node is less than the next number of the comparison destination node. A structured document storage device comprising a search means.
前記格納手段は、前記第1のノードの前記順番号に、その第1のノードの出現順に2ずつ増加する0以上の整数を割り当て、前記第2のノードの前記順番号に、その第2のノードの一つ上位のノードである親ノードの前記順番号に1を加算した値を割り当て、
前記子孫ノード検索手段は、前記比較元ノードの前記順番号が前記比較先ノードの前記順番号に1を加算した値より大きく、かつ、前記比較元ノードの前記順番号が前記比較先ノードの前記次番号より小さいときに、前記比較元ノードが前記比較先ノードの子孫ノードであると判断する
ことを特徴とする請求項1記載の構造化文書格納装置。 The structured document includes a first node whose appearance order is defined and a second node whose appearance order is not defined,
The storage means assigns an integer of 0 or more that increases by 2 in the order of appearance of the first node to the order number of the first node, and assigns the second number to the order number of the second node. Assign a value obtained by adding 1 to the order number of the parent node that is one node higher than the node,
The descendant node search means is configured such that the order number of the comparison source node is larger than a value obtained by adding 1 to the order number of the comparison destination node, and the order number of the comparison source node is the value of the comparison destination node. 2. The structured document storage device according to claim 1, wherein when the number is smaller than a next number, the comparison source node is determined to be a descendant node of the comparison destination node.
前記構造化文書解析ステップにより解析して得られた前記構造化文書のノードに関する情報中の対象ノードの出現順を表す順番号を決定すると共に、前記対象ノードより後に前記情報中に出現するノードのうち前記対象ノードの子孫ノードを除いて最も先に出現するノードの前記順番号を前記対象ノードに付す次番号として決定し、前記対象ノードに関する情報と共に前記順番号と前記次番号とを、前記構造化文書のノードに関する情報が格納されるノードテーブルに格納する格納ステップと、
供給される検索手順リストに従い、前記ノードテーブルの格納情報を参照して検索結果を出力する検索ステップと
を備え、前記検索ステップは、前記格納情報中の比較元ノードの前記順番号が比較先ノードの前記順番号より大きく、かつ、前記比較元ノードの前記順番号が前記比較先ノードの前記次番号より小さいときに、前記比較元ノードが前記比較先ノードの子孫ノードであると判断する子孫ノード検索ステップを含むことを特徴とする構造化文書格納方法。 A structured document analysis step of analyzing the structured document and outputting information about nodes included in the structured document;
Determining a sequence number representing the order of appearance of the target node in the information related to the node of the structured document obtained by analysis in the structured document analyzing step, and determining a node number that appears in the information after the target node; The order number of the node that appears first except for the descendant nodes of the target node is determined as the next number to be assigned to the target node, and the order number and the next number together with information on the target node are determined as the structure A storage step of storing in a node table in which information on nodes of the document is stored;
A search step of outputting a search result by referring to the stored information in the node table according to the supplied search procedure list, wherein the search step includes the sequence number of the comparison source node in the storage information as a comparison destination node A descendant node that determines that the comparison source node is a descendant node of the comparison destination node when the order number of the comparison source node is less than the next number of the comparison destination node. A structured document storage method comprising a retrieval step.
前記格納ステップは、前記第1のノードの前記順番号に、その第1のノードの出現順に2ずつ増加する0以上の整数を割り当て、前記第2のノードの前記順番号に、その第2のノードの一つ上位のノードである親ノードの前記順番号に1を加算した値を割り当て、
前記子孫ノード検索ステップは、前記比較元ノードの前記順番号が前記比較先ノードの前記順番号に1を加算した値より大きく、かつ、前記比較元ノードの前記順番号が前記比較先ノードの前記次番号より小さいときに、前記比較元ノードが前記比較先ノードの子孫ノードであると判断する
ことを特徴とする請求項3記載の構造化文書格納方法。 The structured document includes a first node whose appearance order is defined and a second node whose appearance order is not defined,
The storing step assigns an integer of 0 or more that increases by 2 in the order of appearance of the first node to the order number of the first node, and assigns the second number to the order number of the second node. Assign a value obtained by adding 1 to the order number of the parent node that is one node higher than the node,
In the descendant node search step, the order number of the comparison source node is larger than a value obtained by adding 1 to the order number of the comparison destination node, and the order number of the comparison source node is the value of the comparison destination node. 4. The structured document storage method according to claim 3, wherein when the number is smaller than a next number, it is determined that the comparison source node is a descendant node of the comparison destination node.
構造化文書を解析して、その構造化文書に含まれるノードに関する情報を出力する構造化文書解析ステップと、
前記構造化文書解析ステップにより解析して得られた前記構造化文書のノードに関する情報中の対象ノードの出現順を表す順番号を決定すると共に、前記対象ノードより後に前記情報中に出現するノードのうち前記対象ノードの子孫ノードを除いて最も先に出現するノードの前記順番号を前記対象ノードに付す次番号として決定し、前記対象ノードに関する情報と共に前記順番号と前記次番号とを、前記構造化文書のノードに関する情報が格納されるノードテーブルに格納させる格納ステップと、
供給される検索手順リストに従い、前記ノードテーブルの格納情報を参照して検索結果を出力する検索ステップと
を実行させ、前記検索ステップは、前記格納情報中の比較元ノードの前記順番号が比較先ノードの前記順番号より大きく、かつ、前記比較元ノードの前記順番号が前記比較先ノードの前記次番号より小さいときに、前記比較元ノードが前記比較先ノードの子孫ノードであると判断する子孫ノード検索ステップを含むことを特徴とする構造化文書格納プログラム。 On the computer,
A structured document analysis step of analyzing the structured document and outputting information about nodes included in the structured document;
Determining a sequence number representing the order of appearance of the target node in the information related to the node of the structured document obtained by analysis in the structured document analyzing step, and determining a node number that appears in the information after the target node; The order number of the node that appears first except for the descendant nodes of the target node is determined as the next number to be assigned to the target node, and the order number and the next number together with information on the target node are determined as the structure A storage step for storing in a node table in which information on nodes of the document is stored;
A search step of referring to the stored information of the node table and outputting a search result according to the supplied search procedure list, wherein the search step includes a comparison destination node in which the order number of the comparison source node is compared A descendant that determines that the comparison source node is a descendant node of the comparison destination node when the order number of the comparison source node is greater than the sequence number of the node and the comparison source node is less than the next number of the comparison destination node A structured document storage program comprising a node search step.
前記格納ステップは、前記第1のノードの前記順番号に、その第1のノードの出現順に2ずつ増加する0以上の整数を割り当て、前記第2のノードの前記順番号に、その第2のノードの一つ上位のノードである親ノードの前記順番号に1を加算した値を割り当て、
前記子孫ノード検索ステップは、前記比較元ノードの前記順番号が前記比較先ノードの前記順番号に1を加算した値より大きく、かつ、前記比較元ノードの前記順番号が前記比較先ノードの前記次番号より小さいときに、前記比較元ノードが前記比較先ノードの子孫ノードであると判断する
ことを特徴とする請求項5記載の構造化文書格納プログラム。 The structured document includes a first node whose appearance order is defined and a second node whose appearance order is not defined,
The storing step assigns an integer of 0 or more that increases by 2 in the order of appearance of the first node to the order number of the first node, and assigns the second number to the order number of the second node. Assign a value obtained by adding 1 to the order number of the parent node that is one node higher than the node,
In the descendant node search step, the order number of the comparison source node is larger than a value obtained by adding 1 to the order number of the comparison destination node, and the order number of the comparison source node is the value of the comparison destination node. 6. The structured document storage program according to claim 5, wherein when it is smaller than a next number, it is determined that the comparison source node is a descendant node of the comparison destination node.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
JP2010216420A JP2012073706A (en) | 2010-09-28 | 2010-09-28 | Structured document storage device, structured document storage method and structured document storage program |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
JP2010216420A JP2012073706A (en) | 2010-09-28 | 2010-09-28 | Structured document storage device, structured document storage method and structured document storage program |
Publications (1)
Publication Number | Publication Date |
---|---|
JP2012073706A true JP2012073706A (en) | 2012-04-12 |
Family
ID=46169833
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
JP2010216420A Pending JP2012073706A (en) | 2010-09-28 | 2010-09-28 | Structured document storage device, structured document storage method and structured document storage program |
Country Status (1)
Country | Link |
---|---|
JP (1) | JP2012073706A (en) |
-
2010
- 2010-09-28 JP JP2010216420A patent/JP2012073706A/en active Pending
Similar Documents
Publication | Publication Date | Title |
---|---|---|
JP4886693B2 (en) | Information processing method, information processing apparatus, and information processing program | |
JP4124261B2 (en) | Document analysis system, document analysis method, and program thereof | |
JP4997749B2 (en) | Document processing method, program, and system | |
US20020178184A1 (en) | Software system for biological storytelling | |
JP2004086782A (en) | Apparatus for supporting integration of heterogeneous database | |
JP6132698B2 (en) | Tabular multidimensional data conversion method and apparatus | |
JP5241738B2 (en) | Method and apparatus for building tree structure data from tables | |
US20220164526A1 (en) | Method And Apparatus For Structured Documents | |
JP2006185408A (en) | Database construction device, database retrieval device, and database device | |
JPWO2006038498A1 (en) | Array generation method and array generation program | |
JP2012059041A (en) | Document management system, retrieval designation method, and program | |
JP2015162004A (en) | Inter-development document trace link generation support device and method and program | |
JP2016031567A (en) | Personal information anonymity apparatus | |
JPWO2007052680A1 (en) | Document processing apparatus and document processing method | |
JP5273884B1 (en) | Structure analysis apparatus and program | |
JP2012059212A (en) | Extraction apparatus, extraction method and extraction program | |
JP6710881B1 (en) | Document creation support system | |
JP2012073706A (en) | Structured document storage device, structured document storage method and structured document storage program | |
JPWO2006137564A1 (en) | Document processing device | |
JPH09282218A (en) | Html document book form shaping method and device therefor | |
JP6638053B1 (en) | Document creation support system | |
JP6753190B2 (en) | Document retrieval device and program | |
JP4411994B2 (en) | Information processing device | |
JP2008084128A (en) | Device, method and program for designating element of structured document | |
JP2006155593A (en) | Document analysis system and document adaptation system |