Clover Coverage Report
Coverage timestamp: Fri Feb 14 2014 01:49:02 UTC
../../../../../img/srcFileCovDistChart10.png 0% of files have more coverage
374   838   179   3.94
154   696   0.48   95
95     1.88  
1    
 
  Qedeq2Xml       Line # 81 374 179 92.5% 0.9245586
 
  (1)
 
1    /* This file is part of the project "Hilbert II" - http://www.qedeq.org
2    *
3    * Copyright 2000-2014, Michael Meyling <mime@qedeq.org>.
4    *
5    * "Hilbert II" is free software; you can redistribute
6    * it and/or modify it under the terms of the GNU General Public
7    * License as published by the Free Software Foundation; either
8    * version 2 of the License, or (at your option) any later version.
9    *
10    * This program is distributed in the hope that it will be useful,
11    * but WITHOUT ANY WARRANTY; without even the implied warranty of
12    * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13    * GNU General Public License for more details.
14    */
15   
16    package org.qedeq.kernel.xml.dao;
17   
18    import java.io.IOException;
19   
20    import org.qedeq.base.io.TextOutput;
21    import org.qedeq.base.utility.StringUtility;
22    import org.qedeq.kernel.bo.KernelContext;
23    import org.qedeq.kernel.bo.module.InternalServiceJob;
24    import org.qedeq.kernel.bo.module.KernelQedeqBo;
25    import org.qedeq.kernel.bo.service.basis.ControlVisitor;
26    import org.qedeq.kernel.se.base.list.ElementList;
27    import org.qedeq.kernel.se.base.module.Add;
28    import org.qedeq.kernel.se.base.module.Author;
29    import org.qedeq.kernel.se.base.module.AuthorList;
30    import org.qedeq.kernel.se.base.module.Axiom;
31    import org.qedeq.kernel.se.base.module.ChangedRule;
32    import org.qedeq.kernel.se.base.module.Chapter;
33    import org.qedeq.kernel.se.base.module.Conclusion;
34    import org.qedeq.kernel.se.base.module.ConditionalProof;
35    import org.qedeq.kernel.se.base.module.Existential;
36    import org.qedeq.kernel.se.base.module.FormalProof;
37    import org.qedeq.kernel.se.base.module.FormalProofLine;
38    import org.qedeq.kernel.se.base.module.FormalProofLineList;
39    import org.qedeq.kernel.se.base.module.Formula;
40    import org.qedeq.kernel.se.base.module.FunctionDefinition;
41    import org.qedeq.kernel.se.base.module.Header;
42    import org.qedeq.kernel.se.base.module.Hypothesis;
43    import org.qedeq.kernel.se.base.module.Import;
44    import org.qedeq.kernel.se.base.module.ImportList;
45    import org.qedeq.kernel.se.base.module.InitialFunctionDefinition;
46    import org.qedeq.kernel.se.base.module.InitialPredicateDefinition;
47    import org.qedeq.kernel.se.base.module.Latex;
48    import org.qedeq.kernel.se.base.module.LatexList;
49    import org.qedeq.kernel.se.base.module.LinkList;
50    import org.qedeq.kernel.se.base.module.LiteratureItem;
51    import org.qedeq.kernel.se.base.module.LiteratureItemList;
52    import org.qedeq.kernel.se.base.module.Location;
53    import org.qedeq.kernel.se.base.module.LocationList;
54    import org.qedeq.kernel.se.base.module.ModusPonens;
55    import org.qedeq.kernel.se.base.module.Node;
56    import org.qedeq.kernel.se.base.module.PredicateDefinition;
57    import org.qedeq.kernel.se.base.module.Proof;
58    import org.qedeq.kernel.se.base.module.Proposition;
59    import org.qedeq.kernel.se.base.module.Qedeq;
60    import org.qedeq.kernel.se.base.module.Rename;
61    import org.qedeq.kernel.se.base.module.Rule;
62    import org.qedeq.kernel.se.base.module.Section;
63    import org.qedeq.kernel.se.base.module.Specification;
64    import org.qedeq.kernel.se.base.module.Subsection;
65    import org.qedeq.kernel.se.base.module.SubsectionList;
66    import org.qedeq.kernel.se.base.module.SubstFree;
67    import org.qedeq.kernel.se.base.module.SubstFunc;
68    import org.qedeq.kernel.se.base.module.SubstPred;
69    import org.qedeq.kernel.se.base.module.Term;
70    import org.qedeq.kernel.se.base.module.Universal;
71    import org.qedeq.kernel.se.base.module.UsedByList;
72    import org.qedeq.kernel.se.common.ModuleService;
73    import org.qedeq.kernel.se.common.SourceFileExceptionList;
74   
75   
76    /**
77    * This class prints a QEDEQ module in XML format in an output stream.
78    *
79    * @author Michael Meyling
80    */
 
81    public final class Qedeq2Xml extends ControlVisitor implements ModuleService {
82   
83    /** Output goes here. */
84    private TextOutput printer;
85   
86    /**
87    * Constructor.
88    *
89    * @param plugin This plugin we work for.
90    * @param bo QEDEQ BO.
91    * @param printer Print herein.
92    */
 
93  135 toggle public Qedeq2Xml(final ModuleService plugin, final KernelQedeqBo bo, final TextOutput printer) {
94  135 super(plugin, bo);
95  135 this.printer = printer;
96    }
97   
98    /**
99    * Prints a XML representation of given QEDEQ module into a given output stream.
100    *
101    * @param process Service process we work for.
102    * @param plugin Plugin we work for.
103    * @param bo BO QEDEQ module object.
104    * @param printer Print herein.
105    * @throws SourceFileExceptionList Major problem occurred.
106    * @throws IOException Writing failed.
107    */
 
108  135 toggle public static void print(final InternalServiceJob process,
109    final ModuleService plugin, final KernelQedeqBo bo, final TextOutput printer) throws
110    SourceFileExceptionList, IOException {
111  135 final Qedeq2Xml converter = new Qedeq2Xml(plugin, bo, printer);
112  135 try {
113  135 converter.traverse(process);
114    } finally {
115  135 printer.flush();
116    }
117  135 if (printer.checkError()) {
118  0 throw printer.getError();
119    }
120    }
121   
 
122  135 toggle public final void visitEnter(final Qedeq qedeq) {
123  135 printer.println("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
124  135 printer.println("<QEDEQ");
125  135 printer.println(" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"");
126  135 printer.println(" xsi:noNamespaceSchemaLocation=\"http://www.qedeq.org/"
127    + KernelContext.getInstance().getKernelVersionDirectory() + "/xml/qedeq.xsd\">");
128  135 printer.pushLevel();
129    }
130   
 
131  135 toggle public final void visitLeave(final Qedeq qedeq) {
132  135 printer.popLevel();
133  135 printer.println("</QEDEQ>");
134    }
135   
 
136  135 toggle public void visitEnter(final Header header) {
137  135 printer.print("<HEADER");
138  135 if (header.getEmail() != null) {
139  135 printer.print(" email=\"" + StringUtility.escapeXml(header.getEmail()) + "\"");
140    }
141  135 printer.println(">");
142  135 printer.pushLevel();
143    }
144   
 
145  135 toggle public void visitLeave(final Header header) {
146  135 printer.popLevel();
147  135 printer.println("</HEADER>");
148    }
149   
 
150  285 toggle public void visitEnter(final Specification specification) {
151  285 printer.print("<SPECIFICATION");
152  285 if (specification.getName() != null) {
153  285 printer.print(" name=\"" + StringUtility.escapeXml(specification.getName()) + "\"");
154    }
155  285 if (specification.getName() != null) {
156  285 printer.print(" ruleVersion=\"" + StringUtility.escapeXml(specification.getRuleVersion()) + "\"");
157    }
158  285 printer.println(">");
159  285 printer.pushLevel();
160    }
161   
 
162  285 toggle public void visitLeave(final Specification specification) {
163  285 printer.popLevel();
164  285 printer.println("</SPECIFICATION>");
165    }
166   
 
167  3164 toggle public void visitEnter(final LatexList latexList) {
168  3164 final String last = getCurrentContext().getLocationWithinModule();
169  3164 if (last.endsWith(".getTitle()")) {
170  1156 printer.println("<TITLE>");
171  2008 } else if (last.endsWith(".getSummary()")) {
172  135 printer.println("<ABSTRACT>");
173  1873 } else if (last.endsWith(".getIntroduction()")) {
174  403 printer.println("<INTRODUCTION>");
175  1470 } else if (last.endsWith(".getName()")) {
176  478 printer.println("<NAME>");
177  992 } else if (last.endsWith(".getPrecedingText()")) {
178  528 printer.println("<PRECEDING>");
179  464 } else if (last.endsWith(".getSucceedingText()")) {
180  154 printer.println("<SUCCEEDING>");
181  310 } else if (last.endsWith(".getLatex()")) {
182  92 printer.println("<TEXT>");
183  218 } else if (last.endsWith(".getDescription()")) {
184  125 if (last.indexOf(".getChangedRuleList().get(") < 0) {
185  109 printer.println("<DESCRIPTION>");
186    }
187    }
188  3164 printer.pushLevel();
189    }
190   
 
191  3164 toggle public void visitLeave(final LatexList latexList) {
192  3164 printer.popLevel();
193  3164 final String last = getCurrentContext().getLocationWithinModule();
194  3164 if (last.endsWith(".getTitle()")) {
195  1156 printer.println("</TITLE>");
196  2008 } else if (last.endsWith(".getSummary()")) {
197  135 printer.println("</ABSTRACT>");
198  1873 } else if (last.endsWith(".getIntroduction()")) {
199  403 printer.println("</INTRODUCTION>");
200  1470 } else if (last.endsWith(".getName()")) {
201  478 printer.println("</NAME>");
202  992 } else if (last.endsWith(".getPrecedingText()")) {
203  528 printer.println("</PRECEDING>");
204  464 } else if (last.endsWith(".getSucceedingText()")) {
205  154 printer.println("</SUCCEEDING>");
206  310 } else if (last.endsWith(".getLatex()")) {
207  92 printer.println("</TEXT>");
208  218 } else if (last.endsWith(".getDescription()")) {
209  125 if (last.indexOf(".getChangedRuleList().get(") < 0) {
210  109 printer.println("</DESCRIPTION>");
211    }
212    }
213    }
214   
 
215  5344 toggle public void visitEnter(final Latex latex) {
216  5344 printer.print("<LATEX");
217  5344 if (latex.getLanguage() != null) {
218  5217 printer.print(" language=\"" + latex.getLanguage() + "\"");
219    }
220  5344 printer.println(">");
221  5344 if (latex.getLatex() != null) {
222  5332 printer.pushLevel();
223  5332 printer.println("<![CDATA[");
224  5332 printer.addToken(" "); // we must fool the printer, this is token not whitespace!
225  5332 final String tabs = printer.getLevel();
226  5332 printer.clearLevel();
227    // escape ]]>
228  5332 final String data = StringUtility.replace(latex.getLatex(),
229    "]]>", "]]]]><![CDATA[>");
230  5332 printer.println(StringUtility.useSystemLineSeparator(data).trim());
231  5332 printer.pushLevel(tabs);
232    }
233    }
234   
 
235  5344 toggle public void visitLeave(final Latex latex) {
236  5344 if (latex.getLatex() != null) {
237  5332 printer.println("]]>");
238  5332 printer.popLevel();
239    }
240  5344 printer.println("</LATEX>");
241    }
242   
 
243  285 toggle public void visitEnter(final LocationList locationList) {
244  285 printer.println("<LOCATIONS>");
245  285 printer.pushLevel();
246    }
247   
 
248  285 toggle public void visitLeave(final LocationList locationList) {
249  285 printer.popLevel();
250  285 printer.println("</LOCATIONS>");
251    }
252   
 
253  322 toggle public void visitEnter(final Location location) {
254  322 printer.print("<LOCATION");
255  322 if (location.getLocation() != null) {
256  322 printer.print(" value=\"" + location.getLocation() + "\"");
257    }
258  322 printer.println(" />");
259    }
260   
 
261  135 toggle public void visitEnter(final AuthorList authorList) {
262  135 printer.println("<AUTHORS>");
263  135 printer.pushLevel();
264    }
265   
 
266  135 toggle public void visitLeave(final AuthorList authorList) {
267  135 printer.popLevel();
268  135 printer.println("</AUTHORS>");
269    }
270   
 
271  135 toggle public void visitEnter(final Author author) {
272  135 printer.print("<AUTHOR");
273  135 if (author.getEmail() != null) {
274  135 printer.print(" email=\"" + StringUtility.escapeXml(author.getEmail()) + "\"");
275    }
276  135 printer.println(">");
277  135 printer.pushLevel();
278  135 if (author.getName() != null) {
279  135 printer.println("<NAME>");
280    }
281  135 printer.pushLevel();
282    }
283   
 
284  135 toggle public void visitLeave(final Author author) {
285  135 printer.popLevel();
286  135 if (author.getName() != null) {
287  135 printer.println("</NAME>");
288    }
289  135 printer.popLevel();
290  135 printer.println("</AUTHOR>");
291    }
292   
 
293  86 toggle public void visitEnter(final ImportList importList) {
294  86 printer.println("<IMPORTS>");
295  86 printer.pushLevel();
296    }
297   
 
298  86 toggle public void visitLeave(final ImportList importList) {
299  86 printer.popLevel();
300  86 printer.println("</IMPORTS>");
301    }
302   
 
303  133 toggle public void visitEnter(final Import imp) {
304  133 printer.print("<IMPORT");
305  133 if (imp.getLabel() != null) {
306  133 printer.print(" label=\"" + StringUtility.escapeXml(imp.getLabel()) + "\"");
307    }
308  133 printer.println(">");
309  133 printer.pushLevel();
310    }
311   
 
312  133 toggle public void visitLeave(final Import imp) {
313  133 printer.popLevel();
314  133 printer.println("</IMPORT>");
315    }
316   
 
317  17 toggle public void visitEnter(final UsedByList usedByList) {
318  17 printer.println("<USEDBY>");
319  17 printer.pushLevel();
320    }
321   
 
322  17 toggle public void visitLeave(final UsedByList usedByList) {
323  17 printer.popLevel();
324  17 printer.println("</USEDBY>");
325    }
326   
 
327  217 toggle public void visitEnter(final Chapter chapter) {
328  217 printer.print("<CHAPTER");
329  217 if (chapter.getNoNumber() != null) {
330  32 printer.print(" noNumber=\"" + chapter.getNoNumber().booleanValue() + "\"");
331    }
332  217 printer.println(">");
333  217 printer.pushLevel();
334    }
335   
 
336  217 toggle public void visitLeave(final Chapter chapter) {
337  217 printer.popLevel();
338  217 printer.println("</CHAPTER>");
339    }
340   
 
341  262 toggle public void visitEnter(final Section section) {
342  262 printer.print("<SECTION");
343  262 if (section.getNoNumber() != null) {
344  0 printer.print(" noNumber=\"" + section.getNoNumber().booleanValue() + "\"");
345    }
346  262 printer.println(">");
347  262 printer.pushLevel();
348    }
349   
 
350  262 toggle public void visitLeave(final Section section) {
351  262 printer.popLevel();
352  262 printer.println("</SECTION>");
353    }
354   
 
355  160 toggle public void visitEnter(final SubsectionList subsectionList) {
356  160 printer.println("<SUBSECTIONS>");
357  160 printer.pushLevel();
358    }
359   
 
360  160 toggle public void visitLeave(final SubsectionList subsectionList) {
361  160 printer.popLevel();
362  160 printer.println("</SUBSECTIONS>");
363    }
364   
 
365  92 toggle public void visitEnter(final Subsection subsection) {
366  92 printer.print("<SUBSECTION");
367  92 if (subsection.getId() != null) {
368  2 printer.print(" id=\"" + StringUtility.escapeXml(subsection.getId()) + "\"");
369    }
370  92 if (subsection.getLevel() != null) {
371  0 printer.print(" level=\"" + StringUtility.escapeXml(subsection.getLevel()) + "\"");
372    }
373  92 printer.println(">");
374  92 printer.pushLevel();
375    }
376   
 
377  92 toggle public void visitLeave(final Subsection subsection) {
378  92 printer.popLevel();
379  92 printer.println("</SUBSECTION>");
380    }
381   
 
382  825 toggle public void visitEnter(final Node node) {
383  825 printer.print("<NODE");
384  825 if (node.getId() != null) {
385  825 printer.print(" id=\"" + StringUtility.escapeXml(node.getId()) + "\"");
386    }
387  825 if (node.getLevel() != null) {
388  360 printer.print(" level=\"" + StringUtility.escapeXml(node.getLevel()) + "\"");
389    }
390  825 printer.println(">");
391  825 printer.pushLevel();
392    }
393   
 
394  825 toggle public void visitLeave(final Node node) {
395  825 printer.popLevel();
396  825 printer.println("</NODE>");
397    }
398   
 
399  195 toggle public void visitEnter(final Axiom axiom) {
400  195 printer.print("<AXIOM");
401  195 if (axiom.getDefinedOperator() != null) {
402  6 printer.print(" definedOperator=\"" + StringUtility.escapeXml(axiom.getDefinedOperator()) + "\"");
403    }
404  195 printer.println(">");
405  195 printer.pushLevel();
406    }
407   
 
408  195 toggle public void visitLeave(final Axiom axiom) {
409  195 printer.popLevel();
410  195 printer.println("</AXIOM>");
411    }
412   
 
413  350 toggle public void visitEnter(final Proposition proposition) {
414  350 printer.println("<THEOREM>");
415  350 printer.pushLevel();
416    }
417   
 
418  350 toggle public void visitLeave(final Proposition proposition) {
419  350 printer.popLevel();
420  350 printer.println("</THEOREM>");
421    }
422   
 
423  59 toggle public void visitEnter(final Proof proof) {
424  59 printer.print("<PROOF");
425  59 if (proof.getKind() != null) {
426  59 printer.print(" kind=\"" + StringUtility.escapeXml(proof.getKind()) + "\"");
427    }
428  59 if (proof.getLevel() != null) {
429  59 printer.print(" level=\"" + StringUtility.escapeXml(proof.getLevel()) + "\"");
430    }
431  59 printer.println(">");
432    }
433   
 
434  59 toggle public void visitLeave(final Proof proof) {
435  59 printer.println("</PROOF>");
436    }
437   
 
438  94 toggle public void visitEnter(final FormalProof proof) {
439  94 printer.println("<FORMAL_PROOF>");
440  94 printer.pushLevel();
441    }
442   
 
443  94 toggle public void visitLeave(final FormalProof proof) {
444  94 printer.popLevel();
445  94 printer.println("</FORMAL_PROOF>");
446    }
447   
 
448  194 toggle public void visitEnter(final FormalProofLineList proof) {
449  194 printer.println("<LINES>");
450  194 printer.pushLevel();
451    }
452   
 
453  194 toggle public void visitLeave(final FormalProofLineList proof) {
454  194 printer.popLevel();
455  194 printer.println("</LINES>");
456    }
457   
 
458  958 toggle public void visitEnter(final FormalProofLine line) {
459  958 printer.print("<L");
460  958 if (line.getLabel() != null) {
461  957 printer.print(" label=\"" + StringUtility.escapeXml(line.getLabel()) + "\"");
462    }
463  958 printer.println(">");
464  958 printer.pushLevel();
465    }
466   
 
467  958 toggle public void visitLeave(final FormalProofLine line) {
468  958 printer.popLevel();
469  958 printer.println("</L>");
470    }
471   
 
472  288 toggle public void visitEnter(final ModusPonens reason) {
473  288 printer.print("<MP");
474  288 if (reason.getReference1() != null) {
475  284 printer.print(" ref1=\"" + StringUtility.escapeXml(reason.getReference1()) + "\"");
476    }
477  288 if (reason.getReference2() != null) {
478  285 printer.print(" ref2=\"" + StringUtility.escapeXml(reason.getReference2()) + "\"");
479    }
480    }
481   
 
482  288 toggle public void visitLeave(final ModusPonens reason) {
483  288 printer.println("/>");
484    }
485   
 
486  216 toggle public void visitEnter(final Add reason) {
487  216 printer.print("<ADD");
488  216 if (reason.getReference() != null) {
489  215 printer.print(" ref=\"" + StringUtility.escapeXml(reason.getReference()) + "\"");
490    }
491    }
492   
 
493  216 toggle public void visitLeave(final Add reason) {
494  216 printer.println("/>");
495    }
496   
 
497  34 toggle public void visitEnter(final Rename reason) {
498  34 printer.print("<RENAME");
499  34 if (reason.getReference() != null) {
500  31 printer.print(" ref=\"" + StringUtility.escapeXml(reason.getReference()) + "\"");
501    }
502  34 if (reason.getOccurrence() != 0) {
503  26 printer.print(" occurrence=\"" + StringUtility.escapeXml("" + reason.getOccurrence()) + "\"");
504    }
505  34 printer.println(">");
506  34 printer.pushLevel();
507    }
508   
 
509  34 toggle public void visitLeave(final Rename reason) {
510  34 printer.popLevel();
511  34 printer.println("</RENAME>");
512    }
513   
 
514  20 toggle public void visitEnter(final SubstFree reason) {
515  20 printer.print("<SUBST_FREE");
516  20 if (reason.getReference() != null) {
517  19 printer.print(" ref=\"" + StringUtility.escapeXml(reason.getReference()) + "\"");
518    }
519  20 printer.println(">");
520  20 printer.pushLevel();
521    }
522   
 
523  20 toggle public void visitLeave(final SubstFree reason) {
524  20 printer.popLevel();
525  20 printer.println("</SUBST_FREE>");
526    }
527   
 
528  6 toggle public void visitEnter(final SubstFunc reason) {
529  6 printer.print("<SUBST_FUNVAR");
530  6 if (reason.getReference() != null) {
531  5 printer.print(" ref=\"" + StringUtility.escapeXml(reason.getReference()) + "\"");
532    }
533  6 printer.println(">");
534  6 printer.pushLevel();
535    }
536   
 
537  6 toggle public void visitLeave(final SubstFunc reason) {
538  6 printer.popLevel();
539  6 printer.println("</SUBST_FUNVAR>");
540    }
541   
 
542  374 toggle public void visitEnter(final SubstPred reason) {
543  374 printer.print("<SUBST_PREDVAR");
544  374 if (reason.getReference() != null) {
545  366 printer.print(" ref=\"" + StringUtility.escapeXml(reason.getReference()) + "\"");
546    }
547  374 printer.println(">");
548  374 printer.pushLevel();
549    }
550   
 
551  374 toggle public void visitLeave(final SubstPred reason) {
552  374 printer.popLevel();
553  374 printer.println("</SUBST_PREDVAR>");
554    }
555   
 
556  4 toggle public void visitEnter(final Existential reason) {
557  4 printer.print("<EXISTENTIAL");
558  4 if (reason.getReference() != null) {
559  4 printer.print(" ref=\"" + StringUtility.escapeXml(reason.getReference()) + "\"");
560    }
561  4 printer.println(">");
562  4 printer.pushLevel();
563    }
564   
 
565  4 toggle public void visitLeave(final Existential reason) {
566  4 printer.popLevel();
567  4 printer.println("</EXISTENTIAL>");
568    }
569   
 
570  16 toggle public void visitEnter(final Universal reason) {
571  16 printer.print("<UNIVERSAL");
572  16 if (reason.getReference() != null) {
573  15 printer.print(" ref=\"" + StringUtility.escapeXml(reason.getReference()) + "\"");
574    }
575  16 printer.println(">");
576  16 printer.pushLevel();
577    }
578   
 
579  16 toggle public void visitLeave(final Universal reason) {
580  16 printer.popLevel();
581  16 printer.println("</UNIVERSAL>");
582    }
583   
 
584  100 toggle public void visitEnter(final ConditionalProof reason) {
585  100 printer.println("<CP>");
586  100 printer.pushLevel();
587    }
588   
 
589  100 toggle public void visitLeave(final ConditionalProof reason) {
590  100 printer.popLevel();
591  100 printer.println("</CP>");
592    }
593   
 
594  100 toggle public void visitEnter(final Hypothesis hypothesis) {
595  100 printer.print("<HYPOTHESIS");
596  100 if (hypothesis.getLabel() != null) {
597  100 printer.print(" label=\"" + StringUtility.escapeXml(hypothesis.getLabel()) + "\"");
598    }
599  100 printer.println(">");
600  100 printer.pushLevel();
601    }
602   
 
603  100 toggle public void visitLeave(final Hypothesis hypothesis) {
604  100 printer.popLevel();
605  100 printer.println("</HYPOTHESIS>");
606    }
607   
 
608  100 toggle public void visitEnter(final Conclusion conclusion) {
609  100 printer.print("<CONCLUSION");
610  100 if (conclusion.getLabel() != null) {
611  100 printer.print(" label=\"" + StringUtility.escapeXml(conclusion.getLabel()) + "\"");
612    }
613  100 printer.println(">");
614  100 printer.pushLevel();
615    }
616   
 
617  100 toggle public void visitLeave(final Conclusion conclusion) {
618  100 printer.popLevel();
619  100 printer.println("</CONCLUSION>");
620    }
621   
 
622  50 toggle public void visitEnter(final InitialPredicateDefinition definition) {
623  50 printer.print("<DEFINITION_PREDICATE_INITIAL");
624  50 if (definition.getArgumentNumber() != null) {
625  50 printer.print(" arguments=\"" + StringUtility.escapeXml(definition.getArgumentNumber()) + "\"");
626    }
627  50 if (definition.getName() != null) {
628  50 printer.print(" name=\"" + StringUtility.escapeXml(definition.getName()) + "\"");
629    }
630  50 printer.println(">");
631  50 printer.pushLevel();
632  50 if (definition.getLatexPattern() != null) {
633  50 printer.println("<LATEXPATTERN>" + StringUtility.escapeXml(definition.getLatexPattern())
634    + "</LATEXPATTERN>");
635    }
636    }
637   
 
638  50 toggle public void visitLeave(final InitialPredicateDefinition definition) {
639  50 printer.popLevel();
640  50 printer.println("</DEFINITION_PREDICATE_INITIAL>");
641    }
642   
 
643  55 toggle public void visitEnter(final PredicateDefinition definition) {
644  55 printer.print("<DEFINITION_PREDICATE");
645  55 if (definition.getArgumentNumber() != null) {
646  55 printer.print(" arguments=\"" + StringUtility.escapeXml(definition.getArgumentNumber()) + "\"");
647    }
648  55 if (definition.getName() != null) {
649  55 printer.print(" name=\"" + StringUtility.escapeXml(definition.getName()) + "\"");
650    }
651  55 printer.println(">");
652  55 printer.pushLevel();
653  55 if (definition.getLatexPattern() != null) {
654  55 printer.println("<LATEXPATTERN>" + StringUtility.escapeXml(definition.getLatexPattern())
655    + "</LATEXPATTERN>");
656    }
657    }
658   
 
659  55 toggle public void visitLeave(final PredicateDefinition definition) {
660  55 printer.popLevel();
661  55 printer.println("</DEFINITION_PREDICATE>");
662    }
663   
 
664  1 toggle public void visitEnter(final InitialFunctionDefinition definition) {
665  1 printer.print("<DEFINITION_FUNCTION_INITIAL");
666  1 if (definition.getArgumentNumber() != null) {
667  1 printer.print(" arguments=\"" + StringUtility.escapeXml(definition.getArgumentNumber()) + "\"");
668    }
669  1 if (definition.getName() != null) {
670  1 printer.print(" name=\"" + StringUtility.escapeXml(definition.getName()) + "\"");
671    }
672  1 printer.println(">");
673  1 printer.pushLevel();
674  1 if (definition.getLatexPattern() != null) {
675  1 printer.println("<LATEXPATTERN>" + definition.getLatexPattern()
676    + "</LATEXPATTERN>");
677    }
678    }
679   
 
680  1 toggle public void visitLeave(final InitialFunctionDefinition definition) {
681  1 printer.popLevel();
682  1 printer.println("</DEFINITION_FUNCTION_INITIAL>");
683    }
684   
 
685  69 toggle public void visitEnter(final FunctionDefinition definition) {
686  69 printer.print("<DEFINITION_FUNCTION");
687  69 if (definition.getArgumentNumber() != null) {
688  69 printer.print(" arguments=\"" + StringUtility.escapeXml(definition.getArgumentNumber()) + "\"");
689    }
690  69 if (definition.getName() != null) {
691  69 printer.print(" name=\"" + StringUtility.escapeXml(definition.getName()) + "\"");
692    }
693  69 printer.println(">");
694  69 printer.pushLevel();
695  69 if (definition.getLatexPattern() != null) {
696  69 printer.println("<LATEXPATTERN>" + definition.getLatexPattern()
697    + "</LATEXPATTERN>");
698    }
699    }
700   
 
701  69 toggle public void visitLeave(final FunctionDefinition definition) {
702  69 printer.popLevel();
703  69 printer.println("</DEFINITION_FUNCTION>");
704    }
705   
 
706  105 toggle public void visitEnter(final Rule rule) {
707  105 printer.print("<RULE");
708  105 if (rule.getName() != null) {
709  105 printer.print(" name=\"" + StringUtility.escapeXml(rule.getName()) + "\"");
710    }
711  105 if (rule.getVersion() != null) {
712  105 printer.print(" version=\"" + StringUtility.escapeXml(rule.getVersion()) + "\"");
713    }
714  105 printer.println(">");
715  105 printer.pushLevel();
716    }
717   
 
718  105 toggle public void visitLeave(final Rule rule) {
719  105 printer.popLevel();
720  105 printer.println("</RULE>");
721    }
722   
 
723  19 toggle public void visitEnter(final LinkList linkList) {
724  40 for (int i = 0; i < linkList.size(); i++) {
725  21 printer.print("<LINK");
726  21 if (linkList.get(i) != null) {
727  21 printer.print(" id=\"" + StringUtility.escapeXml(linkList.get(i)) + "\"");
728    }
729  21 printer.println("/>");
730  19 };
731    }
732   
 
733  16 toggle public void visitEnter(final ChangedRule rule) {
734  16 printer.print("<CHANGED_RULE");
735  16 if (rule.getName() != null) {
736  16 printer.print(" name=\"" + StringUtility.escapeXml(rule.getName()) + "\"");
737    }
738  16 if (rule.getVersion() != null) {
739  16 printer.print(" version=\"" + StringUtility.escapeXml(rule.getVersion()) + "\"");
740    }
741  16 printer.println(">");
742    }
743   
 
744  16 toggle public void visitLeave(final ChangedRule rule) {
745  16 printer.println("</CHANGED_RULE>");
746    }
747   
 
748  2192 toggle public void visitEnter(final Formula formula) {
749  2192 printer.println("<FORMULA>");
750  2192 printer.pushLevel();
751    }
752   
 
753  2192 toggle public void visitLeave(final Formula formula) {
754  2192 printer.popLevel();
755  2192 printer.println("</FORMULA>");
756    }
757   
 
758  24 toggle public void visitEnter(final Term term) {
759  24 printer.println("<TERM>");
760  24 printer.pushLevel();
761    }
762   
 
763  24 toggle public void visitLeave(final Term term) {
764  24 printer.popLevel();
765  24 printer.println("</TERM>");
766    }
767   
768    // TODO mime 20070217: what do we do if an atom is not first element of a list?
769    // we wouldn't get it here!!! But can we think of an output syntax anyway????
 
770  21208 toggle public void visitEnter(final ElementList list) {
771  21208 final String operator = list.getOperator();
772  21208 printer.print("<" + operator);
773  21208 final boolean firstIsAtom = list.size() > 0 && list.getElement(0).isAtom();
774  21208 if (firstIsAtom) {
775  14551 final String atom = list.getElement(0).getAtom().getString();
776  14551 if (atom != null) {
777  14551 if ("VAR".equals(operator) || "PREDVAR".equals(operator)
778    || "FUNVAR".equals(operator)) {
779  11876 printer.print(" id=\"" + StringUtility.escapeXml(atom) + "\"");
780  2675 } else if ("PREDCON".equals(operator) || "FUNCON".equals(operator)) {
781  2675 printer.print(" ref=\"" + StringUtility.escapeXml(atom) + "\"");
782    } else {
783  0 printer.print(" unknown=\"" + StringUtility.escapeXml(atom) + "\"");
784    }
785    }
786    }
787  21208 if (list.size() == 0 || list.size() == 1 && list.getElement(0).isAtom()) {
788  11204 printer.print("/");
789    }
790  21208 printer.println(">");
791  21208 printer.pushLevel();
792    }
793   
 
794  21208 toggle public void visitLeave(final ElementList list) {
795  21208 printer.popLevel();
796  21208 if (list.size() == 0 || list.size() == 1 && list.getElement(0).isAtom()) {
797  11204 return;
798    }
799  10004 printer.println("</" + list.getOperator() + ">");
800    }
801   
 
802  10 toggle public void visitEnter(final LiteratureItemList list) {
803  10 printer.println("<BIBLIOGRAPHY>");
804  10 printer.pushLevel();
805    }
806   
 
807  10 toggle public void visitLeave(final LiteratureItemList list) {
808  10 printer.popLevel();
809  10 printer.println("</BIBLIOGRAPHY>");
810    }
811   
 
812  34 toggle public void visitEnter(final LiteratureItem item) {
813  34 printer.print("<ITEM");
814  34 if (item.getLabel() != null) {
815  34 printer.print(" label=\"" + StringUtility.escapeXml(item.getLabel()) + "\"");
816    }
817  34 printer.println(">");
818  34 printer.pushLevel();
819    }
820   
 
821  34 toggle public void visitLeave(final LiteratureItem item) {
822  34 printer.popLevel();
823  34 printer.println("</ITEM>");
824    }
825   
 
826  0 toggle public String getServiceId() {
827  0 return this.getClass().getName();
828    }
829   
 
830  0 toggle public String getServiceAction() {
831  0 return "generate XML";
832    }
833   
 
834  0 toggle public String getServiceDescription() {
835  0 return "Transformes QEDEQ module into XML data";
836    }
837   
838    }