2 XML Week XML XML XML-DB WG NTT ( ) ymmt@po.ntts.co.jp chiba@isid.co.jp obamikio@jp.ibm.com
XQuery SQL SQL SQL
XQuery SQL XML
XQuery XML XML XPath XML XPath XML XPath XPath XML XML
XQuery XML XML XPath XPath <students> <student name=" "> <teacher> </teacher> </student> <student name=" "> <teacher> </teacher> </student> <students> /students/student[@name=" "] <student name=" "> <teacher> </teacher> </student>
XQuery XML XML XPath <students> <teacher name=" "> <student name=" "> <student> </student> <teacher> </teacher> <student> </student> </student> </teacher> <student name=" "> <teacher> </teacher> </student> <students> XML
XQuery XML XML XPath XSLT XSLT XPath XML XSLT
XQuery XML XML XPath XSLT XPath XSLT XML!! XQuery XQuery!!
XML XML XML XML
XML XML XML XML SQL XML SQL
XML XML XML XML XML SQL XQuery
XML XML XML (Join)
XML XML XML XML XML
XML XML XQuery unordered ( ) unordered unordered( for $p in doc("parts.xml")//part[color = "Red"], $s in doc("suppliers.xml")//supplier where $p/suppno = $s/suppno return <ps> { $p/partno, $s/suppno } </ps> ) XQuery
XML Query XQL99 XQL98 XPath XSLT XUL excelon XML-QL XSQL Oracle XML XML OODBQuery OODBQuery XPointer RDBQuery RDBQuery SQL OQL QUILT XQuery XQL XSLT XPath XML XML-QL SQL XQL XML-QL QUILT XQuery QUILT W3C XML
XQuery W3C Working Draft (www.w3.org/xml/query) XML Query Requirements (5/2/2003) XML Query Use Cases (5/2/2003) :11/15/2002 http://www.xmlconsortium.org/wg/tech/wd-xmlquery-use-cases-20021115-japan-clean.htm XQuery1.0 and XPath2.0 Data Model (LAST CALL) (5/2/2003) XSLT 2.0 and XQuery 1.0 Serialization (5/2/2003) XQuery1.0 and XPath2.0 Formal Semantics (5/2/2003) XQuery1.0: An XML Query Language (5/2/2003) XML Syntax for XQuery1.0 (XQueryX) (6/7/2001) XQuery1.0 and XPath2.0 Functions and Operators (LAST CALL)(5/2/2003) XPath Requirements Version2.0 (2/14/2001) XML Path Language (XPath)2.0 (5/2/2003) :8/16/2002 Document WG http://www.xmlconsortium.org/wg/tech/wd-xpath20-20020816-japan-without-appendix.htm XML Query and XPath Full-Text Requirements (5/2/2003) XML Query and XPath Full-Text Use Cases (2/14/2003) Document WG
XQuery Expression XQuery 2003/05/03 Working Draft FLWOR Path
Path $ QName $b $val FLWOR typeswitch Path XML Path Language (XPath)2.0 /doc/chapter[title="introduction"]
XQuery XQuery1.0 and XPath2.0 Functions and Operators op:numeric-add fn:round fn:concat fn:contains fn:replace fn:local-name fn:deep-equal fn:empty fn:insert-before fn:sum fn:doc
XML Direct Element Constructor XML curly braces { } Computed Constructor element attribute document text <title isbn= isbn-0060229357 > { $b/title } </title> element title { "Harold and the Purple Crayon" } { attribute isbn { "isbn-0060229357" } }
FLWOR 1 F L W O R FOR LET WHERE ORDER BY RETURN flower əʊə XML JOIN XML FLWOR FLWOR
FLWOR 2 FOR for in (, in )* Cartesian tuple stream iteration LET let := (, in )* tuple stream FOR FOR FOR
FLWOR 3 WHERE where FOR LET tuple stream true false ORDER BY order by tuple stream collation empty
FLWOR 4 RETURN return FLWOR tuple stream
XML Query Use Cases 9 ( XMP ) ( TREE ) ( SEQ ) ( R ) ("SGML") Standard Generalized Markup Language ( STRING ) ( NS ) ( PARTS ) ("STRONG")
XML Query Use Cases Use Case 1 1991 Addison-Wesley (Use Case XMP Q1) Use Case 2 Bicycle itemno description bid Use Cases R Q2
Use Case 1 1991 Addison-Wesley (Use Case XMP Q1)
XML bib.xml <bib> <book year="1994"> <title>tcp/ip Illustrated</title> <author> <>Stevens</> <>W.</> </author> <publisher>addison-wesley</publisher> <price> 65.95</price> </book> XML Query Use Cases <book year="2000"> <title>data on the Web</title> <author> <>Abiteboul</> <>Serge</> </author> <author> <>Buneman</> <>Peter</> </author> <author> <>Suciu</> <>Dan</> </author> <publisher>morgan Kaufmann Publishers</publisher> <price>39.95</price> </book> </bib>
bib.xml bib book book year title author publisher price year title author author author publisher price 1994 TCP/IP Illustrated Addison -Wesley 65.95 2000 Data on the Web Morgan Kaufmann Publishers 39.95 Stevens W. Abiteboul Serge Buneman Peter Suciu Dan
XQuery 1 1991 Addison-Wesley (Use Case XMP Q1) XQuery
XQuery 1 1 bib book year 1994 title TCP/IP Illustrated author Stevens W. publisher price Addison -Wesley 65.95 book year 2000 title Data on the Web author Abiteboul Peter publisher price Morgan Kaufmann Publishers 39.95 author Suciu Serge author Buneman Dan
XQuery 1 2 bib $b = book book year title author publisher price year title author author author publisher price 1994 TCP/IP Illustrated Addison -Wesley 65.95 2000 Data on the Web Morgan Kaufmann 39.95 Publishers Stevens W. Abiteboul Serge Buneman Peter Suciu Dan
XQuery 1 3 WHERE bib $b = book book year title author publisher price year title author author author publisher price 1994 TCP/IP Illustrated Addison -Wesley 65.95 2000 Data on the Web Morgan Kaufmann 39.95 Publishers Stevens W. Abiteboul Serge Buneman Peter Suciu Dan
XQuery 1 4 return <book year= 1994 > <title>tcp/ip Illustrated</title> </book> bib $b = book book year title author publisher price year title author author author publisher price 1994 TCP/IP Illustrated Addison -Wesley 65.95 2000 Data on the Web Morgan Kaufmann 39.95 Publishers Stevens W. Abiteboul Serge Buneman Peter Suciu Dan
XQuery 1 5 bib book $b = book year title author publisher price year title author author author publisher price 1994 TCP/IP Illustrated Addison -Wesley 65.95 2000 Data on the Web Morgan Kaufmann Publishers 39.95 Stevens W. Abiteboul Serge Buneman Peter Suciu Dan
XQuery 1 6 bib WHERE book $b = book year title author publisher price year title author author author publisher price 1994 TCP/IP Illustrated Addison -Wesley 65.95 2000 Data on the Web Morgan 39.95 Kaufmann Publishers Stevens W. Abiteboul Serge Buneman Peter Suciu Dan
XQuery 1 7 XQuery <bib> <book year= 1994 > <title>tcp/ip Illustrated</title> </book> </bib> bib book book year title author publisher price year title author author author publisher price 1994 TCP/IP Illustrated Addison -Wesley 65.95 2000 Data on the Web Morgan Kaufmann 39.95 Publishers Stevens W. Abiteboul Serge Buneman Peter Suciu Dan
Use Case 2 Bicycle itemno description bid Use Cases R Q2
ITEMS BIDS 25 1999-03-06 1999-02-05 U01 Broken Bicycle 1008 200 1999-02-20 1999-01-20 U04 Racing Bicycle 1007 50000 1999-05-25 1999-05-05 U03 Helicopter 1006 20 1999-04-30 1999-03-19 U03 Tennis Racket 1005 15 1999-03-08 1999-02-25 U01 Tricycle 1004 25 1999-02-20 1999-01-10 U02 Old Bicycle 1003 500 1999-03-15 1999-02-11 U02 Motorcycle 1002 40 1999-01-20 1999-01-05 U01 Red Bicycle 1001 RESERVE _PRICE END_DATE START_DATE OFFERED _BY DESCRIPTION ITEMNO 1999-02-12 225 1007 U04 1999-02-08 200 1007 U05 1999-01-25 175 1007 U03 1999-03-05 40 1004 U01 1999-02-03 20 1003 U05 1999-01-22 15 1003 U04 1999-03-02 1200 1002 U02 1999-02-25 1000 1002 U04 1999-02-17 800 1002 U03 1999-02-16 600 1002 U02 1999-02-14 400 1002 U01 1999-01-15 55 1001 U02 1999-01-13 50 1001 U04 1999-01-11 45 1001 U02 1999-01-08 40 1001 U04 1999-01-07 35 1001 U02 BID_DATE BID ITEMNO USERID
XML items.xml items.xml
XML bids.xml bids.xml
XQuery 2 Bicycle itemno description bid Use Cases R Q2 XQuery
XQuery 2 1 <result> { for $i in doc("items.xml")//item_tuple let $b := doc("bids.xml")//bid_tuple[itemno = $i/itemno] where contains($i/description, "Bicycle") order by $i/itemno return <item_tuple> { $i/itemno } { $i/description } <high_bid>{ max($b/bid) }</high_bid> </item_tuple> }</result> items bids $i = item_tuple bid_tuple $b = itemno description offered_by start_date end_date reserve_price userid itemno bid bid_date XML JOIN
XQuery 2 2 <result> { for $i in doc("items.xml")//item_tuple let $b := doc("bids.xml")//bid_tuple[itemno = $i/itemno] where contains($i/description, "Bicycle") order by $i/itemno return <item_tuple> { $i/itemno } { $i/description } <high_bid>{ max($b/bid) }</high_bid> </item_tuple> }</result> JOIN $i = $b = ITEMNO 1001 DESCRIPTION Red Bicycle OFFERED _BY U01 START_DATE 1999-01-05 END_DATE 1999-01-20 RESERVE _PRICE 40 USERID U02 U04 ITEMNO 1001 1001 BID 35 40 BID_DATE 1999-01-07 1999-01-08 U02 1001 45 1999-01-11 U04 1001 50 1999-01-13 U02 1001 55 1999-01-15
XQuery 2 3 <result> { for $i in doc("items.xml")//item_tuple let $b := doc("bids.xml")//bid_tuple[itemno = $i/itemno] where contains($i/description, "Bicycle") order by $i/itemno return <item_tuple> { $i/itemno } { $i/description } <high_bid>{ max($b/bid) }</high_bid> </item_tuple> }</result> $i = $b = ITEMNO 1001 DESCRIPTION Red Bicycle OFFERED _BY U01 START_DATE 1999-01-05 END_DATE 1999-01-20 RESERVE _PRICE 40 USERID U02 U04 ITEMNO 1001 1001 BID 35 40 BID_DATE 1999-01-07 1999-01-08 U02 1001 45 1999-01-11 U04 1001 50 1999-01-13 U02 1001 55 1999-01-15
XQuery 2 4 <result> { for $i in doc("items.xml")//item_tuple let $b := doc("bids.xml")//bid_tuple[itemno = $i/itemno] where contains($i/description, "Bicycle") order by $i/itemno return <item_tuple> { $i/itemno } { $i/description } <high_bid>{ max($b/bid) }</high_bid> </item_tuple> }</result> $i = $b = ITEMNO DESCRIPTION OFFERED _BY START_DATE END_DATE RESERVE _PRICE USERID U02 ITEMNO 1001 BID 35 BID_DATE 1999-01-07 1001 Red Bicycle U01 1999-01-05 1999-01-20 40 U04 1001 40 1999-01-08 U02 1001 45 1999-01-11 item_tuple U04 U02 1001 1001 50 55 1999-01-13 1999-01-15 itemno description high_bid max( )
XQuery 2 5 <result> { for $i in doc("items.xml")//item_tuple let $b := doc("bids.xml")//bid_tuple[itemno = $i/itemno] where contains($i/description, "Bicycle") order by $i/itemno return <item_tuple> { $i/itemno } { $i/description } <high_bid>{ max($b/bid) }</high_bid> </item_tuple> }</result> result item_tuple item_tuple item_tuple item_tuple itemno description high_bid itemno description high_bid itemno description high_bid itemno description high_bid 1001 Red Bicycle 55.0 1003 Old Bicycle 20.0 1007 Racing Bicycle 225.0 1008 Broken Bicycle order by
XQuery 2 6 <result> <item_tuple> <itemno>1001</itemno> <description>red Bicycle</description> <high_bid>55.0</high_bid> </item_tuple> <item_tuple> <itemno>1003</itemno> <description>old Bicycle</description> <high_bid>20.0</high_bid> </item_tuple> <item_tuple> <itemno>1007</itemno> <description>racing Bicycle</description> <high_bid>225.0</high_bid> </item_tuple> <item_tuple> <itemno>1008</itemno> <description>broken Bicycle</description> <high_bid></high_bid> </item_tuple> </result>
SVG XQuery SVG Scalable Vector Graphics W3C XML http://www.w3.org/tr/svg/ rect circle text SVG XQuery
SVG SVG <?xml version= 1.0 encoding= UTF-8?> <svg xmlns:svg='http://www.w3.org/2000/svg' width='100mm' height='100mm' viewbox='0 0 100 100'> <circle cx='20' cy='20' r='15' fill="#ff0000" stroke="#000000" stroke-width="0.3"/> </svg> SVG 20 x RGB #FF0000 20 15 y
SVG XML-DB (NeoCore) XQueryViewer XML-DB (Xquery Apache XML Project Batik 1.5 (SVG Library) Java Foundation Class (Swing) Java SDK 1.4
SVG SVG Xquery
[ ] SVG 1 SVG circle1.svg 5 10 15 20 25 30
[ ] SVG 2 SVG circle1.svg <?xml version="1.0" encoding="utf-8" standalone="no"?> <svg xmlns='http://www.w3.org/2000/svg' width='100mm' height='100mm' viewbox='0 0 100 100'> <g> <circle cx='15' cy='15' r='5' fill="#ff0000" fill-opacity="0.2" stroke="#000000" stroke-width="0.3"/> <circle cx='15' cy='65' r='5' fill="#ff0000" fill-opacity="0.2" stroke="#000000" stroke-width="0.3"/> <circle cx='65' cy='65' r='5' fill="#ff0000" fill-opacity="0.2" stroke="#000000" stroke-width="0.3"/> <circle cx='65' cy='15' r='5' fill="#ff0000" fill-opacity="0.2" stroke="#000000" stroke-width="0.3"/> <circle cx='20' cy='20' r='10' fill="#ff0033" fill-opacity="0.2" stroke="#000000" stroke-width="0.3"/> <circle cx='20' cy='60' r='10' fill="#ff0033" fill-opacity="0.2" stroke="#000000" stroke-width="0.3"/> <circle cx='60' cy='60' r='10' fill="#ff0033" fill-opacity="0.2" stroke="#000000" stroke-width="0.3"/> <circle cx='60' cy='20' r='10' fill="#ff0033" fill-opacity="0.2" stroke="#000000" stroke-width="0.3"/> <circle cx='25' cy='25' r='15' fill="#ff0066" fill-opacity="0.2" stroke="#000000" stroke-width="0.3"/> <circle cx='25' cy='55' r='15' fill="#ff0066" fill-opacity="0.2" stroke="#000000" stroke-width="0.3"/> <circle cx='55' cy='55' r='15' fill="#ff0066" fill-opacity="0.2" stroke="#000000" stroke-width="0.3"/> <circle cx='55' cy='25' r='15' fill="#ff0066" fill-opacity="0.2" stroke="#000000" stroke-width="0.3"/> <circle cx='30' cy='30' r='20' fill="#ff0099" fill-opacity="0.2" stroke="#000000" stroke-width="0.3"/> <circle cx='30' cy='50' r='20' fill="#ff0099" fill-opacity="0.2" stroke="#000000" stroke-width="0.3"/> <circle cx='50' cy='50' r='20' fill="#ff0099" fill-opacity="0.2" stroke="#000000" stroke-width="0.3"/> <circle cx='50' cy='30' r='20' fill="#ff0099" fill-opacity="0.2" stroke="#000000" stroke-width="0.3"/> <circle cx='35' cy='35' r='25' fill="#ff00cc" fill-opacity="0.2" stroke="#000000" stroke-width="0.3"/> <circle cx='35' cy='45' r='25' fill="#ff00cc" fill-opacity="0.2" stroke="#000000" stroke-width="0.3"/> <circle cx='45' cy='45' r='25' fill="#ff00cc" fill-opacity="0.2" stroke="#000000" stroke-width="0.3"/> <circle cx='45' cy='35' r='25' fill="#ff00cc" fill-opacity="0.2" stroke="#000000" stroke-width="0.3"/> <circle cx='40' cy='40' r='30' fill="#ff00ff" fill-opacity="0.2" stroke="#000000" stroke-width="0.3"/> </g> </svg>
[ ] SVG 3 20 <svg xmlns='http://www.w3.org/2000/svg' width='100mm' height='100mm' viewbox='0 0 100 100'> { for $c in document("circle1.svg")/svg//circle where $c/@r < 20 return <g> { $c } </g> }</svg> 20 <svg xmlns='http://www.w3.org/2000/svg' width='100mm' height='100mm' viewbox='0 0 100 100'> { for $c in document("circle1.svg")/svg//circle where $c/@r > 20 return <g> { $c } </g> }</svg>
[ ] SVG 4 20 20
[ ] SVG 5 SVG rect1.svg 10 10 4 4
[ ] SVG 6 SVG circle1.svg <?xml version="1.0" encoding="utf-8" standalone="no"?> <svg xmlns='http://www.w3.org/2000/svg' width='40mm' height='40mm' viewbox='0 0 40 40'> <g> <rect x='0' y='0' width='10' height='10' fill="#66ccff" stroke="none"/> <rect x='10' y='0' width='10' height='10' fill="#ff9933" stroke="none"/> <rect x='20' y='0' width='10' height='10' fill="#66ccff" stroke="none"/> <rect x='30' y='0' width='10' height='10' fill="#ff9933" stroke="none"/> <rect x='0' y='10' width='10' height='10' fill="#ff9933" stroke="none"/> <rect x='10' y='10' width='10' height='10' fill="#66ccff" stroke="none"/> <rect x='20' y='10' width='10' height='10' fill="#ff9933" stroke="none"/> <rect x='30' y='10' width='10' height='10' fill="#66ccff" stroke="none"/> <rect x='0' y='20' width='10' height='10' fill="#66ccff" stroke="none"/> <rect x='10' y='20' width='10' height='10' fill="#ff9933" stroke="none"/> <rect x='20' y='20' width='10' height='10' fill="#66ccff" stroke="none"/> <rect x='30' y='20' width='10' height='10' fill="#ff9933" stroke="none"/> <rect x='0' y='30' width='10' height='10' fill="#ff9933" stroke="none"/> <rect x='10' y='30' width='10' height='10' fill="#66ccff" stroke="none"/> <rect x='20' y='30' width='10' height='10' fill="#ff9933" stroke="none"/> <rect x='30' y='30' width='10' height='10' fill="#66ccff" stroke="none"/> </g> </svg>
[ ] SVG 7 x 2 <svg xmlns='http://www.w3.org/2000/svg' width='80mm' height='40mm' viewbox='0 0 80 40'> { for $r in document("rect1.svg")/svg//rect return <g> <rect x={$r/@x*2} y={$r/@y} width={$r/@width*2} height={$r/@height} fill={$r/@fill} stroke="none"/> </g> }</svg>
[ ] SVG 8
Demonstration XML DB NeoCore http://www.neocore.jp/ SVG