-
Notifications
You must be signed in to change notification settings - Fork 15
/
onexsd2bgf.pro
41 lines (36 loc) · 868 Bytes
/
onexsd2bgf.pro
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
:- ensure_loaded('../slps.pro').
% wiki: XSD2BGF
loadOneXsd(File,(S,G,_))
:-
% Load schema and check schema element
format('Loading XSD file ~q.~n',[File]),
load_structure(File, Content, [dialect(xmlns)]),
member(S,Content),
S =.. [element|_],
self(name(xsd:schema),S),
noXmlnssBelow(S),
% Derive dir of schema file
(
name(File,FileS),
append(DirS,[0'/|BaseS],FileS),
\+ member(0'/,BaseS),
name(Dir,DirS),
!
;
Dir = '.'
),
% Derive grammar
gFromSchema(S,G),
!.
main
:-
% Compatibility hack for >6.4.1 and the use of '--'
( RawArgv = argv ; RawArgv = os_argv ),
current_prolog_flag(RawArgv,Argv),
append(_,['--',XsdFile,BgfFile],Argv),
loadOneXsd(XsdFile,G1),
completeXsd(G1,G2),
gToXml(G2,Xml),
saveXml(BgfFile,Xml),
halt.
:- run.