mirror of
https://github.com/KevinMidboe/linguist.git
synced 2025-10-29 17:50:22 +00:00
Add JSONiq support
This commit is contained in:
@@ -868,6 +868,12 @@ JSONLD:
|
|||||||
lexer: JavaScript
|
lexer: JavaScript
|
||||||
primary_extension: .jsonld
|
primary_extension: .jsonld
|
||||||
|
|
||||||
|
JSONiq:
|
||||||
|
type: programming
|
||||||
|
ace_mode: jsoniq
|
||||||
|
lexer: XQuery
|
||||||
|
primary_extension: .jq
|
||||||
|
|
||||||
Jade:
|
Jade:
|
||||||
group: HTML
|
group: HTML
|
||||||
type: markup
|
type: markup
|
||||||
|
|||||||
9
samples/JSONiq/detail.jq
Normal file
9
samples/JSONiq/detail.jq
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
(: Query for returning one database entry :)
|
||||||
|
|
||||||
|
import module namespace req = "http://www.28msec.com/modules/http-request";
|
||||||
|
import module namespace catalog = "http://guide.com/catalog";
|
||||||
|
|
||||||
|
variable $id := (req:param-values("id"), "London")[1];
|
||||||
|
variable $part := (req:param-values("part"), "main")[1];
|
||||||
|
|
||||||
|
catalog:get-data-by-key($id, $part)
|
||||||
17
samples/JSONiq/query.jq
Normal file
17
samples/JSONiq/query.jq
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
(: Query for searching the database for keywords :)
|
||||||
|
|
||||||
|
import module namespace index = "http://guide.com/index";
|
||||||
|
import module namespace catalog = "http://guide.com/catalog";
|
||||||
|
|
||||||
|
import module namespace req = "http://www.28msec.com/modules/http-request";
|
||||||
|
|
||||||
|
variable $phrase := (req:param-values("q"), "London")[1];
|
||||||
|
variable $limit := integer((req:param-values("limit"), 5)[1]);
|
||||||
|
|
||||||
|
[
|
||||||
|
for $result at $idx in index:index-search($phrase)
|
||||||
|
where $idx le $limit
|
||||||
|
let $data := catalog:get-data-by-id($result.s, $result.p)
|
||||||
|
return
|
||||||
|
{| { score : $result.r } , $data |}
|
||||||
|
]
|
||||||
Reference in New Issue
Block a user