Clover Coverage Report
Coverage timestamp: Fri May 24 2013 13:47:27 UTC
../../../../../img/srcFileCovDistChart9.png 45% of files have more coverage
374   838   179   3.94
154   696   0.48   95
95     1.88  
1    
 
  Qedeq2Xml       Line # 81 374 179 89.9% 0.8988764
 
  (1)
 
1    /* This file is part of the project "Hilbert II" - http://www.qedeq.org
2    *
3    * Copyright 2000-2013, 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.ControlVisitor;
24    import org.qedeq.kernel.bo.module.InternalServiceProcess;
25    import org.qedeq.kernel.bo.module.KernelQedeqBo;
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.Plugin;
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 Plugin {
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  132 toggle public Qedeq2Xml(final Plugin plugin, final KernelQedeqBo bo, final TextOutput printer) {
94  132 super(plugin, bo);
95  132 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  132 toggle public static void print(final InternalServiceProcess process,
109    final Plugin plugin, final KernelQedeqBo bo, final TextOutput printer) throws
110    SourceFileExceptionList, IOException {
111  132 final Qedeq2Xml converter = new Qedeq2Xml(plugin, bo, printer);
112  132 try {
113  132 converter.traverse(process);
114    } finally {
115  132 printer.flush();
116    }
117  132 if (printer.checkError()) {
118  0 throw printer.getError();
119    }
120    }
121   
 
122  132 toggle public final void visitEnter(final Qedeq qedeq) {
123  132 printer.println("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
124  132 printer.println("<QEDEQ");
125  132 printer.println(" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"");
126  132 printer.println(" xsi:noNamespaceSchemaLocation=\"http://www.qedeq.org/"
127    + KernelContext.getInstance().getKernelVersionDirectory() + "/xml/qedeq.xsd\">");
128  132 printer.pushLevel();
129    }
130   
 
131  132 toggle public final void visitLeave(final Qedeq qedeq) {
132  132 printer.popLevel();
133  132 printer.println("</QEDEQ>");
134    }
135   
 
136  132 toggle public void visitEnter(final Header header) {
137  132 printer.print("<HEADER");
138  132 if (header.getEmail() != null) {
139  132 printer.print(" email=\"" + StringUtility.escapeXml(header.getEmail()) + "\"");
140    }
141  132 printer.println(">");
142  132 printer.pushLevel();
143    }
144   
 
145  132 toggle public void visitLeave(final Header header) {
146  132 printer.popLevel();
147  132 printer.println("</HEADER>");
148    }
149   
 
150  280 toggle public void visitEnter(final Specification specification) {
151  280 printer.print("<SPECIFICATION");
152  280 if (specification.getName() != null) {
153  280 printer.print(" name=\"" + StringUtility.escapeXml(specification.getName()) + "\"");
154    }
155  280 if (specification.getName() != null) {
156  280 printer.print(" ruleVersion=\"" + StringUtility.escapeXml(specification.getRuleVersion()) + "\"");
157    }
158  280 printer.println(">");
159  280 printer.pushLevel();
160    }
161   
 
162  280 toggle public void visitLeave(final Specification specification) {
163  280 printer.popLevel();
164  280 printer.println("</SPECIFICATION>");
165    }
166   
 
167  3144 toggle public void visitEnter(final LatexList latexList) {
168  3144 final String last = getCurrentContext().getLocationWithinModule();
169  3144 if (last.endsWith(".getTitle()")) {
170  1145 printer.println("<TITLE>");
171  1999 } else if (last.endsWith(".getSummary()")) {
172  132 printer.println("<ABSTRACT>");
173  1867 } else if (last.endsWith(".getIntroduction()")) {
174  403 printer.println("<INTRODUCTION>");
175  1464 } else if (last.endsWith(".getName()")) {
176  474 printer.println("<NAME>");
177  990 } else if (last.endsWith(".getPrecedingText()")) {
178  528 printer.println("<PRECEDING>");
179  462 } else if (last.endsWith(".getSucceedingText()")) {
180  154 printer.println("<SUCCEEDING>");
181  308 } else if (last.endsWith(".getLatex()")) {
182  92 printer.println("<TEXT>");
183  216 } else if (last.endsWith(".getDescription()")) {
184  123 if (last.indexOf(".getChangedRuleList().get(") < 0) {
185  107 printer.println("<DESCRIPTION>");
186    }
187    }
188  3144 printer.pushLevel();
189    }
190   
 
191  3144 toggle public void visitLeave(final LatexList latexList) {
192  3144 printer.popLevel();
193  3144 final String last = getCurrentContext().getLocationWithinModule();
194  3144 if (last.endsWith(".getTitle()")) {
195  1145 printer.println("</TITLE>");
196  1999 } else if (last.endsWith(".getSummary()")) {
197  132 printer.println("</ABSTRACT>");
198  1867 } else if (last.endsWith(".getIntroduction()")) {
199  403 printer.println("</INTRODUCTION>");
200  1464 } else if (last.endsWith(".getName()")) {
201  474 printer.println("</NAME>");
202  990 } else if (last.endsWith(".getPrecedingText()")) {
203  528 printer.println("</PRECEDING>");
204  462 } else if (last.endsWith(".getSucceedingText()")) {
205  154 printer.println("</SUCCEEDING>");
206  308 } else if (last.endsWith(".getLatex()")) {
207  92 printer.println("</TEXT>");
208  216 } else if (last.endsWith(".getDescription()")) {
209  123 if (last.indexOf(".getChangedRuleList().get(") < 0) {
210  107 printer.println("</DESCRIPTION>");
211    }
212    }
213    }
214   
 
215  5321 toggle public void visitEnter(final Latex latex) {
216  5321 printer.print("<LATEX");
217  5321 if (latex.getLanguage() != null) {
218  5194 printer.print(" language=\"" + latex.getLanguage() + "\"");
219    }
220  5321 printer.println(">");
221  5321 if (latex.getLatex() != null) {
222  5309 printer.pushLevel();
223  5309 printer.println("<![CDATA[");
224  5309 printer.addToken(" "); // we must fool the printer, this is token not whitespace!
225  5309 final String tabs = printer.getLevel();
226  5309 printer.clearLevel();
227    // escape ]]>
228  5309 final String data = StringUtility.replace(latex.getLatex(),
229    "]]>", "]]]]><![CDATA[>");
230  5309 printer.println(StringUtility.useSystemLineSeparator(data).trim());
231  5309 printer.pushLevel(tabs);
232    }
233    }
234   
 
235  5321 toggle public void visitLeave(final Latex latex) {
236  5321 if (latex.getLatex() != null) {
237  5309 printer.println("]]>");
238  5309 printer.popLevel();
239    }
240  5321 printer.println("</LATEX>");
241    }
242   
 
243  280 toggle public void visitEnter(final LocationList locationList) {
244  280 printer.println("<LOCATIONS>");
245  280 printer.pushLevel();
246    }
247   
 
248  280 toggle public void visitLeave(final LocationList locationList) {
249  280 printer.popLevel();
250  280 printer.println("</LOCATIONS>");
251    }
252   
 
253  317 toggle public void visitEnter(final Location location) {
254  317 printer.print("<LOCATION");
255  317 if (location.getLocation() != null) {
256  317 printer.print(" value=\"" + location.getLocation() + "\"");
257    }
258  317 printer.println(" />");
259    }
260   
 
261  132 toggle public void visitEnter(final AuthorList authorList) {
262  132 printer.println("<AUTHORS>");
263  132 printer.pushLevel();
264    }
265   
 
266  132 toggle public void visitLeave(final AuthorList authorList) {
267  132 printer.popLevel();
268  132 printer.println("</AUTHORS>");
269    }
270   
 
271  132 toggle public void visitEnter(final Author author) {
272  132 printer.print("<AUTHOR");
273  132 if (author.getEmail() != null) {
274  132 printer.print(" email=\"" + StringUtility.escapeXml(author.getEmail()) + "\"");
275    }
276  132 printer.println(">");
277  132 printer.pushLevel();
278  132 if (author.getName() != null) {
279  132 printer.println("<NAME>");
280    }
281  132 printer.pushLevel();
282    }
283   
 
284  132 toggle public void visitLeave(final Author author) {
285  132 printer.popLevel();
286  132 if (author.getName() != null) {
287  132 printer.println("</NAME>");
288    }
289  132 printer.popLevel();
290  132 printer.println("</AUTHOR>");
291    }
292   
 
293  84 toggle public void visitEnter(final ImportList importList) {
294  84 printer.println("<IMPORTS>");
295  84 printer.pushLevel();
296    }
297   
 
298  84 toggle public void visitLeave(final ImportList importList) {
299  84 printer.popLevel();
300  84 printer.println("</IMPORTS>");
301    }
302   
 
303  131 toggle public void visitEnter(final Import imp) {
304  131 printer.print("<IMPORT");
305  131 if (imp.getLabel() != null) {
306  131 printer.print(" label=\"" + StringUtility.escapeXml(imp.getLabel()) + "\"");
307    }
308  131 printer.println(">");
309  131 printer.pushLevel();
310    }
311   
 
312  131 toggle public void visitLeave(final Import imp) {
313  131 printer.popLevel();
314  131 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  214 toggle public void visitEnter(final Chapter chapter) {
328  214 printer.print("<CHAPTER");
329  214 if (chapter.getNoNumber() != null) {
330  32 printer.print(" noNumber=\"" + chapter.getNoNumber().booleanValue() + "\"");
331    }
332  214 printer.println(">");
333  214 printer.pushLevel();
334    }
335   
 
336  214 toggle public void visitLeave(final Chapter chapter) {
337  214 printer.popLevel();
338  214 printer.println("</CHAPTER>");
339    }
340   
 
341  261 toggle public void visitEnter(final Section section) {
342  261 printer.print("<SECTION");
343  261 if (section.getNoNumber() != null) {
344  0 printer.print(" noNumber=\"" + section.getNoNumber().booleanValue() + "\"");
345    }
346  261 printer.println(">");
347  261 printer.pushLevel();
348    }
349   
 
350  261 toggle public void visitLeave(final Section section) {
351  261 printer.popLevel();
352  261 printer.println("</SECTION>");
353    }
354   
 
355  159 toggle public void visitEnter(final SubsectionList subsectionList) {
356  159 printer.println("<SUBSECTIONS>");
357  159 printer.pushLevel();
358    }
359   
 
360  159 toggle public void visitLeave(final SubsectionList subsectionList) {
361  159 printer.popLevel();
362  159 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  821 toggle public void visitEnter(final Node node) {
383  821 printer.print("<NODE");
384  821 if (node.getId() != null) {
385  821 printer.print(" id=\"" + StringUtility.escapeXml(node.getId()) + "\"");
386    }
387  821 if (node.getLevel() != null) {
388  360 printer.print(" level=\"" + StringUtility.escapeXml(node.getLevel()) + "\"");
389    }
390  821 printer.println(">");
391  821 printer.pushLevel();
392    }
393   
 
394  821 toggle public void visitLeave(final Node node) {
395  821 printer.popLevel();
396  821 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  49 toggle public void visitEnter(final InitialPredicateDefinition definition) {
623  49 printer.print("<DEFINITION_PREDICATE_INITIAL");
624  49 if (definition.getArgumentNumber() != null) {
625  49 printer.print(" arguments=\"" + StringUtility.escapeXml(definition.getArgumentNumber()) + "\"");
626    }
627  49 if (definition.getName() != null) {
628  49 printer.print(" name=\"" + StringUtility.escapeXml(definition.getName()) + "\"");
629    }
630  49 printer.println(">");
631  49 printer.pushLevel();
632  49 if (definition.getLatexPattern() != null) {
633  49 printer.println("<LATEXPATTERN>" + StringUtility.escapeXml(definition.getLatexPattern())
634    + "</LATEXPATTERN>");
635    }
636    }
637   
 
638  49 toggle public void visitLeave(final InitialPredicateDefinition definition) {
639  49 printer.popLevel();
640  49 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  0 toggle public void visitEnter(final InitialFunctionDefinition definition) {
665  0 printer.print("<DEFINITION_FUNCTION_INITIAL");
666  0 if (definition.getArgumentNumber() != null) {
667  0 printer.print(" arguments=\"" + StringUtility.escapeXml(definition.getArgumentNumber()) + "\"");
668    }
669  0 if (definition.getName() != null) {
670  0 printer.print(" name=\"" + StringUtility.escapeXml(definition.getName()) + "\"");
671    }
672  0 printer.println(">");
673  0 printer.pushLevel();
674  0 if (definition.getLatexPattern() != null) {
675  0 printer.println("<LATEXPATTERN>" + definition.getLatexPattern()
676    + "</LATEXPATTERN>");
677    }
678    }
679   
 
680  0 toggle public void visitLeave(final InitialFunctionDefinition definition) {
681  0 printer.popLevel();
682  0 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  103 toggle public void visitEnter(final Rule rule) {
707  103 printer.print("<RULE");
708  103 if (rule.getName() != null) {
709  103 printer.print(" name=\"" + StringUtility.escapeXml(rule.getName()) + "\"");
710    }
711  103 if (rule.getVersion() != null) {
712  103 printer.print(" version=\"" + StringUtility.escapeXml(rule.getVersion()) + "\"");
713    }
714  103 printer.println(">");
715  103 printer.pushLevel();
716    }
717   
 
718  103 toggle public void visitLeave(final Rule rule) {
719  103 printer.popLevel();
720  103 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  21202 toggle public void visitEnter(final ElementList list) {
771  21202 final String operator = list.getOperator();
772  21202 printer.print("<" + operator);
773  21202 final boolean firstIsAtom = list.size() > 0 && list.getElement(0).isAtom();
774  21202 if (firstIsAtom) {
775  14545 final String atom = list.getElement(0).getAtom().getString();
776  14545 if (atom != null) {
777  14545 if ("VAR".equals(operator) || "PREDVAR".equals(operator)
778    || "FUNVAR".equals(operator)) {
779  11872 printer.print(" id=\"" + StringUtility.escapeXml(atom) + "\"");
780  2673 } else if ("PREDCON".equals(operator) || "FUNCON".equals(operator)) {
781  2673 printer.print(" ref=\"" + StringUtility.escapeXml(atom) + "\"");
782    } else {
783  0 printer.print(" unknown=\"" + StringUtility.escapeXml(atom) + "\"");
784    }
785    }
786    }
787  21202 if (list.size() == 0 || list.size() == 1 && list.getElement(0).isAtom()) {
788  11200 printer.print("/");
789    }
790  21202 printer.println(">");
791  21202 printer.pushLevel();
792    }
793   
 
794  21202 toggle public void visitLeave(final ElementList list) {
795  21202 printer.popLevel();
796  21202 if (list.size() == 0 || list.size() == 1 && list.getElement(0).isAtom()) {
797  11200 return;
798    }
799  10002 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    }