使用Oracle时的一些限制

Q:As far as I know, in Oracle8 there was a limit of 64k allowed,in Oracle10 there is no limit at all ?
A:
Even in Oracle8, 64k was not the limit.
The limit is and was "by operating environment". SQLPlus might have a limit, Pro*C might have a limit. VB might impose it's own limit, JDBC might.
The API's are that which would impose a limit, well, besides "practicality" of course.
In plsql for example, execute immediate is limited to 32k because PLSQL itself is limited to 32k in a varchar variable. However, you can use dbms_sql to parse an ARRAY that can be huge -- megabytes in size.

in(n,....),其中list的最大列表数是1000,否则报ORA-01795 ;
解决大于1000的简单方法是把list的列表的数据insert into临时表,然后关联查询,如:
select ... from tableA a,tempTable t where a.id=t.id;

Reference:Ask Tom "maximum length of sql statement", version 10

Posted in Oracle | Tagged | Leave a comment

英语中对女人的10种叫法,可别用错了哟

转一篇网络文章:来源:英语中对女人的10种叫法
英语中对女性的称呼可谓丰富,且谐趣十足。这些称呼多用于口语,表现出称呼者对被称呼者的态度、情感以及彼此之间的微妙或显而易见的关系。

  1、old hen 老婆子

  俗语,男性用语,专用于中年以上的女性。除开玩笑的场合外,女性不太欢迎这一称谓。因为“oldhen”的字面意思是“老母鸡”。这一表达的来源是:从男人们的眼光来看,母鸡来回乱跑,凑在一起唧唧喳喳,或者互相对啄。Three oldhens from the neighbored were standing on the cornergossiping。有三个邻居老婆子站在街角上说长道短。说到hen还要提到与hen相关的表达:hen-pecked怕老婆的,本义是 “被母鸡啄的”。意思是“象软弱的公鸡经常被强壮的母鸡啄伤。男子慑于女性的淫威,表现得服服帖帖”。这个表达出自1690年德莱顿的喜剧《安菲特律翁》和1712发行的杂志《旁观者》。理解了上面的意思,那么hen party就不难理解为“女人的聚会”。后引申为凡是只有女人参加的社交性聚会都叫henparty。与它相对的是stag party雄鹿会,只有男子参加的聚会。

  2、spring chicken 少女

  原意“童子鸡,不超过10个月的肉嫩的笋鸡”。这一表达来源已久:在古时候由于孵化技术上的原因,不到春天就很难得到这样的鸡,后转义为“少女”。 Mrs. Gray may not be a granny, but she's certainly no springchicken。格雷夫人也许还不算老太太,但是她的年纪肯定不小啦。有时可直接用chick表示“小女孩儿”。That chick's areal tiger. She scratched my face when I talkedback。那小娘儿们可真是个母老虎。当我还嘴时,她竟然抓破了我的脸。

  3、the little woman 老婆,太太

  请注意不要漏掉定冠词the。I promised the little woman to be home early tonight。我答应我老婆今天晚上早回家。偶尔也表示“你太太”。How's the littlewoman?你太太好吗?对太太的称呼还有Missus,带有戏谑的说法。I'm fine, but the missus has been alittle under the weatherrecently。我身体很好,但是我老婆最近有点不舒服。有时用于对方或第三方的妻子。Hello, Jim. How's the missusthese days?吉姆,你好。你太太最近好吗?对妻子的称呼另有one's betterhalf。这一表达是以基薄雾浓云愁永昼督教的男女结婚合成一体的教义为基础的。I promised to take my better half shopping this afternoon。我答应我妻子今天下午带她去买东西。

  4、one's ball and chain 老婆

  本义是“带有重铁球的脚镣”。过去犯人在户外劳动时,为防止他们逃跑而带上这种刑具。把丈夫象犯人似地束缚起来,转用于玩笑中指“老婆”。 Yes, I'm going to the party tonight, but I'll have to drag along myball and chain。是呀,我要参加今天的社交晚会,但是我必须带着我家的母老虎。lady of thehouse也指“老婆,屋里头的”。

  5、one's old lady 老娘,某人的母亲

  此处的old并不表示“老,年纪大”,与an old lady“老太太”不同。Her old lady is veryyoung。她老娘很年轻。这样的说法很自然。但有时可能有人不喜欢,所以使用时要注意场合。在谈到自己的母亲时,可以加定冠词,作the oldlady。The old lady has gone to bed。俺娘已经睡下了。那fat lady指的什么呢?先看例句:The operais not over until the fat lady sings。关键人物出面问题才会解决。原来fatlady是在歌剧中演压轴戏的女主角,俗称“大姐大”。说到one's old lady,顺便提及one's old man老爸,老头。Hisold man is thirty。他老豆30岁了。在指“家父”时,加定冠词,作the old man。I'll have to askthe old man。我得去问问我爸爸。

  6、doll 美人

  本义“洋娃娃”。在男性使用的场合仅指“美人”,并无头脑简单的意思。Get a load of that doll overthere. I wonder what her nameis。你瞧瞧那边的那位美人哟!不知道她叫什么名字。女性把doll翻版用作对男性的称呼,表示“有魅力的英俊男子”。Isn't thecaptain of the baseball team a doll?

  棒球队长不是一个英俊的青年吗?有时doll表示“可爱的姑娘”。My brother's new girl friend is a doll。我弟弟新近交的女朋友是个挺可爱的姑娘。

  7、skirt 青年女子

  这一表达来源于女性穿的裙子,与中国旧时用“裙钗”表女子是一样的构思。这一说法仅限于男子对女性的称呼,因为女性并不喜欢这一称呼。 There are a lot of good-looking skirts among the new freshmen thisyear。在今年新入学的大学一年级学生中,有很多好看的姑娘。

  8、clinging vine 会撒娇的女子;依赖男子的女人

  像绕在树上的爬藤一样总挎着男人胳膊的女人。Every time we invite Bill to dinner, he showsup with one of his clingingvines。我们每次请比尔吃饭的时候,他总是带着一位贴在身上撒娇的女人。这一习语多用于未婚的女性。在用于已婚女性时,意思是“不能独立,依赖男人生活的女人”。Why don't you do something by yourself for a change? When Imarried you I didn't realize you were such a clingingvine。你为什么不改变一下,依靠自己做点什么事情呢?当我跟你结婚时,我不知道你是这样一个没有独立能力的女人。

  9、a plain Jane 不起眼的女人

  这里的plain是“不惹人注目的,朴素的”,而Jane是一般女人名,plain与Jane合辙押韵。I wonder why ahandsome man like Jeff married such a plainJane。我很奇怪象杰夫这样出色的男子怎么与一个不怎么起眼的姑娘结婚。

  10、jailbait 祸水妞儿

  一般指11-15岁有姿色的少女。jail是“监狱”,bait是“诱饵”,押母韵,合起来就是“使人进监狱的诱饵”。认为美色诱发犯罪显然是想推脱干系,对女性极不公平。She's a beautiful girl—but beware, she'sjailbait。她是个漂亮姑娘,但是要当心,可是个祸水妞儿啊。

  大家在使用这些女性称呼时,一定要注意其中的褒贬含义,分清场合和彼此的身份,避免误会或引起尴尬。

选自:环球时报

Posted in English | Leave a comment

使用dbms_output时要记得先开启SERVEROUTPUT

今天运行一段简单的PL/SQL,调用dbms_output.put_line(i);时,没有任何的结果输出,请教了一下同事,原来是没有开启serveroutput。特此记录一下。

SET SERVEROUTPUT ON;

一篇比较好的介绍dbms_output的文章:oracle的dbms_output

Posted in Oracle | Leave a comment

使用solr的DataImportHandler组件从Oracle创建索引

刚接触solr,照着Quick Start进行了相关的配置,在处理many-to-many表达相关数据时,同样的配置在mysql和oracle上得到的结果不一样,oracle中始终都不能fetch和index many-to-many表中的数据,即使用solr-DIH example中的例子。此时的db-data-config配置如下:

<entity name="entity" dataSource="oracle" query="select * from entity">
<field column="ent_primkey" name="ent_primkey" />
<entity name="project"  dataSource="oracle"
query="select project_name from invivo_project p left join map_project_study mps on mps.project_id=p.project_id left join entity e on e.ent_primkey=mps.study_id and  e.type='study' where e.id='${entity.id}' and mps.study_id='${entity.ent_primkey}'">
<field name="project" column="project_name" />
</entity>
</entity>

为了找出问题发生的原因,在本地debug了一下DIH的相关代码,原来自己忽略了一个事实:Oracle默认会把所有字段都变成大写,而DIH中并没有ignore大小写,同时其也使用了column中定义的值作为key来存储从数据库中得到的值,而我的配置中传入的参数都是小写的,name和column名称也不一致(?),所以执行时根本就不会把真正的参数替换进去。进而得不到值(即使得到值了也不会添加到field中去),也不会被index。

找到原因后,把上面配置中红色的部分做如下修正:id->ID; ent_primkey ->ENT_PRIMKEY; project->project_name,同时修改schema中相应发field信息,在oracle下终于看到了project的信息了。

总之,做配置的时候根据使用数据库的不同,需要留意大小写以及field name等问题。

Posted in 搜索与推荐 | Leave a comment

预防腐佳节又重阳败局真能预防腐佳节又重阳败吗?

    据《联合早报网》9月8日讯,中国近日成立国家预防腐佳节又重阳败局。新上任的监瑞脑消金兽察部部长马馼前天被任命兼任国家预防腐佳节又重阳败局首任局帘卷西风长,监瑞脑消金兽察部副部长屈万祥兼任国家预防腐佳节又重阳败局副局帘卷西风长。
    国家预防腐佳节又重阳败局属于部级单位。除了国家预防腐佳节又重阳败局,各省市地方政府也将成立预防腐佳节又重阳败局。从监瑞脑消金兽察部部长兼任该局局帘卷西风长的规格看,各省市的预防腐佳节又重阳败机构可能也将
由当地的监瑞脑消金兽察部门领佳节又重阳导兼任。有关人士指出,国家预防腐佳节又重阳败局在名义上是国务院的直属单位,但事实上该局和监瑞脑消金兽察部门一样,由中玉枕纱厨纪委统一领佳节又重阳导。
    其职能主要有四方面:
    一是加强对干部的教育,使领佳节又重阳导干部增强廉洁自律的自觉性;
    二是加强制度建设,不断提高反东篱把酒黄昏后腐倡廉工作的制度化水平;
    三是加强对权力运行的制约和监督,包括对贯彻落实国家政策、法律法规情况进行监督;
    四是加强反东篱把酒黄昏后腐败国际合作,履行《联合国反东篱把酒黄昏后腐败公约》所规定的义务。
    
官方媒体认为,成立国家预防腐佳节又重阳败局是中国在反东篱把酒黄昏后腐败问题上的制度创新,是吸收和借鉴发达国家预防和惩处腐佳节又重阳败的先进经验。成立国家预防腐佳节又重阳败局影响的不仅仅是一个行业和领域,是中国反东篱把酒黄昏后腐败格局的大调整。
    北京有关学者对本报说,在官半夜凉初透场和社会存在大量腐佳节又重阳败现象的情势下,多一个反东篱把酒黄昏后腐机构肯定比少一个要好。但真要从源头上遏制腐佳节又重阳败,官方必须进行政治改革,让监瑞脑消金兽察机构真正能够对权力的来源、运行和用权结果施行有效监督。而在目前的政治体制下,要做到这一点几乎是不可能的。
    
真的希望预防腐佳节又重阳败局能想官媒宣传的那样执行其应有的职责,而不是一个摆设!
    新闻来源:中国成立国家预防腐佳节又重阳败局

Posted in 胡谈乱侃 | Tagged | Leave a comment

到了反思高等教育的时候了

高校可能面临新一波倒闭效应 台湾高教改革遭遇困境


● 吴佳蓓(台北)

  台湾高等教育改革迈向十年之路,当初广设大学以舒缓升学压力的主张,现今浮现教育资源稀释化衍生大学普遍贫困的严重现象,在汰劣存优的大学评鉴制度未见成效前,优势不足的高等教育学府可能面临新一波的倒闭效应。教改十年,台湾教育政策遭遇更严峻的难题待解。

大学窄门放宽 学生质量下降

 
 台湾的大学升学环境,在入学普及化的改革下,屡屡创下高录取率与低录取门槛的极度反比趋势,象征国家竞争力的大学生质量有逐年滑落的现象。根据教育部公
布的数据,教改施行前的1996年,大学录取率仅有49.24﹪,大学松绑后,今年考生录取率快速激增到96.3﹪,形成佳节又重阳人人有校可读的状况。

 
 今年8月刚公布的大学发榜资料显示,申请大学登记资格的9万7130名考生中,有8万6652人获录取,7128人放弃登记志愿。令人惊讶的是,今年大
学最低录取分数出现12.2的极低标准,意味考生在满分100分的六科科目中,只要获得两分平均成绩即可登记入学,大学窄门放宽反而导致竞争力下降危机,
成为台湾高等教育最为棘手的问题。

  教改冲破大学高度窄化的限制,而沉苛的升学主义,是过去高中生长期以来的共同记忆,以往在“学历等同
未来”的社会价值观底下,“大考定终生”成为大学考生必然面临的极度压力,而教育僵化导致学习无法随着兴趣发展的负面影响逐渐形成反省力量,致使教育部在
1995年制定“多元教育”的变革基调,并由前中央研究院院长李半夜凉初透薄雾浓云愁永昼哲担纲教改召集人,在两年的广邀众议后,提出“教育松绑、畅通升学、提升质量”等八大改
革方向,广设大学因而成为高等教育日后发展的重要依据。

  革新后的大学入学制度以多元入学为基础,以照顾有艺术学科性向学生的“推荐甄
试”、以及多数学生适用的“指定科目考试”两大管道分流进行,每年7月举行的指定科目考试,以国文、数学、英文、历史、地理、物理、化学、生物等五至六科
的基础学科成绩登记分发学校,各校拥有自订录取标准的权利,也成为自降水平以广招学生的可调整工具。

大学数量空前扩张

  大
学从精英制度转向高度普及化,致使大学数量获得空前的扩张趋势。根据教育部的资料统计,高等学府(大学、独立学院、专科学校)从1997年的139所,膨
胀到今年的163所,大学生也在10年间从80万人增加到112万人,导致大学密度过高。不少独立学院(college)、技职专科(junior
college)在师资不够完备及属性定位不清的情况下,成为政策仓促、审核不周下成功改制大学的受惠对象,加上社会始终存有报读名校的潮流迷思,纵使获
得升格大学的核定,改制后的大学却未普遍获得学生、家长的实质认同。此外,少子化的现象早已冲击办学绩效,迫使招生原本困窘的大学一再降低录取门槛,衍生
成为近年来录取分数屡创新低的现象。

除了招生不易的经营困境,教改也直接触动高等教育结构性问题的连锁反应。

 
 台湾高教经费历年虽然持续增长,却赶不上大学生增加的步伐。三年前,教育部特别编列五年500亿 (新台币,约23.13亿新元)
预算以提高大学教育的竞争力,却只能给予当时全国159所大学中仅仅12所的补助名额。在僧多粥少的情况下,私立学校成为高教系统下的牺牲者。教育资源稀
释带来经费匮乏的难题,无法摆脱二流学府的私立学校不得藉由提高学费、降低退学率、控制研究资源来维持系统的运作,教育人士陆续预警私校即将到来的倒闭效
应。

  广设大学问题丛生,立法院去年修法,增订大学整并、关闭的退场机制,并建立定期评鉴教育资源,不合格者面临停止招生的命运。但即使评鉴上路,绩效不彰的学府仍然存在。

  提出教改建议的李半夜凉初透薄雾浓云愁永昼哲近日疾呼大学录取率高不是问题,“问题在于大学没有好好的分级”,不同的人到不同的大学就读,学到适合的东西才是重点。

  高教改革走到10年总体检的关键时刻,该走回高门槛的老路,还是继续坚持“尊重差异、适才适所”的理想?全面反省与改革魄力,刻不容缓。

来源:联合早报 2007年8月21日 早报中国

    反观对岸的中国高等教育,又何尝没有面临破产的边缘呢?大学是容易上了,可大部分人都要面临毕业即失业的困境。据教育部统计,今年可能会有100万毕业生待业,加上前几天累积的,实际数量之大,真的不知道会有多少,反思高教改革已是摆在我们眼前迫不及待的事了!不管是政府还是民间,高教何去何从,是关系到国家民族命运的大是大非问题,稍有不慎就可能成为历史的罪人!

Posted in 未分类 | Tagged , | 2 Comments

台湾IT产业竞争力全球第6

    (中时电子报报道)英国经济学人信息部(EIU)昨日公布全球首度的IT(资讯科技)产业竞争力指数大调查,台湾凭藉“研发环境”指标全球第三的优
越表现,带领台湾整体IT产业竞争力抢下全球第六名,第一名是美国,第二名日本,第三名南韩;台湾在“IT劳动生产力”这项高居全球第一。

  这个全球首度针对IT产业环境竞争力的调查,和洛桑管理学院等其他竞争力报告调查最大的不同是,侧重IT产业的制造能力,包含IT硬体、软体和服务的部分,而不是科技的运用能力。

  美、日、南韩 分居前3名

  报告由商业软体联盟(BSA)赞助,总共评比64个国家,采数字比较和问卷结果并计方式,针对6大类25个指标做调查,台湾表现最好的
是“研发环境”,全球第3名,其他大类排名分别为:整体商业环境第11;IT基础建设第18、人力资本第7、法律环境第32,和政府角色的支援第19。

  商业软体联盟亚洲区政策总监吴少雄表示,期许台湾在法律环境层面能够再加强,未来可望超越日韩,在六大类评估指标中,台湾在五类指标有不错的基础,但仍有进步空间。

  调查指出,在“劳动生产力”这个细项指标,台湾排名全球第1,南韩第2,日本第8,中国第10。

  研究环境好 法律环境最差

  吴少雄分析,调查侧重IT产业环境竞争力,中国这个全球的制造工厂在“劳动生产力”中排名第10,表示生产力相当高,但却排不上总排名
的前22名,因为总排名强调的是IT产业整体竞争力,中国虽然成本很低,但这种优势很快地会被越南、印度等成本更低的国家所超越,所以台湾必须加强必要的
能力。

  吴少雄表示,在“研究发展环境”上,台湾得分54.8,排名全球第3,高出第4名的美国、第5名的瑞典15分之多,更远高于邻近的香
港与新加坡,表现相当好,台湾产官成功的合作使得研究发展表现突出,如政府所支援的新竹工业技术研究院是最广为人知的一个例子,包括台积电、联电,工研院
已培养出若干大有名气的公司。

  台湾在经济学人信息部的整体调查中,表现最差的是“法律环境”,吴少雄指出,台湾在2002年加入世界贸易组织后已获改善,在智慧财
产权保护与侵权执法上也付出许多努力,让台湾由美国301条款的优先观察名单降至一般观察名单中,然而本项评比中台湾得分70、排名全球第32,显示出台
湾进步的空间仍相当大。
    来源:《联合早报》8月8日 世界报刊文萃
   
原文:台湾IT产业竞争力全球第6

Posted in 未分类 | Tagged , | Leave a comment

北京, Are you ready?

    北京奥运倒计时一周年主题歌,取名叫《We are
ready》(我们准备好了),这首歌由香港名音乐人金培达和陈少琪联手打造,中国大陆、香港、台湾以及海外133名华裔名歌星(李宇春、陈奕迅、谭咏
麟、萧亚轩、李汶等)共同参与演唱。据说,这大动员式的歌曲,经过了100多个小时的录音和拍摄工作方大功告成。
    据悉,8月8日当晚,百余位歌手将在天莫道不消魂安门广场放歌《我们准备好了》,共同为北京奥运加油喝彩,宣示北京成功主办一届奥运的信心和承诺。
    在距离奥运约367天的时候,北京奥瑞脑消金兽组委昨天对外一一点算奥运筹备成绩,宣布37个比赛场馆、56个训练场馆都将如期在今年底明年初竣工。北京机场扩建计划、地铁机场线、奥运支线、5号线、10号线,以及场馆周边的道路桥梁等各项工程,最迟的明年7月也会完工。
    为了确保北京能以文明风范迎接五湖四海来的朋友,当局主办的“迎奥运、讲文明、树新风”宣传活动,据说也“取得了很大的成果”,至今对87万名窗口行业的员工进行了教育培训,并大力宣传赛场文明,教育亢奋的中国观众在本国运动员败北时,人人做个有礼貌的输家。
    然而,这些美丽的成绩,也没有让中国在人薄雾浓云愁永昼权问题、和 ** 上的敏感度有丝毫减少。随着奥运接近,有关中国民瑞脑消金兽主进程、开放程度、人薄雾浓云愁永昼权的批评声恐怕将更
集中,对于这些情况该如何应对,北京似乎还没有ready。从昨天早上CNN的奥运特辑因提起中国人薄雾浓云愁永昼权和 ** 被当局公然审查,就暴露出这一点。
    奥运被政治化几乎是无可避免的,把电视画面直接掐断的做法,只能应证外界对于这个政权不民瑞脑消金兽主的批评。很多人说,汉城奥运推动韩国走上民瑞脑消金兽主政治的道路;昨天,中国却把不开放和不尊重新闻自由的凭证,在关键时刻奉送给自己的批评者。
    说实话,我不常看CNN。昨天会停留在这一频道,是被其奥运专题所吸引。当电视画面突然变黑的那一刻,我也油然感觉到尴尬,甚至不值。
    We are ready所代表的那种亢奋信心,在两次电视画面变黑的瞬间,好像也受影响而暗淡了起来。
    (摘自《联合早报》2007-08-07 早报中国
     北京, Are you ready?

Posted in 胡谈乱侃 | Tagged , | 2 Comments

Turtle-Terse RDF Triple Language语法学习

Turtle, the Terse RDF Triple Language, is an extension of N-Triplescarefully taking the most useful and appropriate things added from Notation 3 while keeping it in the RDF model.

















































































































































































































Turtle - Terse RDF Triple Language EBNF
[1] turtleDoc ::= statement*
[2] statement ::= directive ws* '.' ws* | triples ws* '.' ws* | ws+
[3] directive ::= '@prefix' ws+ prefixName? ':' ws+ uriref
[4] triples ::= subject ws+ predicateObjectList
Provides RDF triples using the given subject and each pair from the predicateObjectList
[5] predicateObjectList ::= verb ws+ objectList ( ws* ';' ws* verb ws+ objectList )* (ws* ';')?
Provides a sequence of (verb, object) pairs for each object from the objectList
[6] objectList ::= object (ws* ',' ws* object)*
Provides a sequence of objects
[7] verb ::= predicate | 'a'
where 'a' is equivalent to the uriref
[8] comment ::= '#' ( [^#xA#xD] )*
[9] subject ::= resource | blank
[10] predicate ::= resource
[11] object ::= resource | blank | literal
[12] literal ::= quotedString ( '@' language )? | datatypeString | integer | double | decimal | boolean
[13] datatypeString ::= quotedString '^^' resource
[14] integer ::= ('-' | '+') ? [0-9]+
Interpreted as an xsd:integer and generates a datatyped literal with the datatype uriref http://www.w3.org/2001/XMLSchema#integer and canonical lexical representation of xsd:integer which includes allowing no leading zeros.
[15] double ::= ('-' | '+') ? ( [0-9]+ '.' [0-9]* exponent | '.' ([0-9])+ exponent | ([0-9])+ exponent )
Interpreted as an xsd:double and generates a datatyped literal with the datatype uriref http://www.w3.org/2001/XMLSchema#double and any legal lexical representation of xsd:double.
[16] decimal ::= ('-' | '+')? ( [0-9]+ '.' [0-9]* | '.' ([0-9])+ | ([0-9])+ )
Interpreted as an xsd:decimal and generates a datatyped literal with the datatype uriref http://www.w3.org/2001/XMLSchema#decimal and any legal lexical representation of xsd:decimal.
[17] exponent ::= [eE] ('-' | '+')? [0-9]+
[18] boolean ::= 'true' | 'false'
Interpreted as an xsd:boolean and generates a datatyped literal with the datatype uriref http://www.w3.org/2001/XMLSchema#boolean and canonical lexical representation of xsd:boolean.
[19] blank ::= nodeID | '[]' | '[' ws* predicateObjectList ws* ']' | collection
Provides a blank node either from the given nodeID, a generated one, a generated one which is also used to provide the subject of RDF triples for each pair from the predicateObjectList or the root of the collection.
[20] itemList ::= object (ws+ object)*
Provides a sequence of objects (Note there are no commas between items unlike objectList)
[21] collection ::= '(' ws* itemList? ws* ')'
Provides a blank node at the start of an RDF collection of the objects in the itemList. See section Collections for the triples generated.
[22] ws ::= #x9 | #xA | #xD | #x20 | comment
[23] resource ::= uriref | qname
[24] nodeID ::= '_:' name
[25] qname ::= prefixName? ':' name?
See section QNames
[26] uriref ::= '<' relativeURI '>'
[27] language ::= [a-z]+ ('-' [a-z0-9]+ )*
encoding a language tag.
[28] nameStartChar ::= [A-Z] | "_" | [a-z] | [#x00C0-#x00D6] | [#x00D8-#x00F6] | [#x00F8-#x02FF] | [#x0370-#x037D] | [#x037F-#x1FFF] | [#x200C-#x200D] | [#x2070-#x218F] | [#x2C00-#x2FEF] | [#x3001-#xD7FF] | [#xF900-#xFDCF] | [#xFDF0-#xFFFD] | [#x10000-#xEFFFF]
[29] nameChar ::= nameStartChar | '-' | [0-9] | #x00B7 | [#x0300-#x036F] | [#x203F-#x2040]
[30] name ::= nameStartChar nameChar*
[31] prefixName ::= ( nameStartChar - '_' ) nameChar*
[32] relativeURI ::= ucharacter*
Used as a relative URI and resolved against the current base URI to give an absolute URI reference.
[33] quotedString ::= string | longString
[34] string ::= #x22 scharacter* #x22
[35] longString ::= #x22 #x22 #x22 lcharacter* #x22 #x22 #x22
[36] character ::= 'u' hex hex hex hex |
'U' hex hex hex hex hex hex hex hex |
'\' |
[#x20-#x5B] | [#x5D-#x10FFFF]
See String Escapes for full details.
[37] echaracter ::= character | 't' | 'n' | 'r'
See String Escapes for full details.
[38] hex ::= [#x30-#x39] | [#x41-#x46]
hexadecimal digit (0-9, uppercase A-F)
[39] ucharacter ::= ( character - #x3E ) | '>'
[40] scharacter ::= ( echaracter - #x22 ) | '"'
[41] lcharacter ::= echaracter | '"' | #x9 | #xA | #xD



The following table describes all the escapes allowed inside a string, longString or relativeURI:






























Escape Unicode code point
'u' hex hex hex hex A Unicode codepoint in the range U+0 to U+FFFF inclusive corresponding to the encoded hexadecimal value.
'U' hex hex hex hex hex hex hex hex A Unicode codepoint in the range U+10000 to U+10FFFF inclusive corresponding to the encoded hexadecimal value.
't' U+0009
'n' U+000A
'r' U+000D
'"'
(inside string and longString)
U+0022
'>'
(inside relativeURI only)
U+003E
'\' U+005C



Collections


The triples that are generated is given by these expansions to the longer form:


( object1 object2 ) is short for:
[ rdf:first object1; rdf:rest [ rdf:first object2; rdf:rest rdf:nil ] ]


( ) is short for the resource:rdf:nil


Examples


This example is a Turtle translation of example 7 in the RDF/XML Syntax specification (example1.ttl):

@prefix rdf:  .
@prefix dc: .
@prefix ex: .


dc:title "RDF/XML Syntax Specification (Revised)" ;
ex:editor [
ex:fullname "Dave Beckett";
ex:homePage
] .

An example of an RDF collection of two literals.

@prefix :  .
:a :b ( "apple" "banana" ) .

which is short for (example2.ttl):

@prefix :  .
@prefix rdf: .
:a :b
[ rdf:first "apple";
rdf:rest [ rdf:first "banana";
rdf:rest rdf:nil ]
] .

An example of two identical triples containing literal objects containing newlines, written in plain and long literal forms. Assumes that line feeds in this document are #xA. (example3.ttl):

@prefix :  .

:a :b "The first linenThe second linen more" .

:a :b """The first line
The second line more""" .

X. Identifers for the Turtle Language

The XML (Namespace name, Local name) pair that identifies the Turtle language is:

Namespace: http://www.dajobe.org/2004/01/turtle#
<!--
Namespace: http://www.w3.org/2006/12/turtle#
-->Local name: turtle
The suggested namespace prefix is ttl (informative) which would make this ttl:turtle as an XML QName.


来源:http://www.dajobe.org/2004/01/turtle/#sec-grammar


Posted in 读书笔记 | Tagged | Leave a comment

Notation 3学习

This is a language which is a compact and readable alternative to
RDF's XML syntax, but also is extended to allow greater expressiveness. It has
subsets, one of which is RDF 1.0 equivalent, and one of which is RDF plus a
form of RDF rules.

目标

The aims of the
language are

  • to optimize expression of data and logic in the same
    language,
  • to allow RDF
    to be expressed,
  • to allow rules
    to be integrated smoothly with RDF,
  • to allow
    quoting so that statements about statements can be made, and
  • to be as readable, natural, and symmetrical as
    possible.

功能

The language
achieves these with the following features:

  • URI abbreviation using prefixes which are bound to a
    namespace (using @prefix) a bit like in XML,
  • Repetition of
    another object for the same subject and predicate using a comma
    ","
  • Repetition of
    another predicate for the same subject using a semicolon ";"
  • Bnode syntax
    with a certain properties just put the properties between [ and ]
  • Formulae
    allowing N3 graphs to be quoted within N3 graphs using { and }
  • Variables and
    quantification to allow rules, etc to be expressed
  • A simple and consistent grammar.

语法

语法以上下文无关文法的方式来定义:

N3

RDF/XML

HTML

yacc

N3文件以UTF-8为默认的编码方式,MIME类型为text/rdf+n3;charset=utf-8

语法表示

Whitespace

为了简单化,单词(Token)和空白(white space)并没有在语法中明确地指定其应遵循的规则。空白必须在后续单词以一个能延伸前述单词的字符开始的时候,而不能插入到一个单词的内部,除非在以尖括号(<>)分隔的URI内部可以自由地添加和移除空白。

All URIs are quoted with angle brackets. Whitespace within the
<> is to be ignored. Whitespace may therefore be used on output to split
a long URI between lines.

Namespaces

@prefix标志将前缀和名称空间URI绑定在一起。

@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
.

名称空间前缀可以为空,此时,qname(限定名称)以:开头,表示使用的是默认的名称空间。空前缀””默认表示空URI ””,意味着<#foo>等价于:foo,也可通过使用@keywords简写为foo

@keywords

Keywords are a very limited set
of alphanumeric strings which are in the grammar prefixed by an at sign
"@".

If no @keywords directive is
given, qualified names all have colons, and unquoted alphanumerics are all
keywords. Only the keywords is, of, and a may be used naked.

If the @keywords directive is
given, the keywords given will thereafter be recognized without a "@"
prefix, and anything else is a local name in the default namespace. Any keyword
may still be given, even if not in the keyword list, by prefixing it with
"@". Because keywords are declared in this way, we will have the
freedom later to make extensions to the syntax using new keywords without fear
of ambiguity. However, the tokenizer has to be aware of the @keywords setting.
The grammar is written as without reference to the keywords system at all, on
the asssumption that the string has been preprocessed by a keyword processor to
put a "@" on all keywords and a ":" on all qnames in the
default namespace.

Strings

The """value""" string form is used
simply for multi-line values or values containg quote marks.

Escape Sequence 

Meaning 

newline

Ignored

\

Backslash ()

'

Single quote (')

"

Double quote (")

n

ASCII Linefeed (LF)

r

ASCII Carriage Return (CR)

t

ASCII Horizontal Tab (TAB)

uhhhh

character in BMP with Unicode value U+hhhh

U00hhhhhh

character in plane 1-16 with Unicode
value U+hhhhhh

N3中,””用于表示字符串,’’被保留到将来用,因而N3串中也不需被转义。

Semantics

An N3 document encodes a set of statements, and its meaning is the
conjunction of the meaning of the statements.

The statement of the form x p y. asserts that the
relation p holds between x and y.

In property lists, the semicolon ;
is shorthand for repeating the subject. In object lists , is shorthand for
repeating the verb.

Shorthand for common predicates

Shorthand stands for
a <http://www.w3.org/1999/02/22-rdf-syntax-ns#type>
= <http://www.w3.org/2002/07/owl#sameAs>
=> <http://www.w3.org/2000/10/swap/log#implies>

Blank nodes

There are several ways in N3 of
representing a blank or unnamed node: the underscore namespace, the square
bracket syntax, and the path syntax.

Underscore namespace

N3 allows has a special _:
namespace prefix. An identifier of such a form (e.g.
_:a17) represents a blank node.

Square bracket blank node syntax

[pl] means x, where there exists some x such that x has
properties in the property list
pl.

[:firstname
"Ora"] dc:wrote [ dc:title "Moby Dick"] .

用数学术语表示为:x, y . firstname(x, "Ora")&dc:wrote(x,y)&dc:title (y,
"Moby Dick")
或者用英语表示为Some person who has a first name
Ora wrote a book entitled "Moby Dick".

上述写法可等价于:[x:firstname "Ora" ; dc:wrote
[dc:title "Moby Dick" ]] .

[] x:firstname "Ora" ;
dc:wrote [dc:title "Moby Dick" ].
其中[]表示“有些”。

Paths

The x!p
means [ is p
of x ] in the
above anonymous node notation. You can read it as "x's p".

The
x
^p
means [ p x ] . For either forward
or backward traversal, p
is a property, and x
can be a whole path with both ! and ^ in it.

:joe!fam:mother!loc :o ffice!loc:zip
表示Joe's mother's office's zipcode

:joe!fam:mother^fam:mother
表示Anyone whose mother is Joe's mother.

Formulae

An RDF document
parses to a set of statements, or graph. However RDF itself has no data type
allowing a graph as a literal value. N3 extends RDF allows a graph itself to be
referred to within the language, where it is known as a formula. A {statement
list} is a formula whose meaning is the logical conjunction of the statements
in the list which is an unordered set.

{ [
x:firstname  "Ora" ] dc:wrote [
dc:title  "Moby Dick" ] } a
n3:falsehood .

This claims that
the expression in {braces} is false - that there is nothing called Ora which
wrote anything titled "Moby Dick".

A formula is
considered, like a literal string, to be defined only by its contents.

Quantification

@forAll全称量词

@forSome:存在量词

         @forAll
<#h>. @forSome <#g>. <#g> <#loves> <#h> .
表示"Every has someone who loves them" e.g.h(g(loves(g,h))

Boolean literals

The words true and false
are boolean literals.

 

 

 

来源:http://www.w3.org/DesignIssues/Notation3

Posted in 读书笔记 | Tagged , | 1 Comment