Debian Codegraph @

reports/xmlize.ll

raw
1 /*
2 * @progname xmlize2.ll
3 * @version 2.2
4 * @author Rafal T. Prinke
5 * @category
6 * @output XML
7 * @description
8
9 This report converts all LifeLines records
10 to XML tagged file, with <LLGEDCOM> as
11 the root element.
12 It is now more consistent with Mike Kay's GedML.
13 References are all empty tags with IDREF attribute.
14 The NAME element contains one S element - for
15 surname (ie. it is a reserved tag and cannot be
16 used elsewhere).
17
18 I am leaving specific tags for vital events
19 rather than converting them to attributes
20 of generic EVEN tags as Mike does in GedML.
21
22 The CONT tag is replaced with an empty <P/> tag
23 to indicate a new paragraph and the CONC tag
24 is replaced with a space to assure continuity
25 of a paragraph.
26
27 xmlize2.ll - v. 1.1 Rafal T. Prinke, 8 March 2001
28 v. 2.0 - - , 28 April 2001
29 v. 2.1 - - , 29 April 2001
30 v. 2.2 - - , 30 June 2001 - changed REF to IDREF
31 */
32
33
34 global(previous)
35 global(numery)
36 global(tagi)
37
38 proc main ()
39 {
40 list(numery)
41 list(tagi)
42 set(previous,-1)
43
44 "<?xml version=" qt() "1.0" qt()
45
46 /* remove the next line for Unicode encoding or
47 edit for a different 8-bit encoding using one of these:
48 ISO-8859-1 - ISO Latin-1 (Western Europe)
49 ISO-8859-2 - ISO Latin-2 (Central-Eastern Europe)
50 windows-1252 - Windows Lat-1 (Western Europe)
51 windows-1250 - Windows Lat-2 (Central-Eastern Europe)
52 */
53
54 " encoding=" qt() "ISO-8859-2" qt()
55 " standalone=" qt() "yes" qt() "?>"
56
57 "\n"
58 "<LLGEDCOM>"
59
60 forindi(pers,x) {
61 call out(pers)
62 }
63 forfam(fm,x) {
64 call out(fm)
65 }
66 foreven(evn, n) {
67 call out(evn)
68 }
69 forsour(src, n) {
70 call out(src)
71 }
72 forothr(oth, n) {
73 call out(oth)
74 }
75
76 "\n</LLGEDCOM>"
77 }
78
79
80 proc out(item)
81
82 {
83 "\n"
84 traverse(root(item),y,level) {
85
86 if(eqstr(tag(y),"CONT")) { "<P/>" value(y) }
87
88 elsif(eqstr(tag(y),"CONC")) { " " value(y) }
89
90 else {
91
92 while(and(le(level,previous),not(empty(tagi)))) {
93 "</" pop(tagi) ">"
94 set(nic,pop(numery))
95 set(previous,sub(previous,1))
96 }
97 "<" tag(y)
98
99 if(index(value(y),"@",1)) {
100 set(wart,value(y))
101 " IDREF=" qt() substring(wart,2,sub(strlen(wart),1)) qt()
102 "/>"
103 }
104
105 else {
106 if(eq(level,0)) {
107 " ID=" qt() substring(xref(y),2,sub(strlen(xref(y)),1))
108 qt()
109 }
110 ">"
111
112 /* insert tag S for surname with space before and after if necessary */
113
114 if(eqstr(tag(y),"NAME")) {
115 set(bef,substring(value(y),1,sub(index(value(y),"/",1),1)))
116 bef
117 if(nestr(substring(bef,strlen(bef),strlen(bef))," ")) { " " }
118 "<S>"
119
120 substring(value(y),add(index(value(y),"/",1),1),sub(index(value(y),"/",2),1))
121 "</S>"
122
123 set(aft,substring(value(y),add(index(value(y),"/",2),1),strlen(value(y))))
124 if(and(nestr(substring(aft,1,1)," ") ,ne(strlen(aft),0) )) { " " }
125 aft
126 }
127
128 else { value(y) }
129
130 push(numery,level)
131 push(tagi,tag(y))
132 set(previous,level)
133 }
134 }
135 }
136
137 while(not(empty(tagi))) {
138 "</" pop(tagi) ">"
139 set(nic,pop(numery))
140 }
141 }