Team:USTC Software/notebook

From 2010.igem.org

(Difference between revisions)
(Monthly NoteBook)
 
(78 intermediate revisions not shown)
Line 1: Line 1:
-
== BERKERLY DB XML 介绍 by LIAO CHEN ==
+
{{Team:USTC_Software/Header}}
 +
<html>
 +
<style type="text/css">
 +
table.calendar          { margin: 0; padding: 10px; }
 +
table.calendar td      { margin: 0; padding: 2px; vertical-align: top; }
 +
table.month .heading td { padding:2px; background-color:#66b3ff; color:#ffffff;
 +
text-align:center; font-size:120%; font-weight:bold; }
 +
table.month .dow td    { color:#000000; text-align:center; font-size:110%; }
 +
table.month td.today    { background-color:#66b3ff; }
 +
table.month td {
 +
border: none;
 +
margin: 0;
 +
padding: 1pt 1.5pt;
 +
font-weight: bold;
 +
font-size: 100%;
 +
text-align: right;
 +
background-color: white;
 +
}
 +
#bodyContent table.month a {
 +
background:none; padding:0 }
 +
.day-active { color:#0000aa }
 +
.day-empty  { color:#aaa }
 +
</style>
 +
</html>
 +
==Monthly Notebook==
 +
{| style="background-color:white; " align="center" border="1"
 +
|-valign="top"
 +
|width=200px; align="center" |[https://2010.igem.org/Team:USTC_Software/notebook_3 March]
 +
|width=200px; align="center" |[https://2010.igem.org/Team:USTC_Software/notebook_4 April]
 +
|width=200px; align="center" |[https://2010.igem.org/Team:USTC_Software/notebook_5 May]
 +
|width=200px; align="center" |[https://2010.igem.org/Team:USTC_Software/notebook_6 June]
 +
|-valign="top"
 +
|width=200px; align="center" |[https://2010.igem.org/Team:USTC_Software/notebook_7 July]
 +
|width=200px; align="center" |[https://2010.igem.org/Team:USTC_Software/notebook_8 August]
 +
|width=200px; align="center" |[https://2010.igem.org/Team:USTC_Software/notebook_9 September]
 +
|width=200px; align="center" |[https://2010.igem.org/Team:USTC_Software/notebook_10 October]
 +
|}
-
 
+
==Daily Notebook==
-
== 新手入门1 基本操作==
+
{| style="background-color:#ffffff;" align="center" border="1""
-
 
+
|-valign="top"
-
http://www.oracle.com/technology/global/cn/products/berkeley-db/xml/index.html 下载BDB (Berkerly DB XML 2.5),可以很好支持XML文件的查找与插入,删除,索引操作,既支持命令行也支持应用程序的调用。
+
|{{ #calendar: query=preload=Team:USTC_SOFTWARE/Template/Meetings
-
 
+
|title=Team:USTC_SOFTWARE/Notebook/Meetings |year=2010 |month=03 }}
-
在BDB中,所有的文件存在container中,这些container实际上是XML文档和其他信息的集合,它即可作为整个文档(一个单元)存储,又可作为许多结点存储--这时整个文档分解为一个一个小的结点。
+
|{{ #calendar: query=preload=Team:USTC_SOFTWARE/Template/Meetings
-
 
+
|title=Team:USTC_SOFTWARE/Notebook/Meetings |year=2010 |month=04 }}
-
这个软件的安装比较诡异,在install/bin/里面有dbxml的命令,直接输入(我是运行完外面的build.sh后才运行的,安装时间暴长...)。这时出现prompt。注意:每一个xml文档都存在container中,container是xml文档的集合,它还包括索引,metadata(data about data)。我们首先要创建一个container对象:
+
|{{ #calendar: query=preload=Team:USTC_SOFTWARE/Template/Meetings
-
 
+
|title=Team:USTC_SOFTWARE/Notebook/Meetings |year=2010 |month=05 }}
-
dbxml> createContainer <CONTAINER NAME>
+
|{{ #calendar: query=preload=Team:USTC_SOFTWARE/Template/Meetings
-
 
+
|title=Team:USTC_SOFTWARE/Notebook/Meetings |year=2010 |month=06 }}
-
这里不像mysql需要打开数据库(use <database name>),DBD会自动为我们打开。DBD管理文档的格式不是组织关系数据库,无须像mysql一样要定义每一个表的格式,比如create table phonebook values (id INT(3) not null, varchar(120)...),它直接输入xml格式的文件即可:
+
|-valign="top"
-
 
+
|{{ #calendar: query=preload=Team:USTC_SOFTWARE/Template/Meetings
-
dbxml> putDocument phone1 '<phonebook>
+
|title=Team:USTC_SOFTWARE/Notebook/Meetings |year=2010 |month=07 }}
-
<name>
+
|{{ #calendar: query=preload=Team:USTC_SOFTWARE/Template/Meetings
-
<first> liao </first>
+
|title=Team:USTC_SOFTWARE/Notebook/Meetings |year=2010 |month=08 }}
-
<second> chen </second>
+
|{{ #calendar: query=preload=Team:USTC_SOFTWARE/Template/Meetings
-
</name>
+
|title=Team:USTC_SOFTWARE/Notebook/Meetings |year=2010 |month=09 }}
-
<phone type="mobile">xxxxx5873</phone>
+
|{{ #calendar: query=preload=Team:USTC_SOFTWARE/Template/Meetings
-
</phonebook>' s
+
|title=Team:USTC_SOFTWARE/Notebook/Meetings |year=2010 |month=10 }}
-
 
+
|}
-
这里要注意三点,第一是这种格式的输入(当然可以load文件)的xml文档是以单引号为起始终止限定符,第二是s结尾是说xml以string格式输入新的document,第三是它和mysql不一样,不用打分号作为一个语句的结束。
+
-
 
+
-
下面我门说XQuery,我们可以理解它和SQL SELECT语句是差不多的。XPATH是XQuery的中心实现,它就是一系列语句,用于查询XML文档数据集合的子集。它和SQL查询有些类似,比如我们要查<CONTAINER NAME>这个collection中的/phonebook/name/first这个结点的所有的记录,我们输入
+
-
 
+
-
dbxml> query 'collection("<CONTAINER NAME>")/phonebook/name/first/string()'(给出找到了几个拥有这个first的记录)
+
-
dbxml> print (会打印出找到的结点的VALUE)
+
-
 
+
-
这条语句将找到的记录的/phonebook/name/first的结点的值以STRING形式显示。理解XPATH语句是必备的。query的表达式分为两个部分,第一个是导航函数collection(),用它定位文件,后面是搜索的表达式,它遵循XPATH语法格式。collection支持多个文件搜索(collection("CONTAINER1") | collection( "CONTAINER2")),中间用管道符连接。
+
-
 
+
-
如果输入query 'collection("<CONTAINER NAME>")/phonebook[name/first="liao"]/phone[@type=“mobile"]/string()'就是查询在phonebook的字节点下的name/first结点值为liao的那些记录(这是条件查询,用[])的phone字节点的属性(@表示属性)为mobile的值有多少。
+
-
 
+
-
Query的条件搜索expression格式很多,我在下面会列出最重要的一些命令,其他的命令看dbxml> help. 对于每一条命令,可以查询其细节,help <COMMAND>.
+
-
 
+
-
 
+
-
== 新手入门2 Xpath的使用 ==
+
-
Xpath是XML PATH LANGUAGE的简写。
+
-
 
+
-
首先我发现DBD支持用脚本语言批量生成XML文件
+
-
 
+
-
putDocument "" '
+
-
for $i in (0 to 1000)
+
-
return
+
-
<part number="{$i}">
+
-
<description>Description of {$i}</description>
+
-
<category>{$i mod 10}</category>
+
-
{
+
-
if (($i mod 10) = 0)
+
-
then <parent-part>{$i mod 3}</parent-part>
+
-
else ""
+
-
}
+
-
</part>' q
+
-
 
+
-
它还支持shell的运算,比如可以在其中插入{$i mod 3}的运算。还有if...else...end语句块。格式是
+
-
 
+
-
if (CONDITION)
+
-
then (类似于<lable attribute="">value</lable>这样的东西就会加入一个XMLnode)
+
-
else
+
-
 
+
-
比如说我想搜索这1000条记录中有parent-part这个属性的记录(这一句是包含在if-else块中,不是每个都有的),我可以输入
+
-
 
+
-
query '
+
-
collection("parts.dbxml")/part[parent-part]'
+
-
 
+
-
这里首先测试[parent-part]是否为真,然后返回记录,注意这时返回的是以part这个结点为根结点的树形结构。如果将/part[parent-part]改为/part/parent-part呢?大家可以print一下就知道差别了。因为这里返回的是以parent-part为根结点的树。
+
-
 
+
-
 
+
-
 
+
-
 
+
-
比较两个句子的差别。
+

Latest revision as of 20:58, 25 October 2010

Monthly Notebook

March April May June
July August September October

Daily Notebook

March
MTWTFSS
1 2 3 4 5 6 7
8 9 10 11 12 13 14
15 16 17 18 19 20 21
22 23 24 25 26 27 28
29 30 31
April
MTWTFSS
      1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30
May
MTWTFSS
          1 2
3 4 5 6 7 8 9
10 11 12 13 14 15 16
17 18 19 20 21 22 23
24 25 26 27 28 29 30
31
June
MTWTFSS
  1 2 3 4 5 6
7 8 9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28 29 30
July
MTWTFSS
      1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30 31
August
MTWTFSS
            1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31
September
MTWTFSS
    1 2 3 4 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29 30
October
MTWTFSS
        1 2 3
4 5 6 7 8 9 10
11 12 13 14 15 16 17
18 19 20 21 22 23 24
25 26 27 28 29 30 31