zoukankan      html  css  js  c++  java
  • Xquery的初步学习(一次Lab作业的总结)

    Task 1: Open countries.xml, compose the following XQueries:

    1. Return the area of Mongolia.

    2. Return the names of all cities that have the same name as the country in which they are located.

    3. Return the average population of Russian-speaking countries.

    4. Returnthenamesofallcountrieswhereover50%ofthepopulationspeaksGerman. (Hint: Dependingonyoursolution, you may want to use ".", which refers to the "current element" within an XPath expression.)

    5. Returnthenameofthecountrywiththehighestpopulation. (Hint: Youmayneedtoexplicitlycastpopulationnumbers as integers with xs:int() to get the correct answer.)

    第一问:

    for $x in doc("countries.xml")/countries/country
    where $x/@name="Mongolia"
    return <area>{data($x/@area)}</area>

    第二问:

    for $x in doc("countries.xml")/countries/country
    for $y in $x/city
    where $y/name= $x/@name
    return $y/name 

    第三问:

    avg(doc("countries.xml")/countries/country[language="Russian"]/@population)

    第四问:

    for $i in (doc("countries.xml")/countries/country/language[@percentage>50 and .="German"]/../@name)
            return <name>{data($i)}</name>

    第五问:

    for $x in doc("countries.xml")/countries/country
    where $x/@population = max(doc("countries.xml")/countries/country/@population)
    return <name>{data($x/@name)}</name>
  • 相关阅读:
    VINS_Fusion 框架
    VINS_Fusion 前端源码解析
    堆与优先队列
    LSD-SLAM简介
    直接法和特征点法的区别与优缺点
    CV::Mat介绍
    C++ 位运算
    OPENCV重要函数
    C++ 优先队列
    特征点法的巅峰之作—ORBSLAM2
  • 原文地址:https://www.cnblogs.com/northernmashiro/p/9080390.html
Copyright © 2011-2022 走看看