Moderní značkovací jazyky a jejich aplikace
Týden 4 -- Dotazování nad XML daty (XQuery)
Přednáška
- What is XQuery?
- XQuery processing.
- DOM/XSLT comparison
- XQuery syntax
Cvičení
- You can use either eXide IDE from eXist-db or the saxon9he.
- To run the query using saxon9he from command line you have to enter:
- java -cp saxon9he.jar net.sf.saxon.Query overpaid.xq where overpaid.xq is name of your XQuery file that contains specification of XML data:
- archive saxon9he.jar is part of saxon9 distribution,
- the java parameter -cp saxon9he.jar points on the location of the archive,
- specification of source XML data can be done either using the function doc in the query file or using -s:path_to_xml_data parameter to Query class in following form:
- java -cp saxon9he.jar net.sf.saxon.Query overpaid.xq where overpaid.xq is name of your XQuery file that contains specification of XML data:
- To run the query using saxon9he from command line you have to enter:
- http://www.xpathtester.com/xquery an online XPath/XQuery/XSLT runner.
- Create XQuery which will return the people from the source file whos income is over the company average income.
- The result will be in form:
<overpaid average="average income"> <human> <name> ...</name> <surname>...</surname> <salary>...</salary> </human> ... </overpaid>
- Create XQuery which returns cars in the source file that has been produced after the average production year.
- The result will be in the form:
<new_cars min_year='avg_production_year'> <car id="car_id" year="year"> <owner> <name>...</name> <surname>...</surname> </owner> </car> </new_cars>