指向性メモ::2007-02-07::AjaxとObject/RDFマッピングライブラリ

ページ情報
制作日
2007-02-07T14:13:20+09:00
最終更新日
2007-02-07T14:13:20+09:00
ページ内目次

RDFとJavaScriptのObjectをマップするライブラリを作り始めました。雰囲気としてはRailsのActiveRecordに似ています。JavaScriptのコードを書けば、自動的にSPARQLクエリ生成からリモートサーバへの問い合わせ、返事のパースにキャッシュまでを行ってくれます。

現在は本当に作りはじめのベータバージョンで、エラーハンドリングなどは全然していません。機能も最も単純なURIを基準としたデータの取得のみです。

<?xml version="1.0" encoding="utf-8" ?>
<rdf:RDF
    xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
    xmlns:dc="http://purl.org/dc/elements/1.1/"
    xmlns="http://xmlns.com/foaf/0.1/">
    <Person rdf:about="urn:for:me">
        <name>Yudai Ishikawa</name>
        <homepage rdf:resource="http://ishikawa.arielwokrs.com/" dc:title="The 3rd Development Section"/>
    </Person>
</rdf:RDF>

こんな感じのRDFのグラフがあれば、ライブラリのコードを読み込みさえすれば

// Create a instance of query engine with the uri of your remote SPARQL server.
qEngine = new Hercules("http://your/uri/to/sparql/server");

// Register prefixs to omit Namespace URIs. Use empty string for the default Namespace.
qEngine.addPrefix("", "http://xmlns.com/foaf/0.1/");
qEngine.addPrefix("dc", "http://purl.org/dc/elements/1.1/");

// fetch the resource with the specific uri.
var user = qEngine.find("<urn:for:me>");

// And popup objects of the resource.
alert(user.name().getValue()); // -> Yudai Ishikawa
alert(user.homepage().dc$title().getValue()); // -> The 3rd Develpment Section

こんな感じに、QNameをドット記法でつないでいけば何処まででもいけます。SPARQLのクエリを生で書くとものすごい記述量になるので、これだけでもかなり便利なはずです。

次は制約入りのクエリを実装予定です。

Comments

Trackbacks

Trackback Ping URI

http://yudai.arielworks.com/memo/2007/02/07/141320.trackback

末尾に「0 + 0」の計算結果を繋げて下さい。例えば計算結果が「17」の場合、「141320.trackback17」です。これは機械的なトラックバックスパムを防止するための措置です。

Post a comment

Name (optional)
Email address or URI (optional)
Do the math below (required to filter comment spams)
0 + 0 + 1 =
Message (required)
Submit
連絡先、リンク、転載や複製などについては『サイト案内』をご覧ください。Powered by HIMMEL

I ♥ Validator