IBM®
跳转到主要内容
    中国 [选择]    使用条款
 
 
Select a scope: Search for:    
    首页    产品    服务与解决方案     支持与下载    个性化服务    
跳转到主要内容

developerWorks 中国  >  XML  >

Thinking XML: Basic XML and RDF techniques for knowledge management

Part 2: Combining files into an RDF model, and basic RDF querying

developerWorks

返回原文..


Listing 7: Query using regular expressions
 from Ft.Rdf import Util
from Ft.Rdf.Model import REGEX
#Returns an RDF model object, and the database instance it uses for
#persistence (in our case, it's just a memory data structure)
model, db = Util.DeserializeFromUri('issues.rdf')
db.begin()
USER_ID_BASE = 'http://users.rdfinference.org/ril/issue-tracker#'
IT_SCHEMA_BASE = 'http://xmlns.rdfinference.org/ril/issue-tracker#'
print 'Actions assigned to uogbuji:'
#Get all actions with "vote" in the body
actions = Util.GetSubjects(model, IT_SCHEMA_BASE+'body', ".*vote.*",
                           objectFlags=REGEX)
for action in actions:
    #See if this action is assigned to uogbuji
    assignee = Util.GetObject(model, action, IT_SCHEMA_BASE+'assign-to')
    body = Util.GetObject(model, action, IT_SCHEMA_BASE+'body')
    if assignee == USER_ID_BASE+'uogbuji':
        print "*", body
db.commit()
	   

返回原文.

    关于 IBM 隐私条约 联系 IBM 使用条款