source: fmts/trunk/p/C0XRDF.m@ 1377

Last change on this file since 1377 was 1371, checked in by George Lilly, 13 years ago

updates for rdf out

File size: 2.3 KB
Line 
1C0XRDF ; GPL - Fileman Triples RDF out ;11/07/11 17:05
2 ;;0.1;C0X;nopatch;noreleasedate;Build 7
3 ;Copyright 2012 George Lilly. Licensed under the terms of the GNU
4 ;General Public License See attached copy of the License.
5 ;
6 ;This program is free software; you can redistribute it and/or modify
7 ;it under the terms of the GNU General Public License as published by
8 ;the Free Software Foundation; either version 2 of the License, or
9 ;(at your option) any later version.
10 ;
11 ;This program is distributed in the hope that it will be useful,
12 ;but WITHOUT ANY WARRANTY; without even the implied warranty of
13 ;MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 ;GNU General Public License for more details.
15 ;
16 ;You should have received a copy of the GNU General Public License along
17 ;with this program; if not, write to the Free Software Foundation, Inc.,
18 ;51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19 ;
20 Q
21 ;
22REPLYSTART(ZARY);
23 D ADD(ZARY,"<?xml version=""1.0"" encoding=""UTF-8""?>")
24 D ADD(ZARY,"<rdf:RDF xmlns:rdf=""http://www.w3.org/1999/02/22-rdf-syntax-ns#"">")
25 Q
26 ;
27LISTSTART(ZARY,ZNAM)
28 Q
29 ;
30DICTSTART(ZARY,ZSUB)
31 I ZSUB["http" D Q ;
32 . D ADD(ZARY,"<rdf:Description rdf:about="""_ZSUB_""">")
33 I $E(ZSUB,1,1)="/" D Q ;
34 . D ADD(ZARY,"<rdf:Description rdf:about="""_ZSUB_""">")
35 D ADD(ZARY,"<rdf:Description rdf:nodeID="""_ZSUB_""">")
36 Q
37 ;
38DASSERT(ZARY,ZPRED,ZOBJ)
39 I ZPRED[":" D Q ;
40 . I ZPRED="rdf:type" D Q ;
41 . . D ADD(ZARY,"<rdf:type rdf:resource="""_$$EXT^C0XUTIL(ZOBJ)_"""/>")
42 . N ZA,ZB,ZC
43 . S ZA=$P(ZPRED,":",1)
44 . S ZB=$P(ZPRED,":",2)
45 . S ZC=C0XVOC(ZA)
46 . D ADD(ZARY,"<"_ZB_" xmlns="""_ZC_""">"_$$EXT^C0XUTIL(ZOBJ)_"</"_ZB_">")
47 Q
48 ;
49DICTEND(ZARY)
50 D ADD(ZARY,"</rdf:Description>")
51 Q
52 ;
53LISTEND(ZARY)
54 Q
55 ;
56REPLYEND(ZARY)
57 D ADD(ZARY,"</rdf:RDF>")
58 Q
59 ;
60ADD(ZARY,ZELE)
61 N ZI
62 I '$D(ZARY) S @ZARY@(1)=ZELE Q ;
63 S ZI=$O(@ZARY@(""),-1)
64 S @ZARY@(ZI+1)=ZELE
65 Q
66 ;
67rdfout(rdfout,zary) ;
68 d REPLYSTART("rdfout")
69 d LISTSTART("rdfout","results")
70 n zi s zi=""
71 f s zi=$o(zary(zi)) q:zi="" d ; for each subject
72 . n zii s zii=""
73 . D DICTSTART("rdfout",$$EXT^C0XUTIL(zi))
74 . f s zii=$o(zary(zi,zii)) q:zii="" d ; for each pred^obj pair
75 . . d DASSERT("rdfout",$p(zii,"^",1),$p(zii,"^",2))
76 . D DICTEND("rdfout")
77 d LISTEND("rdfout")
78 d REPLYEND("rdfout")
79 q
80 ;
Note: See TracBrowser for help on using the repository browser.