1 / 15

演習3 第1回発表

演習3 第1回発表. 山崎孝裕. 演習の目的. XML 処理言語として、 XDuce と XQuery を用いて XML アプリケーションを作成し、両者の違いを比較する。. XDuce. XML のスキーマから型を作り、静的な型システムの下で XML を処理する。 ML 風の強力なパターンマッチ機構を持つ関数型言語. XQuery. XML 文書に対する問い合わせ言語 リレーショナルデータベース: SQL ≒ XML : XQuery XPath を使った Path 式と、 FLOWR 式によって、 XML 文書に問い合わせを行う。. データ位置指定(1).

jariah
Download Presentation

演習3 第1回発表

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. 演習3 第1回発表 山崎孝裕

  2. 演習の目的 • XML処理言語として、XDuceとXQueryを用いてXMLアプリケーションを作成し、両者の違いを比較する。

  3. XDuce • XMLのスキーマから型を作り、静的な型システムの下でXMLを処理する。 • ML風の強力なパターンマッチ機構を持つ関数型言語

  4. XQuery • XML文書に対する問い合わせ言語 リレーショナルデータベース:SQL ≒ XML:XQuery • XPathを使ったPath式と、FLOWR式によって、XML文書に問い合わせを行う。

  5. データ位置指定(1) • XQueryはXSLと同様に、データの位置をXPathを使って指定する。 • XDuceは、パターンマッチによって同等の機能を得ている。

  6. データ位置指定(2) • 例(XDuce) match b with html [AnyAttrs, head [Any], body [AnyAttrs, h1 [AnyAttrs, val title as String*], AnyEls]]

  7. データ位置指定(3) • 例(XPath) “/html[head]/body/h1” • 簡潔さを見ればXPathのほうが有利 • XDuceではパターンマッチなので、一回のマッチで複数の変数をバインドさせることができる。複雑なパターンも理解しやすい。 →ツリー構造をそのまま表現しているから?

  8. データの流れ(1) • XDuceやXSLでは、パターンやXPathと処理するXMLとをマッチし、そのマッチに対して行うべき処理を一つずつ記述する。処理系では、マッチに対して対応する処理部分が実行されることで処理が進んで行く。

  9. データの流れ(2) • XQueryでは、FLOWR式をクエリーとしてXMLに問い合わせ、そのクエリーにマッチするものを一度に取得して処理をする。

  10. FLOWR式 • FLOWR: for/let/order/where/return • forやletによる問い合わせ(この際にwhereで絞込条件を指定できる)によって問い合わせの結果の組(tuple)の列が返され、returnはその列のそれぞれのtupleに対し一回の実行を行う。

  11. FLOWR式(forとlet) • letはクエリーの結果の列のtupleを含む一要素の列を作成する。 →バインドするだけ • forはクエリーの結果の列のぞれぞれの要素を一つのtupleとみなして、tupleの列を作成する。 →繰り返しを行ってバインド

  12. FLOWR式(例:let) • let $s := (<one/>, <two/>, <three/>) return <out>{$s}</out> ↓ <out><one/><two/><three/></out> • $sには、{ (<one/>, <two/>, <three/>) }という1tupleの列がバインドされている。

  13. FLOWR式(例:for 1) • for $s := (<one/>, <two/>, <three/>) return <out>{$s}</out> ↓ <out><one/></out> <out><two/></out> <out><three/></out> • $sには、{ (<one/>), (<two/>), (<three/>) }という3tupleの列がバインドされている。

  14. FLOWR式(例:for 2) • for $i in (1, 2), $j in (3, 4) ↓ ($i, $j) = { ($i = 1, $j = 3), ($i = 1, $j = 4), ($i = 2, $j = 3), ($i = 2, $j = 4) } • $iと$jの直積を取ったものが($i, $j)となる。

  15. 参考文献 • W3C Recommendation / Working Draft XML: http://www.w3.org/TR/REC-xml/ XPath: http://www.w3.org/TR/xpath XQuery: http://www.w3.org/TR/xquery/ • @IT:XML & Web Services http://www.atmarkit.co.jp/fxml/

More Related