JP2005148970A - Method for converting data - Google Patents

Method for converting data Download PDF

Info

Publication number
JP2005148970A
JP2005148970A JP2003383334A JP2003383334A JP2005148970A JP 2005148970 A JP2005148970 A JP 2005148970A JP 2003383334 A JP2003383334 A JP 2003383334A JP 2003383334 A JP2003383334 A JP 2003383334A JP 2005148970 A JP2005148970 A JP 2005148970A
Authority
JP
Japan
Prior art keywords
tree
data
child
tree element
character string
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
Application number
JP2003383334A
Other languages
Japanese (ja)
Inventor
Takamasa Kawasaki
孝征 川崎
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Meidensha Corp
Meidensha Electric Manufacturing Co Ltd
Original Assignee
Meidensha Corp
Meidensha Electric Manufacturing Co Ltd
Priority date (The priority date 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 date listed.)
Filing date
Publication date
Application filed by Meidensha Corp, Meidensha Electric Manufacturing Co Ltd filed Critical Meidensha Corp
Priority to JP2003383334A priority Critical patent/JP2005148970A/en
Publication of JP2005148970A publication Critical patent/JP2005148970A/en
Pending legal-status Critical Current

Links

Images

Landscapes

  • Document Processing Apparatus (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

<P>PROBLEM TO BE SOLVED: To reduce the size of tree-structure data, thereby rendering the data convertible into readable character-string data and vice versa. <P>SOLUTION: A data conversion part 2 converts the tree-structure data 1 into character-string data by converting it into a data structure formed by positioning the names of tree elements at the front, then positioning the names and values of the trees' attributes, then positioning tree-element value identifiers, then positioning tree-element values, and finally positioning tree-element separators. Methods of conversion for cases where the tree-element attribute values are the same, where there are elements in master/slave relationship, where tree-structure data assumes a matrix structure, and where the tree structure comprises master, slave, and sub-slave, elements, are also included. A method of restoring the tree-structure data from the character-string data is also included. <P>COPYRIGHT: (C)2005,JPO&NCIPI

Description

本提案は、ツリー構造を持つデータ(以下、ツリー構造データと呼ぶ)を可読性の文字列データに変換、およびその逆変換をするデータ変換方法に関するものである。   The present proposal relates to a data conversion method for converting data having a tree structure (hereinafter referred to as tree structure data) into readable character string data and vice versa.

近年、データ形式としてXML(Extensible Markup Language)が用いられることが多くなってきた。XMLは文書フォーマット規定の国際標準であるSGMLをインターネットでの配信に適したものにしたドキュメント記述言語であり、データをツリー構造で表現することができる。ツリー構造で表現するとデータの意味付けを行いやすく、データの作成、編集、検索が行いやすいという長所がある。また、XMLはテキストで表されるので可読性がある(例えば、非特許文献1参照)。   In recent years, XML (Extensible Markup Language) is often used as a data format. XML is a document description language in which SGML, which is an international standard for defining document formats, is adapted to be distributed over the Internet, and can express data in a tree structure. When expressed in a tree structure, it is easy to make data meaningful and easy to create, edit, and search data. In addition, since XML is expressed in text, it has readability (see, for example, Non-Patent Document 1).

ツリー構造データを図で表現した例を図9に、それをXMLで記述した例を図10に示す。
技術評論社出版、「改訂版 標準XML完全解説(上)、中山幹敏、奥井康弘 著」、初版2001年4月発行
An example in which the tree structure data is represented by a diagram is shown in FIG. 9, and an example in which the tree structure data is described in XML is shown in FIG.
Published by Technical Critics Company, “Revised Standard XML Complete Description (above), Mikitoshi Nakayama, Yasuhiro Okui”, first edition published in April 2001

データベース等に構築されるツリー構造データをXMLによる方法で文字列データとして記述した場合、そのデータサイズが大きくなるという問題点が有る。データサイズが大きいとデータの送受信に時間がかかる、データの保存コストが大きいなどの影響がある。   When tree structure data constructed in a database or the like is described as character string data by an XML method, there is a problem that the data size becomes large. If the data size is large, it takes time to send and receive data, and the cost of storing data is high.

本発明の目的は、ツリー構造データをデータサイズを小さくして可読性文字列データに変換およびその逆変換ができるデータ変換方法を提供することにある。   An object of the present invention is to provide a data conversion method capable of converting tree structure data into readable character string data by reducing the data size and vice versa.

本発明は、前記の課題を解決するため、以下の方法を特徴とする。   The present invention is characterized by the following method in order to solve the above problems.

(1)ツリー構造を持つツリー構造データを、ツリー構造の階層を表しかつ可読性のある文字列データに変換、およびその逆変換をするデータ変換方法であって、
前記文字列データは、先頭にツリー要素名を配置し、その次にツリー属性名とツリー属性値を配置し、その次にツリー要素値識別子を配置し、その次にツリー要素値を配置し、最後にツリー要素セパレータを配置したデータ構造に変換することを特徴とする。
(1) A data conversion method for converting tree structure data having a tree structure into character string data representing a hierarchy of the tree structure and being readable, and vice versa.
The string data is arranged with a tree element name at the head, followed by a tree attribute name and a tree attribute value, followed by a tree element value identifier, followed by a tree element value, Finally, it is converted into a data structure in which a tree element separator is arranged.

(2)前記ツリー要素値は、ツリー要素属性が無い場合や有る場合でもそのツリー要素属性値が共通する場合は、ツリー要素名を一つ表示し、その後ろにツリー要素値識別子を用いてツリー要素値を連結配置したデータ構造に変換することを特徴とする。   (2) If the tree element attribute value is common even if there is no tree element attribute, the tree element value is displayed with one tree element name, followed by a tree element value identifier. The element value is converted into a data structure in which the element values are connected and arranged.

(3)前記ツリー構造データが、あるツリー要素Aについてそのツリー要素の子階層に属するツリー要素Bがある場合、前記文字列データは「A,B」という順で配置し、子階層のツリー要素がない場合はツリー要素Aの後ろにそれを示す識別子を配置したデータ構造に変換することを特徴とする。   (3) When the tree structure data includes a tree element B belonging to a child hierarchy of the tree element for a certain tree element A, the character string data is arranged in the order of “A, B”, and the tree elements of the child hierarchy If there is not, the data element is converted into a data structure in which an identifier indicating it is arranged after the tree element A.

(4)前記ツリー構造データは、階層を示す行mと、一つの階層におけるツリー要素を表す列nとした、m*nの行列として配置した構造とし、
このツリー構造データを使用して前記文字列データに変換することを特徴とする。
(4) The tree structure data has a structure arranged as a matrix of m * n, with a row m indicating a hierarchy and a column n representing a tree element in one hierarchy,
The tree structure data is used to convert the data into the character string data.

(5)前記文字列データは、初めにツリー階層先頭識別子を配置し、その次には親ツリー要素を配置し、それ以降はその親ツリー要素の子ツリー要素を配置し、子ツリー要素の終わりにツリー階層最後尾識別子を配置したデータ構造とし、各ツリー要素とその子要素にあたる全てのツリー要素の先頭と最後尾に識別子を配置したデータ構造に変換することを特徴とする。   (5) In the character string data, a tree hierarchy head identifier is first placed, then a parent tree element is placed next, a child tree element of the parent tree element is placed thereafter, and the end of the child tree element And a data structure in which the identifier at the end of the tree hierarchy is arranged, and the data structure is converted into a data structure in which identifiers are arranged at the head and tail of all tree elements corresponding to each tree element and its child elements.

(6)前記ツリー構造データが、前記子ツリー要素の子ツリー要素になる孫ツリー要素がある場合、前記文字列データは、子ツリー要素の前に再度ツリー階層先頭識別子を配置し、その後ろに子ツリー要素を配置し、その後ろに孫ツリー要素を配置し、孫ツリー要素の最後にツリー階層最後尾識別子を配置したことを特徴とする。   (6) When the tree structure data includes a grandchild tree element that becomes a child tree element of the child tree element, the character string data includes a tree hierarchy head identifier again in front of the child tree element, followed by A child tree element is arranged, a grandchild tree element is arranged behind the child tree element, and a tree hierarchy end identifier is arranged at the end of the grandchild tree element.

(7)前記(3)により変換された前記文字列データからツリー構造データへの復元は、
文字列データから先頭の要素を取得し、それをルートツリー要素としてスタックエリアに入れて保存する第1の処理と、
前記ツリー文字列データ中の次の要素を取得してその種別をチェックする第2の処理と、
前記要素の種別がツリー要素である場合、取得した要素を子ツリー要素とし、スタックエリアから最後に入れた要素を一つ取り出し、それを親ツリー要素とする第3の処理と、
前記親ツリー要素に子ツリー要素を加えてスタックエリアに入れて保存する第4の処理と、
前記子ツリー要素をスタックエリアに入れて保存し、前記第2の処理に戻って次の要素を取得する第5の処理と、
前記第2の処理で、要素の種別が階層識別子である場合、スタックエリアから最後に入れた要素を取り出し、前記第2の処理に戻る第6の処理と、
を文字列データの要素がなくなるまで繰り返すことを特徴とする。
(7) The restoration from the character string data converted by the above (3) to the tree structure data is as follows:
A first process for obtaining the first element from the character string data and storing it in the stack area as a root tree element;
A second process of acquiring the next element in the tree character string data and checking its type;
When the type of the element is a tree element, a third process in which the acquired element is set as a child tree element, one element put last from the stack area is taken as a parent tree element,
A fourth process of adding a child tree element to the parent tree element and storing it in a stack area;
A fifth process for storing the child tree element in a stack area and returning to the second process to obtain a next element;
In the second process, when the type of the element is a hierarchy identifier, a sixth process of taking out the last element put in from the stack area and returning to the second process;
Is repeated until there are no more elements in the character string data.

(8)前記(4)により変換された前記文字列データからツリー構造データへの復元は、
ツリー文字列データからm行n列のマトリックスデータを作成する第1の処理と、
前記マトリックスデータの1行1列目の要素をツリー構造データのルート要素として決定する第2の処理と、
前記列nおよび行mを順次インクリメントしながら、m行目n列目のデータをn−1列目のうちm行より小さくかつその値が最大となるような要素の子ツリー要素として追加する第3の処理と、
を前記マトリックスデータの要素がなくなるまで繰り返すことを特徴とする。
(8) The restoration from the character string data converted by the above (4) to the tree structure data is as follows:
A first process of creating matrix data of m rows and n columns from tree character string data;
A second process for determining an element in the first row and the first column of the matrix data as a root element of the tree structure data;
While sequentially incrementing the column n and the row m, the data of the m-th row and the n-th column is added as a child tree element of an element that is smaller than the m-th row and has the maximum value in the (n-1) th column 3 processing,
Is repeated until there are no more elements in the matrix data.

(9)前記(5)または(6)により変換された文字列データからツリー構造データへの復元は、
ツリー文字列データ全体の先頭のツリー要素を親ツリー要素(car要素)とし、その他の要素を子ツリー要素(cdr要素)とする第1の処理と、
前記子ツリー要素がある限り、その先頭から順に一つずつ子ツリー要素を取り出す第2の処理と、
前記取り出した子ツリー要素が前記car要素とcdr要素から成り立っているか否かをチェックする第3の処理と、
前記子ツリー要素が前記car要素とcdr要素から成り立っていれば、親ツリー要素に子ツリー要素中のcar要素を追加する第4の処理と、
前記子ツリー要素中の前記car要素を親ツリー要素とし、子ツリー要素中の前記cdr要素を子ツリー要素とする第5の処理と、
前記第5の処理で区分した親ツリー要素と子ツリー要素を復元した要素として決定し、前記第2の処理に戻って次の要素についての繰り返し処理に入る第6の処理と、
前記第3の処理において、子ツリー要素が前記car要素とcdr要素から成り立っていない場合、親ツリー要素に子ツリー要素を追加し、前記第2の処理に戻る第7の処理と、
を文字列データの要素がなくなるまで繰り返すことを特徴とする。
(9) The restoration from the character string data converted by the above (5) or (6) to the tree structure data is as follows:
A first process in which the first tree element of the entire tree string data is a parent tree element (car element) and the other elements are child tree elements (cdr elements);
As long as there is the child tree element, a second process for taking out the child tree elements one by one from the top,
A third process for checking whether or not the extracted child tree element is composed of the car element and the cdr element;
If the child tree element is composed of the car element and the cdr element, a fourth process of adding the car element in the child tree element to the parent tree element;
A fifth process in which the car element in the child tree element is a parent tree element and the cdr element in the child tree element is a child tree element;
A sixth process of determining the parent tree element and the child tree element divided in the fifth process as restored elements and returning to the second process and entering a repetition process for the next element;
A seventh process of adding a child tree element to a parent tree element and returning to the second process when the child tree element is not composed of the car element and the cdr element in the third process;
Is repeated until there are no more elements in the character string data.

以上のとおり、本発明によれば、ツリー構造データをデータサイズを小さくして可読性文字列データに変換およびその逆変換ができる効果がある。具体的には、以下の効果がある。   As described above, according to the present invention, there is an effect that the tree structure data can be converted into readable character string data by converting the data size to be small and vice versa. Specifically, the following effects are obtained.

(1)請求項1の方法を用いることで、ツリー要素値を表現するツリー文字列データのサイズをXMLより小さくすることができる。   (1) By using the method of claim 1, the size of the tree character string data representing the tree element value can be made smaller than XML.

(2)請求項2の方法を用いることで、属性値が同じツリー要素が連続する場合は実施形態1よりもさらに小さいデータサイズとすることができる。   (2) By using the method of claim 2, when tree elements having the same attribute value continue, the data size can be made smaller than that of the first embodiment.

(3)ツリー要素中に子供のツリー要素がある場合は、ツリー文字列データ中にツリー階層を表現する必要がある。この場合には請求項3の方法を用いることで、閉じタグを省略でき、ツリー文字列データのサイズを小さくすることができる。   (3) When there is a child tree element in the tree element, it is necessary to express the tree hierarchy in the tree character string data. In this case, by using the method of claim 3, the closing tag can be omitted, and the size of the tree character string data can be reduced.

(4)請求項4の方法を用いることで、ツリー構造データの構造によっては請求項3の方法よりもさらにツリー文字列データのサイズを小さくできる場合がある。   (4) Depending on the structure of the tree structure data, the size of the tree character string data can be made smaller than that of the method of claim 3 by using the method of claim 4.

(5)請求項5または6の方法を用いることで、ツリー構造データの構造によっては請求項3の方法よりもさらにツリー文字列データのサイズを小さくできる場合がある。   (5) By using the method of claim 5 or 6, depending on the structure of the tree structure data, the size of the tree character string data may be made smaller than that of the method of claim 3.

(6)請求項7または8の方法を用いることで、文字列データからツリー構造データを復元できる。   (6) By using the method of claim 7 or 8, the tree structure data can be restored from the character string data.

上記の問題点を解決するため、ツリー構造データを文字列データ(以下、ツリー文字列データと呼ぶ)に変換する方法およびその逆変換方法の実施形態を以下に説明する。   In order to solve the above problem, an embodiment of a method for converting tree structure data into character string data (hereinafter referred to as tree character string data) and its inverse conversion method will be described below.

初めに本実施形態で使用する語句を次のように定義する。   First, terms used in this embodiment are defined as follows.

「ツリー構造データ」:ツリー構造を持つデータ。例えば図9のデータ。   “Tree structure data”: Data having a tree structure. For example, the data of FIG.

「ツリー要素」:ツリー構造データを構成するツリーの要素。例えば図9における網掛け部分。   “Tree element”: An element of a tree constituting tree structure data. For example, the shaded portion in FIG.

「ツリー要素名」:ツリー要素の名前。例えば図9の“経理部”など。   "Tree element name": Name of the tree element. For example, “Accounting Department” in FIG.

「ツリー要素属性」:ツリー要素の属性。例えば図9の“郵便番号”など。   “Tree element attributes”: attributes of tree elements. For example, “zip code” in FIG.

「ツリー要素属性値」:ツリー要素属性の値。例えば図9の”271−0067”など。   “Tree element attribute value”: the value of the tree element attribute. For example, “271-0067” in FIG.

「ツリー要素値」:ツリー要素の値。例えば図9の”福沢諭吉”など。   "Tree element value": The value of the tree element. For example, “Fukuzawa Yukichi” in FIG.

「ツリー文字列データ」:ツリー構造データを文字列に変換したデータ。   “Tree character string data”: Data obtained by converting tree structure data into character strings.

「ツリー要素セパレータ」:ツリー文字列データ中でツリー要素を区分する特定の文字。   "Tree element separator": A specific character that separates tree elements in tree string data.

本発明は、ツリー構造データがもつ階層を記述でき、しかもデータサイズを小さくしたツリー文字列データに変換するため、ツリー要素値やツリー属性値のデータ構造、およびツリー要素の親子関係のデータ構造を提供する。前者のデータ構造による変換方法を実施形態1と2で示し、後者のデータ構造による変換方法を実施形態3〜5で示す。   In the present invention, tree element data, tree attribute value data structures, and tree element parent-child data structures can be converted to tree character string data with a reduced data size that can describe the hierarchy of tree structure data. provide. The former data structure conversion method is shown in the first and second embodiments, and the latter data structure conversion method is shown in the third to fifth embodiments.

(実施形態1)ツリー要素値、ツリー要素属性、ツリー要素属性値のデータ構造と変換方法
XMLではツリー要素の初めと終わりにそれぞれタグを用いてその間にツリー要素値を記述するが、終わりにもタグを用いるため、その分データサイズが大きくなる。そこで、本実施形態は、ツリー構造データがもつ階層を記述したツリー要素値を表すデータ構造として、ツリー要素の終わりにはタグを用いない構造を提案する。
(Embodiment 1) Tree element value, tree element attribute, data structure of tree element attribute value and conversion method In XML, a tree element value is described between tags using tags at the beginning and end of the tree element. Since tags are used, the data size increases accordingly. Therefore, the present embodiment proposes a structure in which no tag is used at the end of a tree element as a data structure representing a tree element value describing a hierarchy of the tree structure data.

図1は、本実施形態により変換したツリー構造データとツリー文字列データ構造の例を示す。ツリー構造データ1を構成してデータベース等に格納される各ツリー要素は、ツリー要素名、ツリー要素属性、ツリー要素属性値、ツリー要素値などのデータをもつ。   FIG. 1 shows an example of tree structure data and tree character string data structure converted according to this embodiment. Each tree element constituting the tree structure data 1 and stored in a database or the like has data such as a tree element name, a tree element attribute, a tree element attribute value, and a tree element value.

データ変換部2は、ツリー構造データ1から目的とするツリー要素をツリー文字列データに変換して出力する。なお、データ変換部2は、ツリー文字列データをツリー構造データに逆変換する機能も持つ。   The data conversion unit 2 converts the target tree element from the tree structure data 1 into tree character string data and outputs it. The data conversion unit 2 also has a function of inversely converting tree character string data into tree structure data.

このデータ変換部2で変換したツリー文字列データ3は、初めにツリー要素名を配置する。その次にツリー属性名とツリー属性値をXMLと同様な記述方法で配置する。その次にツリー要素値識別子を配置する。これは、この識別子の次にツリー要素値を配置するという目印になるもので専用文字を用いる。そしてその次にツリー要素値を配置する。最後にツリー要素セパレータを配置し、ツリー要素の終わりを示す。これらを模式的に表すと下記のようになる。   In the tree character string data 3 converted by the data converter 2, a tree element name is first arranged. Next, the tree attribute name and the tree attribute value are arranged in the same description method as XML. Next, a tree element value identifier is arranged. This is a mark that a tree element value is arranged next to this identifier, and a dedicated character is used. Then, tree element values are arranged. Finally, place a tree element separator to indicate the end of the tree element. These are schematically represented as follows.

ツリー文字列データの構造=「ツリー要素名+ツリー要素属性名とツリー要素属性値+ツリー要素値識別子+ツリー要素値+ツリー要素セパレータ」
例えば、図9に示すツリー構造データに対して、図10に示すXMLの例は下記のようになる。
Tree character string data structure = "tree element name + tree element attribute name and tree element attribute value + tree element value identifier + tree element value + tree element separator"
For example, with respect to the tree structure data shown in FIG. 9, an example of XML shown in FIG. 10 is as follows.

[1]XMLによるツリー文字列データの例
<部員番号=”1”>福沢諭吉</部員>
<部員番号=”2”>新渡戸稲造</部員>
<部員番号=”3”>夏目漱石</部員>
これを本実施形態では下記のようなデータ構造に変換する。ここでは、ツリー要素値識別子に記号「%」を用い、ツリー要素セパレータに記号「,」を用いた場合である。
[1] Example of tree character string data by XML <member number = “1”> Yukichi Fukuzawa </ member>
<Member number = “2”> Inazo Nitobe <// member>
<Member No. = “3”> Soseki Natsume <// Member>
In the present embodiment, this is converted into the following data structure. Here, the symbol “%” is used for the tree element value identifier and the symbol “,” is used for the tree element separator.

[2]本実施形態によるツリー文字列データの例
部員番号=”1”%福沢諭吉,
部員番号=”2”%新渡戸稲造,
部員番号=”3”%夏目漱石,
上記のように本実施形態では、タグの終わりを示す部分にタグ名を用いない。そのため、ツリー文字列データのデータサイズが小さくなる。例えば、上記の[1]XMLによるツリー文字列データの例では90バイトであったものが、上記の[2]本実施形態の例では71バイトになっており、データサイズを約21%縮小することができる。
[2] Example of tree character string data according to this embodiment Member number = "1"% Yukichi Fukuzawa,
Member number = "2"% Nitobe Inazo,
Member number = "3"% Natsume Soseki,
As described above, in this embodiment, a tag name is not used for the portion indicating the end of the tag. Therefore, the data size of the tree character string data is reduced. For example, in the above example of [1] XML tree character string data, it is 90 bytes, but in the above [2] example of this embodiment, it is 71 bytes, and the data size is reduced by about 21%. be able to.

(実施形態2)リレー要素値の統合方法
本実施形態は、ツリー構造データがもつ階層を記述したツリー要素値を表すデータ構造として、ツリー要素属性が無い場合や有る場合でもそのツリー要素属性値が共通する場合は、ツリー要素名を一つ配置し、その後ろにツリー要素値識別子を用いてツリー要素値を連結配置した構造とする。
(Embodiment 2) Relay Element Value Integration Method In this embodiment, the tree element attribute value is the data structure representing the tree element value describing the hierarchy of the tree structure data, even when there is no tree element attribute or when there is no tree element attribute. If they are common, one tree element name is arranged, and a tree element value identifier is used behind the tree element value to form a structure in which the tree element values are connected and arranged.

実施形態1と同様に、初めにツリー要素名を配置する。その次にツリー属性名とツリー属性値をXMLと同様な記述方法で配置する。その次にツリー要素値識別子を配置する。これは、この識別子の次にツリー要素値を配置するという目印になるもので専用文字を用いる。そしてその次にツリー要素値を配置する。ここでツリー要素名、ツリー要素属性名、ツリー要素属性値が同一のツリー要素値がある場合には、その後ろにツリー要素値識別子を加え、その後ろにツリー要素値を配置する。この組み合わせを繰り返す。これらを模式的に表すと下記のようになる。   As in the first embodiment, the tree element names are arranged first. Next, the tree attribute name and the tree attribute value are arranged in the same description method as XML. Next, a tree element value identifier is arranged. This is a mark that a tree element value is arranged next to this identifier, and a dedicated character is used. Then, tree element values are arranged. Here, when there is a tree element value having the same tree element name, tree element attribute name, and tree element attribute value, a tree element value identifier is added behind the tree element value, and the tree element value is arranged behind the tree element value identifier. Repeat this combination. These are schematically represented as follows.

ツリー文字列データの構造=「ツリー要素名+ツリー要素属性とツリー要素属性値+ツリー要素値識別子+ツリー要素値+ツリー要素値識別子+ツリー要素値+ツリー要素値識別子+ツリー要素値+……+ツリー要素セパレータ」
例えばツリー要素名が「部員入社年」のXMLの例は下記のようになる。
Tree character string data structure = “tree element name + tree element attribute and tree element attribute value + tree element value identifier + tree element value + tree element value identifier + tree element value + tree element value identifier + tree element value + …… + Tree element separator "
For example, an XML example in which the tree element name is “membership year” is as follows.

[3]XMLによるツリー文字列データの例
<部員入社年=”2003”>福沢諭吉</部員>
<部員入社年=”2003”>新渡戸稲造</部員>
<部員入社年=”2003”>夏目漱石</部員>
これを本実施形態では下記のようなデータ構造に変換する。ここでは、ツリー要素値識別子に%を用い、ツリー要素セパレータに記号「,」を用いた。
[3] Example of tree character string data by XML <membership year = “2003”> Yukichi Fukuzawa </ member>
<Year of joining the club = “2003”> Inazo Nitobe // Member
<Participation year = “2003”> Soseki Natsume </ members>
In the present embodiment, this is converted into the following data structure. Here,% is used for the tree element value identifier, and the symbol “,” is used for the tree element separator.

[4]本実施形態によるツリー文字列データの例
部員入社年=”2003”%福沢諭吉%新渡戸稲造%夏目漱石,
上記のように本実施形態では、ツリー要素名が複数ある場合でもそれを一つで記述できる。そのため、ツリー文字列データのデータサイズが小さくなる。例えば、上記のXMLの例になる[3]では107バイトあったものが、本実施形態の例になる[4]の例8では48バイトになっており、データサイズを約55%縮小することができる。
[4] Example of tree character string data according to this embodiment Membership year = “2003”% Yukichi Fukuzawa% Inazo Nitobe% Soseki Natsume,
As described above, in the present embodiment, even when there are a plurality of tree element names, they can be described as one. Therefore, the data size of the tree character string data is reduced. For example, in the above XML example [3], 107 bytes is used, but in the example [4] 8 of this embodiment, it is 48 bytes, and the data size is reduced by about 55%. Can do.

(実施形態3)深さ優先方法
ツリー構造データでは各ツリー要素に親子関係(ツリー階層)が存在する。XMLではツリー要素の始まりと終わりにタグを用いてその間に子タグを書くことでツリー階層を表現している(図10参照)。本実施形態は、ツリー階層を表すのにツリー要素の終わりのタグを不要にした方法を提案する。
(Embodiment 3) Depth priority method In tree structure data, a parent-child relationship (tree hierarchy) exists in each tree element. In XML, a tree hierarchy is expressed by using a tag at the beginning and end of a tree element and writing a child tag between them (see FIG. 10). The present embodiment proposes a method in which the tag at the end of the tree element is not required to represent the tree hierarchy.

(1)ツリー階層関係のデータ変換方法
本実施形態では、ツリー構造データの階層を表すデータ構造として、あるツリー要素(ここではAと呼ぶ)についてそのツリー要素の子階層に属するツリー要素(ここではBと呼ぶ)がある場合には、ツリー文字列データ中において「A,B」という順で配置した構造とする。子階層のツリー要素がない場合はそれを示す識別子を配置した構造とする。なお、ツリー要素値、ツリー要素属性、ツリー要素属性値については、実施形態1と2で示した方法で配置する。
(1) Tree Hierarchy Relationship Data Conversion Method In this embodiment, as a data structure representing the hierarchy of tree structure data, a tree element (here A) is a tree element belonging to a child hierarchy of the tree element (here A) In this case, the tree character string data is arranged in the order of “A, B”. If there is no tree element in the child hierarchy, an identifier indicating the element is arranged. The tree element value, the tree element attribute, and the tree element attribute value are arranged by the method shown in the first and second embodiments.

図1のデータ変換部2によるデータ変換手順を以下に示す。   A data conversion procedure by the data conversion unit 2 in FIG. 1 is shown below.

(S1)初めにルートツリー要素を取得する。   (S1) First, a root tree element is acquired.

(S2)データ変換が指定されたツリー要素をツリー文字列データに追加する。   (S2) A tree element for which data conversion is designated is added to the tree character string data.

(S3)データ変換が指定されたツリー要素に対して子ツリー要素がなければ、固有の識別子をツリー文字列データに追加する。この識別子をツリー階層識別子と呼ぶ。   (S3) If there is no child tree element for the tree element for which data conversion is designated, a unique identifier is added to the tree character string data. This identifier is called a tree hierarchy identifier.

(S4)子ツリー要素があれば、それを指定して処理(S2)、(S3)を再帰的に繰り返す。子ツリー要素が複数ある場合には、一つずつ(S2)、(S3)を再帰的に繰り返す。   (S4) If there is a child tree element, it is designated and the processing (S2) and (S3) are recursively repeated. When there are a plurality of child tree elements, (S2) and (S3) are recursively repeated one by one.

(S5)全ての子ツリー要素についての処理が終われば、ツリー階層識別子をツリー文字列データに追加する。   (S5) When processing for all child tree elements is completed, a tree hierarchy identifier is added to the tree character string data.

例えば、図2の(a)に示すように、あるツリー要素Aの1つ下の階層にツリー要素Bとツリー要素Cがある場合には、ツリー階層識別子に記号「@」を用い、ツリー要素セパレータには記号「,」を用いると、図2の(b)に示すようになる。   For example, as shown in FIG. 2A, when there are a tree element B and a tree element C in a hierarchy one level below a certain tree element A, the symbol “@” is used as the tree hierarchy identifier, and the tree element When the symbol “,” is used for the separator, it becomes as shown in FIG.

同様に図9のデータ変換結果は下記のような記述になる。   Similarly, the data conversion result of FIG. 9 has the following description.

[5]本実施形態によるツリー階層をもつツリー要素のデータ変換例
会社組織,東京本社,経理部住所=”7階”郵便番号=”271−0067”,部員番号=”1”%福沢諭吉,@,部員番号=”1”%新渡戸稲造,@,部員番号=”1”%夏目漱石,@,@,@,沼津工場,技術部,@,試験部,@,@,関西支社,営業部,@,@,@,
(2)ツリー文字列データからツリー構造データへの復元方法
データ変換部2は、ツリー文字列データからツリー構造データへの復元機能を設け、この処理は図3に示し、以下の手順で実現される。
[5] Data conversion example of tree element having tree hierarchy according to this embodiment Company organization, Tokyo head office, accounting department address = “7th floor” ZIP code = “271-0067”, department number = “1”% Fukuzawa Yukichi, @, Department number = "1"% Nitobe Inazo, @, department number = "1"% Natsume Soseki, @, @, @, Numazu factory, engineering department, @, testing department, @, @, Kansai branch office, sales department , @, @, @,
(2) Method for Restoring Tree Character String Data to Tree Structure Data The data conversion unit 2 has a function for restoring tree character string data to tree structure data. This process is shown in FIG. The

まず、ツリー文字列データから先頭の要素を取得し、それをルートツリー要素とする。その要素をスタックエリアに入れて保存する(S11)。次に、ツリー文字列データ中の次の要素を取得し(S12)、その要素の種別をチェックする(S13)。当該要素がツリー要素である場合、取得した要素を子ツリー要素とし、スタックエリアから最後に入れた要素を一つ取り出し、それを親ツリー要素とする(S14)。当該、親ツリー要素に子ツリー要素を加え(S15)、当該親ツリー要素をスタックエリアに入れて保存し(S16)、子ツリー要素をスタックエリアに入れて保存し、処理S2に戻って次の要素を取得する(S17)。   First, the first element is acquired from the tree character string data, and is used as the root tree element. The element is stored in the stack area (S11). Next, the next element in the tree character string data is acquired (S12), and the type of the element is checked (S13). If the element is a tree element, the acquired element is set as a child tree element, and one element put last from the stack area is taken out and set as a parent tree element (S14). The child tree element is added to the parent tree element (S15), the parent tree element is stored in the stack area (S16), the child tree element is stored in the stack area, the process returns to step S2, and the next An element is acquired (S17).

取得した要素の種別が階層識別子である場合、スタックエリアから最後に入れた要素を取り出し、処理S12に戻って次の要素を取得する(S18)。   If the type of the acquired element is a hierarchy identifier, the last element entered is taken out from the stack area, and the process returns to step S12 to acquire the next element (S18).

以上の処理(S12)〜(S18)を要素がなくなるまで繰り返し、要素がなくなったときに処理を終了する。   The above processes (S12) to (S18) are repeated until there are no more elements, and the process ends when there are no more elements.

(3)本実施形態の特徴
本実施形態では、ツリー文字列データ中に各要素を1回配置するため、ツリー要素数が増加した場合のツリー文字列データサイズの増加の度合いはXMLに比べて低くすることができる。また、実施形態1や2と併用することでツリー要素に要素値や属性値を持たせることが可能なのでXMLと同様なツリー構造データへの逆変換ができる。
(3) Features of the present embodiment In the present embodiment, each element is arranged once in the tree character string data. Therefore, the degree of increase in the tree character string data size when the number of tree elements is increased as compared to XML. Can be lowered. In addition, when used in combination with the first and second embodiments, tree elements can have element values and attribute values, so that reverse conversion to tree structure data similar to XML can be performed.

(4)本実施形態におけるデータ量
本実施形態では、深さ優先方法でのデータ量は下記のようになる。
(4) Data amount in this embodiment In this embodiment, the data amount in the depth priority method is as follows.

データ量=各要素サイズの合計+ツリー階層識別子サイズ*ツリー階層識別子数+ツリー要素セパレータサイズ*ツリー要素セパレータ数
上記のツリー文字列データのデータ量dは、全要素数をx、要素サイズをe、ツリー階層識別子サイズを1、ツリー要素セパレータサイズを1とすると、下記の式から求めることができる。
Data amount = total of each element size + tree hierarchy identifier size * number of tree hierarchy identifiers + tree element separator size * number of tree element separators The data amount d of the above tree character string data is x for the total number of elements and e for the element size. When the tree hierarchy identifier size is 1 and the tree element separator size is 1, it can be obtained from the following equation.

d=(e+3)x−1
なぜならば
d=要素サイズ*全要素数+ツリー階層識別子サイズ*ツリー階層識別子数+ツリー要素セパレータサイズ*ツリー要素セパレータ数
であり、この式において、要素サイズ=e、ツリー階層識別子サイズ=1,ツリー階層識別子数=全要素数=x、ツリー要素セパレータサイズ=1、ツリー要素セパレータ数=全要素数+ツリー階層識別子数−1=2x−1となり、よって、
d=ex+x+2x−1=(e+3)x−1
になる。
d = (e + 3) x-1
This is because d = element size * total number of elements + tree hierarchy identifier size * number of tree hierarchy identifiers + tree element separator size * number of tree element separators. In this expression, element size = e, tree hierarchy identifier size = 1, tree Hierarchy identifier number = total element number = x, tree element separator size = 1, tree element separator number = total element number + tree hierarchy identifier number−1 = 2x−1.
d = ex + x + 2x-1 = (e + 3) x-1
become.

(実施形態4)マトリックス
(1)ツリー階層関係のデータ変換方法
本実施形態では、ツリー構造データの階層を表すデータ構造として、ツリー構造データをm*nの行列として配置した構造とする。列は階層を示し、行は一つの階層におけるツリー要素を割り当てるか、または、行と列が逆になってもよい。行数と列数は行列の先頭に位置させる。また、ツリー要素の区分にはツリー要素セパレータを用いる。なお、ツリー要素値、ツリー要素属性、ツリー要素属性値については、実施形態1と2で示した方法で配置する。
(Embodiment 4) Matrix (1) Data conversion method related to tree hierarchy In this embodiment, a tree structure data is arranged as an m * n matrix as a data structure representing a hierarchy of tree structure data. Columns indicate hierarchies and rows may assign tree elements in one hierarchy, or rows and columns may be reversed. Place the number of rows and columns at the top of the matrix. In addition, a tree element separator is used to classify tree elements. The tree element value, the tree element attribute, and the tree element attribute value are arranged by the method shown in the first and second embodiments.

例えば、あるツリー要素Aの1つ下の階層にツリー要素Bとツリー要素Cがある場合には、行数2階数2の行列として記述し、模式的に示すと図4の(a)に示すようになる。   For example, when there is a tree element B and a tree element C in the hierarchy immediately below a certain tree element A, it is described as a matrix having 2 rows and 2 ranks, and schematically shown in FIG. It becomes like this.

これをツリー文字列データで記述するとツリー要素セパレータに記号「,」を用いて以下のようになる。   When this is described by tree character string data, the symbol “,” is used for the tree element separator as follows.

[6]本実施形態によるツリー文字列データの例。   [6] Example of tree character string data according to the present embodiment.

2,2,A,B,,C
同様にして図9のデータは図4の(b)に示すようになる。図中の数字は便宜上、行番号と列番号を示すもので、実際のデータには含まれない。これを文字列で示すと、下記のようになる。
2, 2, A, B, C
Similarly, the data in FIG. 9 is as shown in FIG. The numbers in the figure indicate row numbers and column numbers for convenience, and are not included in actual data. This is shown as a character string as follows.

[7]本実施形態によるツリー文字列データの例。   [7] Example of tree character string data according to the present embodiment.

6,4,会社組織,東京本社,経理部住所=”7階”郵便番号=”271−0067”,部員番号=”1”%福沢諭吉,,,,部員番号=”2”%新渡戸稲造,,,,部員番号=”3”%夏目漱石,,沼津工場,技術部,,,,試験部,,,関西支社,営業部,
(2)ツリー文字列データからツリー構造データへの復元方法
データ変換部2は、ツリー文字列データからツリー構造データへの復元機能を設け、この処理は図5に示し、以下の手順で実現される。
6,4, company organization, Tokyo head office, accounting department address = "7th floor" zip code = "271-0067", department number = "1"% Yukichi Fukuzawa, ..., department number = "2"% Nitobe Inazo, ,, Employee ID = "3"% Natsume Soseki, Numazu Factory, Engineering Department, Testing Department, Kansai Branch, Sales Department,
(2) Restoration method from tree character string data to tree structure data The data converter 2 has a restoration function from tree character string data to tree structure data. This process is shown in FIG. The

(S21)ツリー文字列データから図4の(b)のようなm行n列のマトリックスデータを作成する。   (S21) Create matrix data of m rows and n columns as shown in FIG. 4B from the tree character string data.

(S22)マトリックスデータの1行1列目の要素をツリー構造データのルート要素として決定する。   (S22) The element in the first row and first column of the matrix data is determined as the root element of the tree structure data.

(S23)m=1,n=2の初期設定をする。   (S23) Initial setting is made such that m = 1 and n = 2.

(S24)マトリックスデータのm行n列目の要素を取得し、それをm行(n−1)列目の子ツリー要素として追加する。   (S24) An element in the m-th row and the n-th column of the matrix data is acquired and added as a child tree element in the m-th row (n-1) column.

(S25)nをインクリメント(+1)する。   (S25) Increment n (+1).

(S26)nが最大値maxを越えたか否かチェックし、越えていなければS24に戻って次のm行n列目の要素を追加する。   (S26) It is checked whether or not n exceeds the maximum value max. If not, the process returns to S24 to add the element in the next m-th row and n-th column.

(S27)nが最大値maxを越えていれば、mをインクリメントし、n=2に戻し、次のm行の2列目の要素を追加対象として設定する。   (S27) If n exceeds the maximum value max, m is incremented and returned to n = 2, and the element in the second column of the next m row is set as an addition target.

(S28)mのインクリメント結果が最大行maxを越えたか否かをチェックし、越えていなければS24に戻って次のm行n列目の要素を追加する。   (S28) It is checked whether or not the increment result of m exceeds the maximum row max. If not, the process returns to S24 to add the next m-th row and n-th element.

上記のように、ツリー文字列データからツリー構造データへの復元には、ツリー文字列データからm行n列のマトリックスデータを作成し、マトリックスデータの1行1列目の要素をツリー構造データのルート要素として決定する。その後は、列nおよび行mを順次インクリメントしながら、m行目n列目のデータをn−1列目のうちm行より小さくかつその値が最大となるような要素の子ツリー要素として追加する処理を、マトリックスデータの要素がなくなるまで繰り返すことで実現される。   As described above, to restore from the tree character string data to the tree structure data, the matrix data of m rows and n columns is created from the tree character string data, and the element of the first row and the first column of the matrix data is changed to the tree structure data. Determine as root element. After that, the column n and the row m are sequentially incremented, and the data in the m-th row and the n-th column are added as child tree elements of an element that is smaller than the m-th row in the n-1th column and has the maximum value. This process is realized by repeating the process until there are no more matrix data elements.

(3)本実施形態の特徴
マトリックス方法では実施形態3に示すツリー階層識別子の指定は不要であり、その分ツリー文字列データのデータ量が少なくなる。マトリックス方法を用いれば、ツリー構造データの構造によっては、ツリー文字列データのデータ量が深さ優先方法よりも少なくなる場合がある。実施形態1や2と併用することでツリー要素に要素値や属性値を持たせることが可能なのでXMLと同様なツリー構造データを記述することができる。欠点としては、データサイズがデータ構造により大きく変化することがある。
(3) Features of the present embodiment In the matrix method, it is not necessary to specify the tree hierarchy identifier shown in the third embodiment, and the amount of tree character string data is reduced accordingly. If the matrix method is used, the amount of data of the tree character string data may be smaller than the depth priority method depending on the structure of the tree structure data. By using in combination with the first and second embodiments, tree elements can have element values and attribute values, so that tree structure data similar to XML can be described. The disadvantage is that the data size varies greatly depending on the data structure.

(4)データ量
マトリックス方法でのデータ量は以下のようになる(行数と列数を除く)。
(4) Data volume The data volume in the matrix method is as follows (excluding the number of rows and columns).

データ量=各要素サイズの合計+ツリー要素セパレータサイズ*ツリー要素セパレータ数
データ量dは、全要素数をx、要素サイズをe、ツリー要素セパレータサイズを1とすると次式のように表現できる。
Data amount = total of each element size + tree element separator size * number of tree element separators Data amount d can be expressed as the following equation where x is the total number of elements, e is the element size, and 1 is the tree element separator size.

d=(1/4)*x^2+(e+1/2)*x−(3/4)(最大時)
d=(e+1)x−1(最小時)
(注)最小時とは、マトリックス中に空白要素が無い場合である。最大時とは、m*nの行列で1行とn列のみに要素があり、他は空白要素の場合である。
d = (1/4) * x ^ 2 + (e + 1/2) * x- (3/4) (at maximum)
d = (e + 1) × −1 (at minimum)
(Note) The minimum time is when there are no blank elements in the matrix. The maximum time is a case of an m * n matrix having elements only in one row and n columns and the others being blank elements.

なぜならば、
d=要素サイズ*全要素数+ツリー要素セパレータサイズ*ツリー要素セパレータ数
ここで最小時には、
ツリー要素セパレータ数=全要素数一1となり
d=e*x+x−1=(e+1)x−1
最大時には、
ツリー要素セパレータ数=((全要素数+1)/2)^2−1
となり、以下のようになる。
because,
d = element size * total number of elements + tree element separator size * number of tree element separators
The number of tree element separators = the total number of elements becomes 1, 1 d = e * x + x−1 = (e + 1) x−1
At maximum,
Number of tree element separators = ((total number of elements + 1) / 2) ^ 2-1
It becomes as follows.

d=e*x+((x+1)/2)^2−1=(1/4)*x^2+(e+1/2)*x−(3/4)
(実施形態5)リスト
(1)ツリー階層関係のデータ変換方法
本実施形態では、ツリー構造データの階層を表すデータ構造として、あるツリー要素とその子要素にあたる全てのツリー要素の先頭と最後尾を識別子で区切って配置した構造とする。ここでは、先頭の識別子をツリー階層先頭識別子と呼び、最後尾の識別子をツリー階層最後尾識別子と呼び、合わせてツリー階層識別子と呼ぶ。
d = e * x + ((x + 1) / 2) ^ 2-1 = (1/4) * x ^ 2 + (e + 1/2) * x- (3/4)
(Embodiment 5) List (1) Data conversion method of tree hierarchy relation In this embodiment, as a data structure representing the hierarchy of tree structure data, the beginning and end of a tree element and all tree elements corresponding to its child elements are identified. The structure is separated by Here, the first identifier is called a tree hierarchy first identifier, the last identifier is called a tree hierarchy last identifier, and is collectively called a tree hierarchy identifier.

初めにツリー階層先頭識別子を配置し、その次には親ツリー要素を配置し、それ以降はその親ツリー要素の子ツリー要素を配置し、子ツリー要素の終わりにツリー階層最後尾識別子を配置する。ツリー要素やツリー階層識別子の区分にはツリー要素セパレータを用いる。   The tree hierarchy head identifier is placed first, the parent tree element is placed next, the child tree element of the parent tree element is placed thereafter, and the tree hierarchy tail identifier is placed at the end of the child tree element. . Tree element separators are used to classify tree elements and tree hierarchy identifiers.

子ツリー要素にさらに子ツリー要素(孫ツリー要素と呼ぶ)がある場合には、その子ツリー要素の前に再度ツリー階層先頭識別子を配置し、その後ろに子ツリー要素を配置し、その後ろに孫ツリー要素を配置し、孫ツリー要素の最後にツリー階層最後尾識別子を配置する。ツリー要素とツリー階層識別子の区分にもツリー要素セパレータを用いる。   If there are more child tree elements (called grandchild tree elements) in the child tree element, the tree hierarchy head identifier is again placed before the child tree element, the child tree element is placed behind it, and the grandchild behind it. A tree element is arranged, and a tree hierarchy tail identifier is arranged at the end of the grandchild tree element. Tree element separators are also used to distinguish between tree elements and tree hierarchy identifiers.

こうすることで、ツリー要素名中にツリー階層識別子と同じ文字を記述することができる。   By doing so, the same character as the tree hierarchy identifier can be described in the tree element name.

ツリー階層識別子に囲まれた中で先頭のツリー要素をcar要素と呼び、それ以外のツリー要素をcdr要素と呼ぶ。   The first tree element surrounded by the tree hierarchy identifier is called a car element, and the other tree elements are called cdr elements.

なお、ツリー要素値、ツリー要素属性、ツリー要素属性値については、実施形態1と2で示した方法で配置する。   The tree element value, the tree element attribute, and the tree element attribute value are arranged by the method shown in the first and second embodiments.

例えば、あるツリー要素Aの一つ下の階層にツリー要素Bとツリー要素Cがある場合には、ツリー階層先頭識別子に記号「(」を用い、ツリー階層最後尾識別子に記号「)」を用い、ツリー要素セパレータには記号「,」を用いた場合に、図6の(a)のようになる。car要素はツリー要素Aであり、cdr要素はツリー要素BとCになる。   For example, when there are a tree element B and a tree element C in the hierarchy immediately below a certain tree element A, the symbol “(” is used as the tree hierarchy head identifier and the symbol “)” is used as the tree hierarchy tail identifier. When the symbol “,” is used for the tree element separator, the result is as shown in FIG. The car element is the tree element A, and the cdr element is the tree elements B and C.

同様にして、あるツリー要素Aの一つ下の階層にツリー要素Bがあり、その下にツリー要素Cがある場合には、図6の(b)のようになる。car要素はツリー要素Aであり、cdr要素は(,B,C,)になる。   Similarly, when there is a tree element B in the hierarchy immediately below a certain tree element A and the tree element C is below it, the result is as shown in FIG. The car element is the tree element A, and the cdr element is (, B, C,).

同様にして、あるツリー要素Aの一つ下の階層にツリー要素BとEがあり、ツリー要素Bの一つ下にツリー要素C、さらに一つ下にツリー要素Dがある場合には、図6の(c)のようになる。car要素はツリー要素Aであり、cdr要素は(,B,(,C,D,),)とEになる。   Similarly, when there are tree elements B and E in the hierarchy one level below a certain tree element A, tree element C is one level below tree element B, and tree element D is one level below, It becomes like (c) of 6. The car element is the tree element A, and the cdr element is (, B, (, C, D,),) and E.

同様に図9のデータ変換結果は下記のような記述になる。   Similarly, the data conversion result of FIG. 9 has the following description.

[8]本実施形態によるツリー文字列データの例。   [8] Example of tree character string data according to the present embodiment.

(,会社組織,(,東京本社,(,経理部住所=”7階”郵便番号=”271−0067”,部員番号=”1”%福沢諭吉,部員番号=”2”%新渡戸稲造,部員番号=”2”%夏目漱石,),),(,沼津工場,技術部,試験部,),(,関西支社,営業部,),)
(2)ツリー文字列データからツリー構造データへの復元方法
データ変換部2は、ツリー文字列データからツリー構造データへの復元機能を設け、この処理は図7に示し、以下の手順で実現される。
(, Company organization, (, Tokyo head office, (, accounting department address = "7th floor" zip code = "271-0067", department number = "1"% Fukuzawa Yukichi, department number = "2"% Nitobe Inzo, staff) Number = "2"% Natsume Soseki,),), (, Numazu Factory, Engineering Department, Testing Department,), (, Kansai Branch, Sales Department,),)
(2) Restoration method from tree character string data to tree structure data The data conversion unit 2 is provided with a restoration function from tree character string data to tree structure data. This process is shown in FIG. The

ツリー文字列データ全体の先頭のツリー要素(car要素)を親ツリー要素とし、そのcdr要素を子ツリー要素とする(S31)。この親ツリー要素と子ツリー要素を処理Aに渡して実行する(S32)。処理Aの開始で、指定された子ツリー要素がある限り、その先頭から順に一つずつ子ツリー要素を取り出す(S33)。なお、「一つずつ」とは、例えば、子ツリー要素がB,(C,C,)Eとすると、1番目がBで、2番目が(,C,D,)で、3番目がEである。   The first tree element (car element) of the entire tree character string data is set as a parent tree element, and the cdr element is set as a child tree element (S31). The parent tree element and child tree element are passed to the process A and executed (S32). As long as there is a designated child tree element at the start of the process A, child tree elements are taken out one by one from the top (S33). “One by one” means that, for example, if the child tree element is B, (C, C,) E, the first is B, the second is (, C, D,), and the third is E. It is.

次に、取り出した子ツリー要素がcar要素とcdr要素から成り立っているか否かをチェックする(S34)。子ツリー要素がcar要素とcdr要素から成り立っていれば、親ツリー要素に子ツリー要素中のcar要素を追加する(S35)。さらに、子ツリー要素中のcar要素を親ツリー要素とし、子ツリー要素中のcdr要素を子ツリー要素とする(S36)。このS36で区分した親ツリー要素と子ツリー要素を復元した要素として決定し、処理S33に戻って次の要素についての繰り返し処理に入る(S37)。処理S34において、子ツリー要素がcar要素とcdr要素から成り立っていない場合、親ツリー要素に子ツリー要素を追加し、処理S33に戻って次の要素についての繰り返し処理に入る(S38)。   Next, it is checked whether or not the extracted child tree element is composed of a car element and a cdr element (S34). If the child tree element is composed of a car element and a cdr element, the car element in the child tree element is added to the parent tree element (S35). Further, the car element in the child tree element is set as a parent tree element, and the cdr element in the child tree element is set as a child tree element (S36). The parent tree element and the child tree element divided in S36 are determined as restored elements, and the process returns to the process S33 to enter the repetition process for the next element (S37). If the child tree element is not composed of the car element and the cdr element in the process S34, the child tree element is added to the parent tree element, and the process returns to the process S33 to repeat the process for the next element (S38).

(3)本実施形態の特徴
本実施形態では、ツリー文字列データのサイズが実施形態3よりも小さくなる場合がある。ただし、データのサイズは、変換するツリー構造データの構造により変化する。その変化の度合いは、最小の場合は実施形態3よりも小さく実施形態4の最小値とほぼ同じである。最大の場合でも実施形態4の最大の場合よりも小さくなる。データサイズの比較は後に説明する。
(3) Features of the present embodiment In the present embodiment, the size of the tree character string data may be smaller than that of the third embodiment. However, the data size changes depending on the structure of the tree structure data to be converted. The minimum degree of change is smaller than that in the third embodiment and is almost the same as the minimum value in the fourth embodiment. Even the maximum case is smaller than the maximum case of the fourth embodiment. Comparison of data sizes will be described later.

また、本実施形態では、実施形態1や2と併用することでツリー要素に要素値や属性値を持たせることが可能なのでXMLと同様なツリー構造データを得ることができる。   Further, in this embodiment, by using together with the first and second embodiments, tree elements can have element values and attribute values, so that tree structure data similar to XML can be obtained.

短所としては、ツリー文字列データをツリー構造データにする場合に、ツリー文字列データの先頭から順に処理するだけではなく、あるツリー階層先頭識別子に対応したツリー階層最後尾識別子を探す必要があるなど、処理が複雑になる。そのため、変換する際の処理負荷が大きくなることが挙げられる。   Disadvantages include: when converting tree string data to tree structure data, it is necessary not only to process the tree string data from the beginning of the tree string data but also to find the tree hierarchy tail identifier corresponding to a certain tree hierarchy head identifier. , Processing becomes complicated. Therefore, the processing load at the time of conversion increases.

(4)データ量
本実施形態でのデータ量は以下のようになる。
(4) Data amount The data amount in this embodiment is as follows.

データ量=各要素サイズの合計+ツリー階層識別子サイズ*ツリー階層識別子数+ツリー要素セパレータサイズ*ツリー要素セパレータ数
データ量dは、全要素数をx、要素サイズをe、識別子サイズを1、ツリー要素セパレータサイズを1とすると次式のように表現できる。
Data amount = total of each element size + tree hierarchy identifier size * number of tree hierarchy identifiers + tree element separator size * number of tree element separators The data amount d is x for all elements, e for element size, 1 for identifier size, tree If the element separator size is 1, it can be expressed as:

d=(e+5)x−5(最大時)
d=(e+1)x+3(最小時)
(注)最小時とは、親ツリー要素が一つであり他のツリー要素は全てその子ツリー要素の場合である。最大時とは、親ツリー要素が一つあり、その子要素ツリー要素が一つあり、その子要素ツリーに子要素ツリーが一つあり、…を繰り返す場合である。
d = (e + 5) × −5 (at maximum)
d = (e + 1) x + 3 (minimum)
(Note) The minimum time is a case where there is one parent tree element and all other tree elements are child tree elements. The maximum time is when there is one parent tree element, one child element tree element, one child element tree in the child element tree, and so on.

なぜならば、
最小時には、識別子数=2となり、
d=ex+2+(x+2−1)
=(e+1)x+3
最大時には、識別指数=(x一1)*2となり、
d=ex+(x−1)*2+{x+(x−1)*2−1}
=(e+5)x−5
また、XMLのデータサイズは省略タグ「/」を用いた場合で、ヘッダーや属性を除いた部分のデータサイズは次のようになる。
because,
At the minimum, the number of identifiers = 2,
d = ex + 2 + (x + 2-1)
= (E + 1) x + 3
At the maximum, the identification index = (x 1 1) * 2
d = ex + (x-1) * 2 + {x + (x-1) * 2-1}
= (E + 5) x-5
The XML data size is the case where the abbreviation tag “/” is used, and the data size of the portion excluding the header and attributes is as follows.

最小時:(e+3)x−1
最大時:2x+7e−2
(各実施形態のデータ量比較)
ツリー階層を表現する方法として実施形態3〜5を示したが、これとXMLでツリー階層を表したときのツリー文字列データのサイズ比較を下記の表に示す。
Minimum: (e + 3) x-1
Maximum time: 2x + 7e-2
(Data amount comparison of each embodiment)
Embodiments 3 to 5 have been shown as methods for expressing a tree hierarchy, and the following table shows a comparison of the size of tree character string data when the tree hierarchy is expressed in XML.

Figure 2005148970
Figure 2005148970

比較に使用したツリー構造データは、図9に示したデータである。これを見るといずれの場合もXMLよりデータサイズが20%以上小さくなっていることが分かる。   The tree structure data used for the comparison is the data shown in FIG. From this, it can be seen that the data size is 20% or more smaller than XML in any case.

実施形態3〜5とXMLについて、ツリー要素数とツリー文字列データのサイズの関係をグラフにしたものを図8に示す。ここでは、各ツリー要素名のサイズを24、ツリー要素セパレータサイズを1、終端識別子サイズを1とした。また、実施形態4と5それからXMLの各方法はツリー構造データによりデータ量が異なるので、ある要素数のときにデータ数が最小(マトリックスが最も密になっている)、データ数が最大(マトリックスが最も疎になっている)、ツリー構造データが2分木(一つのツリー要素は二つの子ツリー要素を持つ)、の三つの場合について示した。   FIG. 8 is a graph showing the relationship between the number of tree elements and the size of tree character string data in the third to fifth embodiments and XML. Here, the size of each tree element name is 24, the tree element separator size is 1, and the end identifier size is 1. Further, since the data amounts of the fourth and fifth embodiments and the XML method differ depending on the tree structure data, the number of data is minimum (the matrix is most dense) and the number of data is the maximum (matrix). In this example, the tree structure data is binary tree (one tree element has two child tree elements).

図8を見ると、実施形態3(深さ優先)はXMLよりもデータサイズが小さいことが分かる。実施形態4(マトリックス)と実施形態5(リスト)では、実施形態3よりもさらにデータサイズが小さくなる場合があることが分かる。   FIG. 8 shows that the data size is smaller in the third embodiment (depth priority) than in XML. In the fourth embodiment (matrix) and the fifth embodiment (list), it can be seen that the data size may be smaller than that in the third embodiment.

本発明の実施形態1におけるデータ変換したツリー構造データとツリー文字列データ構造の例。5 shows an example of tree structure data and tree character string data structure after data conversion in Embodiment 1 of the present invention. 実施形態3におけるツリー階層関係のデータ変換例。14 is a data conversion example of a tree hierarchy relationship according to the third embodiment. 実施形態3におけるツリー文字列データからツリー構造データへの変換処理手順。The conversion processing procedure from the tree character string data to tree structure data in Embodiment 3. 実施形態4における行列構造とマトリックス方式の記述例。10 is a description example of a matrix structure and a matrix method according to the fourth embodiment. 実施形態4におけるツリー文字列データからツリー構造データへの復元処理手順。The restoration processing procedure from the tree character string data to the tree structure data in the fourth embodiment. 実施形態5における階層構造と文字列データ例。FIG. 10 is a hierarchical structure and character string data example in Embodiment 5. FIG. 実施形態5におけるツリー文字列データからツリー構造データへの変換処理手順。The conversion process procedure from the tree character string data to tree structure data in Embodiment 5. XMLと実施形態における要素数とツリー文字列データサイズの例。An example of the number of elements and tree character string data size in XML and the embodiment. ツリー構造データの例。Example of tree structure data. XMLの記述例。Description example of XML.

符号の説明Explanation of symbols

1 ツリー構造データ
2 データ変換部
3 ツリー文字列データ
1 Tree structure data 2 Data converter 3 Tree character string data

Claims (9)

ツリー構造を持つツリー構造データを、ツリー構造の階層を表しかつ可読性のある文字列データに変換、およびその逆変換をするデータ変換方法であって、
前記文字列データは、先頭にツリー要素名を配置し、その次にツリー属性名とツリー属性値を配置し、その次にツリー要素値識別子を配置し、その次にツリー要素値を配置し、最後にツリー要素セパレータを配置したデータ構造に変換することを特徴とするデータ変換方法。
A data conversion method for converting tree structure data having a tree structure into character string data that represents the hierarchy of the tree structure and is readable, and vice versa.
The string data is arranged with a tree element name at the head, followed by a tree attribute name and a tree attribute value, followed by a tree element value identifier, followed by a tree element value, A data conversion method characterized by converting to a data structure in which a tree element separator is arranged at the end.
前記ツリー要素値は、ツリー要素属性が無い場合や有る場合でもそのツリー要素属性値が共通する場合は、ツリー要素名を一つ表示し、その後ろにツリー要素値識別子を用いてツリー要素値を連結配置したデータ構造に変換することを特徴とする請求項1に記載のデータ変換方法。   Even if there is no tree element attribute or the tree element attribute value is common, the tree element value displays one tree element name, followed by the tree element value identifier using the tree element value identifier. 2. The data conversion method according to claim 1, wherein the data is converted into a concatenated data structure. 前記ツリー構造データが、あるツリー要素Aについてそのツリー要素の子階層に属するツリー要素Bがある場合、前記文字列データは「A,B」という順で配置し、子階層のツリー要素がない場合はツリー要素Aの後ろにそれを示す識別子を配置したデータ構造に変換することを特徴とする請求項1に記載のデータ変換方法。   When the tree structure data includes a tree element B belonging to a child hierarchy of the tree element for a certain tree element A, the character string data is arranged in the order of “A, B”, and there is no tree element of the child hierarchy 2. The data conversion method according to claim 1, wherein the data is converted into a data structure in which an identifier indicating the tree element A is arranged after the tree element A. 前記ツリー構造データは、階層を示す行mと、一つの階層におけるツリー要素を表す列nとした、m*nの行列として配置した構造とし、
このツリー構造データを使用して前記文字列データに変換することを特徴とする請求項1に記載のデータ変換方法。
The tree structure data has a structure arranged as a matrix of m * n, with a row m indicating a hierarchy and a column n representing a tree element in one hierarchy,
2. The data conversion method according to claim 1, wherein the tree structure data is used to convert the data into the character string data.
前記文字列データは、初めにツリー階層先頭識別子を配置し、その次には親ツリー要素を配置し、それ以降はその親ツリー要素の子ツリー要素を配置し、子ツリー要素の終わりにツリー階層最後尾識別子を配置したデータ構造とし、各ツリー要素とその子要素にあたる全てのツリー要素の先頭と最後尾に識別子を配置したデータ構造に変換することを特徴とする請求項1に記載のデータ変換方法。   In the character string data, a tree hierarchy top identifier is first arranged, then a parent tree element is arranged, child tree elements of the parent tree element are arranged thereafter, and the tree hierarchy is arranged at the end of the child tree element. 2. A data conversion method according to claim 1, wherein the data structure is a data structure in which the last identifier is arranged, and is converted into a data structure in which identifiers are arranged at the head and tail of all tree elements corresponding to each tree element and its child elements. . 前記ツリー構造データが、前記子ツリー要素の子ツリー要素になる孫ツリー要素がある場合、前記文字列データは、子ツリー要素の前に再度ツリー階層先頭識別子を配置し、その後ろに子ツリー要素を配置し、その後ろに孫ツリー要素を配置し、孫ツリー要素の最後にツリー階層最後尾識別子を配置したことを特徴とする請求項1に記載のデータ変換方法。   When the tree structure data includes a grandchild tree element that becomes a child tree element of the child tree element, the character string data includes a tree hierarchy head identifier again before the child tree element, and a child tree element after that. 2. The data conversion method according to claim 1, wherein a grandchild tree element is arranged behind the grandchild tree element, and a tree hierarchy tail identifier is arranged at the end of the grandchild tree element. 請求項3のデータ変換方法により変換された前記文字列データからツリー構造データへの復元は、
文字列データから先頭の要素を取得し、それをルートツリー要素としてスタックエリアに入れて保存する第1の処理と、
前記ツリー文字列データ中の次の要素を取得してその種別をチェックする第2の処理と、
前記要素の種別がツリー要素である場合、取得した要素を子ツリー要素とし、スタックエリアから最後に入れた要素を一つ取り出し、それを親ツリー要素とする第3の処理と、
前記親ツリー要素に子ツリー要素を加えてスタックエリアに入れて保存する第4の処理と、
前記子ツリー要素をスタックエリアに入れて保存し、前記第2の処理に戻って次の要素を取得する第5の処理と、
前記第2の処理で、要素の種別が階層識別子である場合、スタックエリアから最後に入れた要素を取り出し、前記第2の処理に戻る第6の処理と、
を文字列データの要素がなくなるまで繰り返すことを特徴とする請求項3に記載のデータ変換方法。
The restoration from the character string data converted by the data conversion method according to claim 3 to tree structure data is as follows:
A first process for obtaining the first element from the character string data and storing it in the stack area as a root tree element;
A second process of acquiring the next element in the tree character string data and checking its type;
When the type of the element is a tree element, a third process in which the acquired element is a child tree element, one element that is finally inserted from the stack area, and is used as a parent tree element;
A fourth process of adding a child tree element to the parent tree element and storing it in a stack area;
A fifth process for storing the child tree element in a stack area and returning to the second process to obtain a next element;
In the second process, when the type of the element is a hierarchy identifier, a sixth process of taking out the last element put in from the stack area and returning to the second process;
4. The data conversion method according to claim 3, wherein the process is repeated until there are no more elements in the character string data.
請求項4のデータ変換方法により変換された文字列データからツリー構造データへの復元は、
ツリー文字列データからm行n列のマトリックスデータを作成する第1の処理と、
前記マトリックスデータの1行1列目の要素をツリー構造データのルート要素として決定する第2の処理と、
前記列nおよび行mを順次インクリメントしながら、m行目n列目のデータをn−1列目のうちm行より小さくかつその値が最大となるような要素の子ツリー要素として追加する第3の処理と、
を前記マトリックスデータの要素がなくなるまで繰り返すことを特徴とする請求項4に記載のデータ変換方法。
The restoration from the character string data converted by the data conversion method of claim 4 to the tree structure data is as follows:
A first process of creating matrix data of m rows and n columns from tree character string data;
A second process for determining an element in the first row and the first column of the matrix data as a root element of the tree structure data;
While sequentially incrementing the column n and the row m, the data of the m-th row and the n-th column is added as a child tree element of an element that is smaller than the m-th row and has the maximum value in the (n-1) th column 3 processing,
5. The data conversion method according to claim 4, wherein the process is repeated until there are no more elements in the matrix data.
請求項5または6のデータ変換方法により変換された文字列データからツリー構造データへの復元は、
ツリー文字列データ全体の先頭のツリー要素を親ツリー要素(car要素)とし、その他の要素を子ツリー要素(cdr要素)とする第1の処理と、
前記子ツリー要素がある限り、その先頭から順に一つずつ子ツリー要素を取り出す第2の処理と、
前記取り出した子ツリー要素が前記car要素とcdr要素から成り立っているか否かをチェックする第3の処理と、
前記子ツリー要素が前記car要素とcdr要素から成り立っていれば、親ツリー要素に子ツリー要素中のcar要素を追加する第4の処理と、
前記子ツリー要素中の前記car要素を親ツリー要素とし、子ツリー要素中の前記cdr要素を子ツリー要素とする第5の処理と、
前記第5の処理で区分した親ツリー要素と子ツリー要素を復元した要素として決定し、前記第2の処理に戻って次の要素についての繰り返し処理に入る第6の処理と、
前記第3の処理において、子ツリー要素が前記car要素とcdr要素から成り立っていない場合、親ツリー要素に子ツリー要素を追加し、前記第2の処理に戻る第7の処理と、
を文字列データの要素がなくなるまで繰り返すことを特徴とする請求項5または6に記載のデータ変換方法。
The restoration from the character string data converted by the data conversion method according to claim 5 to the tree structure data is as follows:
A first process in which the first tree element of the entire tree string data is a parent tree element (car element) and the other elements are child tree elements (cdr elements);
As long as there is the child tree element, a second process for taking out the child tree elements one by one from the top,
A third process for checking whether or not the extracted child tree element is composed of the car element and the cdr element;
If the child tree element is composed of the car element and the cdr element, a fourth process of adding the car element in the child tree element to the parent tree element;
A fifth process in which the car element in the child tree element is a parent tree element and the cdr element in the child tree element is a child tree element;
A sixth process of determining the parent tree element and the child tree element divided in the fifth process as restored elements and returning to the second process and entering a repetition process for the next element;
A seventh process of adding a child tree element to a parent tree element and returning to the second process when the child tree element is not composed of the car element and the cdr element in the third process;
The data conversion method according to claim 5, wherein the process is repeated until no character string data element is left.
JP2003383334A 2003-11-13 2003-11-13 Method for converting data Pending JP2005148970A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
JP2003383334A JP2005148970A (en) 2003-11-13 2003-11-13 Method for converting data

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
JP2003383334A JP2005148970A (en) 2003-11-13 2003-11-13 Method for converting data

Publications (1)

Publication Number Publication Date
JP2005148970A true JP2005148970A (en) 2005-06-09

Family

ID=34692085

Family Applications (1)

Application Number Title Priority Date Filing Date
JP2003383334A Pending JP2005148970A (en) 2003-11-13 2003-11-13 Method for converting data

Country Status (1)

Country Link
JP (1) JP2005148970A (en)

Cited By (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2008205624A (en) * 2007-02-16 2008-09-04 Toshiba Corp Data transmitting method
JP2012502337A (en) * 2008-09-08 2012-01-26 トムソン ライセンシング Element encoding method and apparatus
JP2014194815A (en) * 2008-02-22 2014-10-09 Hiroaki Deguchi Text edition system, text edition method and text edition program
CN110765123A (en) * 2018-07-09 2020-02-07 株式会社日立制作所 Material data storage method, device and system based on tree structure

Cited By (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2008205624A (en) * 2007-02-16 2008-09-04 Toshiba Corp Data transmitting method
JP4728979B2 (en) * 2007-02-16 2011-07-20 株式会社東芝 Data transmission method and wireless terminal
JP2014194815A (en) * 2008-02-22 2014-10-09 Hiroaki Deguchi Text edition system, text edition method and text edition program
JP2012502337A (en) * 2008-09-08 2012-01-26 トムソン ライセンシング Element encoding method and apparatus
CN110765123A (en) * 2018-07-09 2020-02-07 株式会社日立制作所 Material data storage method, device and system based on tree structure

Similar Documents

Publication Publication Date Title
JP2008090500A (en) Data structure conversion system, program, and data structure
US20070130176A1 (en) Document processing method, recording medium, and document processing system
CN108196880A (en) Software project knowledge mapping method for automatically constructing and system
CN109740159B (en) Processing method and device for named entity recognition
JP2002099561A (en) Method and system for data conversion, and storage medium
CN106095824A (en) A kind of JSON format text imports the method for data base
US20010014899A1 (en) Structural documentation system
CN109684438B (en) Method for retrieving data with parent-child hierarchical structure
JP2006350729A (en) Application software construction method, application software construction processing program, and application software construction system
JP2005148970A (en) Method for converting data
US7900136B2 (en) Structured document processing apparatus and structured document processing method, and program
JP2016143200A (en) Encoding program, encoding method and encoder
KR20070099689A (en) Database management apparatus and method of managing database
JP2009069988A (en) Database processor, method and program
JP3724878B2 (en) Keyword extraction rule generation method
JP3632643B2 (en) Structured document management device
KR20120135782A (en) Method for transferring meta-data and apparatus thereof
JP2012059212A (en) Extraction apparatus, extraction method and extraction program
JP4519081B2 (en) Document conversion apparatus and program
JP2013218627A (en) Method and device for extracting information from structured document and program
CN111401005B (en) Text conversion method and device and readable storage medium
US20100218088A1 (en) Structured document converting device
JP3709890B2 (en) String search device
JP6589317B2 (en) Rewriting device, processing method and program thereof, and information processing device
CN112232032B (en) Automatic conversion method for content style of docx document