XQuery ပြဋ္ဌာန်း
- အရှေ့ပိုင်း စာကြော် XQuery အကြောင်း
- နောက်ပိုင်း စာကြော် XQuery ထပ်ထည့်
XQuery is case-sensitive, and elements, attributes, and variables must be valid XML names.
Basic grammar rules of XQuery:
Some basic syntax rules:
- XQuery is case-sensitive
- XQuery elements, attributes, and variables must be valid XML names.
- XQuery string values can be enclosed in single or double quotes.
- XQuery variables are defined by a $ followed by a name, for example, $bookstore
- XQuery comments are separated by (: and :), for example, (: XQuery comment :)
XQuery conditional expression
The "If-Then-Else" statement can be used in XQuery.
Please see the following example:
for $x in doc("books.xml")/bookstore/book return if ($x/@category="CHILDREN") then <child>{data($x/title)}</child> else <adult>{data($x/title)}</adult>
Please note the syntax of "If-Then-Else": the parentheses after the if expression are required. else is also required, but you can also write "else ()".
အထင်ကိုးသည့် အမှတ်အသားများ:
<adult>Everyday Italian</adult> <child>Harry Potter</child> <adult>Learning XML</adult> <adult>XQuery Kick Start</adult>
XQuery ကွာချာခြင်း
XQuery တွင် ကွာချာခြင်း အမျိုးမျိုး ၂ မျိုး ရှိသည်。
- အမြဲတမ်းကွာချာခြင်း: =, !=, <, <=, >, >=
- ကွာချာခြင်း: eq, ne, lt, le, gt, ge
这两种比较方法的差异如下:
请看下面的 XQuery 表达式:
$bookstore//book/@q > 10
如果 q 属性的值大于 10,上面的表达式的返回值为 true。
$bookstore//book/@q gt 10
အကယ်၍ အကွက် q တစ်ခု သာ ပြန်လည် သွားရာ အကယ်၍ အကွက် q အချို့ ပြန်လည် သွားခဲ့ရမည် လည်း မဟုတ် သော် အဆိုပါ အစိုက် အပြန် ကို true ပြန်လည် ပြောဆိုသည်။
- အရှေ့ပိုင်း စာကြော် XQuery အကြောင်း
- နောက်ပိုင်း စာကြော် XQuery ထပ်ထည့်