-
Notifications
You must be signed in to change notification settings - Fork 1
/
generate.xqy
26 lines (21 loc) · 915 Bytes
/
generate.xqy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
xquery version "3.1";
import module namespace xsd2json="http://easymetahub.com/ns/xsd2json" at "xsd2json.xqy";
declare namespace output = "http://www.w3.org/2010/xslt-xquery-serialization";
declare namespace map = "http://www.w3.org/2005/xpath-functions/map";
declare namespace xs="http://www.w3.org/2001/XMLSchema";
declare option output:method "text";
declare variable $keepNamespaces external := fn:false();
declare variable $schemaId external := 'output.json';
declare variable $restrictive external := fn:true();
declare variable $option := map {'method': 'json', 'use-character-maps' : map { '/' : '/' }, 'indent': fn:true()};
fn:serialize(
xsd2json:run(
./xs:schema,
map {
$xsd2json:KEEP_NAMESPACES: $keepNamespaces,
$xsd2json:SCHEMAID: $schemaId,
$xsd2json:RESTRICTIVE: $restrictive
}
),
$option
)