[1367] | 1 | C0XRDF ; 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 | ;
|
---|
| 22 | REPLYSTART(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 | ;
|
---|
| 27 | LISTSTART(ZARY,ZNAM)
|
---|
| 28 | Q
|
---|
| 29 | ;
|
---|
| 30 | DICTSTART(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 | ;
|
---|
| 38 | DASSERT(ZARY,ZPRED,ZOBJ)
|
---|
| 39 | I ZPRED[":" D Q ;
|
---|
| 40 | . I ZPRED="rdf:type" D Q ;
|
---|
[1371] | 41 | . . D ADD(ZARY,"<rdf:type rdf:resource="""_$$EXT^C0XUTIL(ZOBJ)_"""/>")
|
---|
[1368] | 42 | . N ZA,ZB,ZC
|
---|
[1367] | 43 | . S ZA=$P(ZPRED,":",1)
|
---|
| 44 | . S ZB=$P(ZPRED,":",2)
|
---|
[1391] | 45 | . I $E(ZB,1,1)="/" D ;
|
---|
| 46 | . . S ZB=$P(ZB,"/",2) ; handling gpltest:/note situations
|
---|
[1483] | 47 | . S ZC=$G(C0XVOC(ZA))
|
---|
| 48 | . I ZC="" S ZC=ZA
|
---|
[1384] | 49 | . I ZOBJ["nodeID:" D Q ;
|
---|
| 50 | . . D ADD(ZARY,"<"_ZB_" xmlns="""_ZC_""" rdf:nodeID="""_$$EXT^C0XUTIL(ZOBJ)_"""/>")
|
---|
[1385] | 51 | . S ZOBJ=$$EXT^C0XUTIL(ZOBJ)
|
---|
| 52 | . I ZOBJ["http" D Q ;
|
---|
| 53 | . . D ADD(ZARY,"<"_ZB_" xmlns="""_ZC_""" rdf:resource="""_ZOBJ_"""/>")
|
---|
| 54 | . I $E(ZOBJ,1,1)="/" D Q ;
|
---|
| 55 | . . D ADD(ZARY,"<"_ZB_" xmlns="""_ZC_""" rdf:resource="""_ZOBJ_"""/>")
|
---|
[1368] | 56 | . D ADD(ZARY,"<"_ZB_" xmlns="""_ZC_""">"_$$EXT^C0XUTIL(ZOBJ)_"</"_ZB_">")
|
---|
[1483] | 57 | I ZPRED'[":" D Q ;
|
---|
| 58 | . I ZPRED["." S ZPRED=$TR(ZPRED,".","-")
|
---|
| 59 | . I ZPRED["@" S ZPRED=$TR(ZPRED,"@","_")
|
---|
| 60 | . D ADD(ZARY,"<"_ZPRED_">"_$$EXT^C0XUTIL(ZOBJ)_"</"_ZPRED_">")
|
---|
[1367] | 61 | Q
|
---|
| 62 | ;
|
---|
| 63 | DICTEND(ZARY)
|
---|
[1370] | 64 | D ADD(ZARY,"</rdf:Description>")
|
---|
[1367] | 65 | Q
|
---|
| 66 | ;
|
---|
| 67 | LISTEND(ZARY)
|
---|
| 68 | Q
|
---|
| 69 | ;
|
---|
| 70 | REPLYEND(ZARY)
|
---|
| 71 | D ADD(ZARY,"</rdf:RDF>")
|
---|
| 72 | Q
|
---|
| 73 | ;
|
---|
| 74 | ADD(ZARY,ZELE)
|
---|
| 75 | N ZI
|
---|
| 76 | I '$D(ZARY) S @ZARY@(1)=ZELE Q ;
|
---|
| 77 | S ZI=$O(@ZARY@(""),-1)
|
---|
| 78 | S @ZARY@(ZI+1)=ZELE
|
---|
| 79 | Q
|
---|
| 80 | ;
|
---|
| 81 | rdfout(rdfout,zary) ;
|
---|
| 82 | d REPLYSTART("rdfout")
|
---|
| 83 | d LISTSTART("rdfout","results")
|
---|
| 84 | n zi s zi=""
|
---|
| 85 | f s zi=$o(zary(zi)) q:zi="" d ; for each subject
|
---|
| 86 | . n zii s zii=""
|
---|
[1368] | 87 | . D DICTSTART("rdfout",$$EXT^C0XUTIL(zi))
|
---|
[1367] | 88 | . f s zii=$o(zary(zi,zii)) q:zii="" d ; for each pred^obj pair
|
---|
| 89 | . . d DASSERT("rdfout",$p(zii,"^",1),$p(zii,"^",2))
|
---|
| 90 | . D DICTEND("rdfout")
|
---|
| 91 | d LISTEND("rdfout")
|
---|
| 92 | d REPLYEND("rdfout")
|
---|
| 93 | q
|
---|
| 94 | ;
|
---|