XPath 帮助文档
一,XPath 简介
XPath 是一种筛选方式,可用于检索、增加限定条件。
二,符号说明
类型 | 符号 | 功能 |
---|---|---|
界符 | // | 后面是主表声明 |
/ | 后面是属性或者关联关系或者关联表。取决于当前语义状态 | |
[ | 开始 where 条件 | |
] | 结束 where 条件 | |
( | 开始分组 | |
) | 结束分组 | |
连接符 | and | 两个等式之间的且条件 |
or | 两个等式之间的或条件 | |
运算符 | = | 等于 |
!= | 不等于 | |
> | 大于 | |
>= | 大于等于 | |
< | 小于 | |
<= | 小于等于 |
三,样例说明
//m1.t1[f1 >= -1.1 and f2 = 'hu' and (/r1/t2/f3 = '[%currentUserId%]' or f4 = f5)]/f6/f7
等效于
select t1.f6, t1.f7
from t1
inner join t2 on t2.xxx = t1.xxx
where t1.f1 >= -1.1 and t1.f2='hu' and (t2.f3 = 9527 or t1.f4 = t1.f5)
//m1.t1/r1/t2
等效于
select * from t1
inner join t2 on t2.xxx = t1.xxx
//m1.t1[(f1 > 5 and f2 = 'hu') or (f3 != 5 or f4 <= '[%now%]')]
等效于
select * from t1
where (t1.f1 > 5 and t1.f2 = 'hu') or (t1.f3 != 5 or t1.f4 <= '2022-03-16 13:45:11')
四,系统关键字
用法 | 含义 |
---|---|
//systemModule$user[id = '[%currentUserId%]'] | 此处的'[%currentUserId%]'表示当前会话的用户主键 id |
//systemModule$user[create_time >= '[%now%]'] | 此处的'[%now%]'表示当前 xpath 执行时的时间,格式为 2022-01-01 01:01:01 |