KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > opencms > htmlconverter > CmsHtmlConverterConfig


1 /*
2 * File : $Source: /usr/local/cvs/opencms/src-modules/com/opencms/htmlconverter/CmsHtmlConverterConfig.java,v $
3 * Date : $Date: 2006/03/27 14:53:04 $
4 * Version: $Revision: 1.3 $
5 *
6 * This library is part of OpenCms -
7 * the Open Source Content Mananagement System
8 *
9 * Copyright (C) 2001 The OpenCms Group
10 *
11 * This library is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU Lesser General Public
13 * License as published by the Free Software Foundation; either
14 * version 2.1 of the License, or (at your option) any later version.
15 *
16 * This library is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 * Lesser General Public License for more details.
20 *
21 * For further information about OpenCms, please see the
22 * OpenCms Website: http://www.opencms.org
23 *
24 * You should have received a copy of the GNU Lesser General Public
25 * License along with this library; if not, write to the Free Software
26 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
27 */

28
29 package com.opencms.htmlconverter;
30
31 import org.opencms.util.CmsStringUtil;
32
33 import java.io.ByteArrayInputStream JavaDoc;
34 import java.io.InputStream JavaDoc;
35 import java.util.ArrayList JavaDoc;
36 import java.util.HashSet JavaDoc;
37 import java.util.StringTokenizer JavaDoc;
38
39 import org.w3c.dom.Document JavaDoc;
40 import org.w3c.dom.NamedNodeMap JavaDoc;
41 import org.w3c.dom.Node JavaDoc;
42 import org.w3c.dom.NodeList JavaDoc;
43 import org.w3c.tidy.Tidy;
44
45 /**
46  * Configuration class for CmsHtmlConverter, user defined configuration
47  * is parsed and used by CmsHtmlConverter.
48  * @author Andreas Zahner
49  * @version 0.6
50  *
51  * @deprecated Will not be supported past the OpenCms 6 release.
52  */

53 final class CmsHtmlConverterConfig {
54
55     /** Comment node in xml-configuration. */
56     private static final int C_COMMENT_NODE = 0;
57     /** "ConverterConfig" node in xml-configuration. */
58     private static final int C_CONFIG_NODE = 1;
59     /** "defaults" node in xml-configuration. */
60     private static final int C_DEFAULT_NODE = 10;
61     /** "replacecontent" node in xml-configuration. */
62     private static final int C_REPLACECONTENT_NODE = 11;
63     /** "inlinetags" node in xml-configuration. */
64     private static final int C_INLINETAG_NODE = 12;
65     /** "removetags" node in xml-configuration. */
66     private static final int C_REMOVETAG_NODE = 13;
67     /** "removeblocks" node in xml-configuration. */
68     private static final int C_REMOVEBLOCK_NODE = 14;
69     /** "replacetags" node in xml-configuration. */
70     private static final int C_REPLACETAG_NODE = 15;
71     /** "replaceblocks" node in xml-configuration. */
72     private static final int C_REPLACEBLOCK_NODE = 16;
73     /** "replacestrings" node in xml-configuration. */
74     private static final int C_REPLACESTRING_NODE = 17;
75
76     /** "xhtmloutput" node in defaults: xml-configuration. */
77     private static final int C_XHTMLOUTPUT_NODE = 20;
78     /** "globalprefix" node in defaults: xml-configuration. */
79     private static final int C_GLOBALPREFIX_NODE = 21;
80     /** "globalsuffix" node in defaults: xml-configuration. */
81     private static final int C_GLOBALSUFFIX_NODE = 22;
82     /** "globaladdeveryline" node in defaults: xml-configuration. */
83     private static final int C_GLOBALADDEVERYLINE_NODE = 23;
84     /** "usebrackets" node in defaults: xml-configuration. */
85     private static final int C_USEBRACKETS_NODE = 24;
86     /** "encodequotationmarks" node in defaults: xml-configuration. */
87     private static final int C_ENCODEQUOTATIONMARKS_NODE = 25;
88
89     /** "addeveryline" node in replacenodes: xml-configuration. */
90     private static final int C_ADDEVERYLINE_NODE = 30;
91     /** "prefix" node in replacenodes: xml-configuration. */
92     private static final int C_PREFIX_NODE = 31;
93     /** "suffix" node in replacenodes: xml-configuration. */
94     private static final int C_SUFFIX_NODE = 32;
95     /** "tag" node in replacenodes: xml-configuration. */
96     private static final int C_TAG_NODE = 33;
97     /** "string" node in replacenodes: xml-configuration. */
98     private static final int C_STRING_NODE = 34;
99
100     /** check if output has to be XHTML. */
101     private boolean m_xhtmlOutput;
102     /** stores global prefix. */
103     private String JavaDoc m_globalPrefix = "";
104     /** stores global suffix. */
105     private String JavaDoc m_globalSuffix = "";
106     /** check if prefix and suffix have to be added to every new line. */
107     private boolean m_globalAddEveryLine;
108     /** code for html bracket "<". */
109     private String JavaDoc m_openBracket = "";
110     /** code for html bracket ">". */
111     private String JavaDoc m_closeBracket = "";
112     /** check if brackets are used. */
113     private boolean m_useBrackets;
114     /** check if quotationmarks must be encoded. */
115     private boolean m_encodeQuotationmarks;
116     /** stores code for quotationmarks. */
117     private String JavaDoc m_quotationmark = "";
118     /** stores prefix for replacetags. */
119     private String JavaDoc m_replaceTagsPrefix = "";
120     /** stores suffix for replacetags. */
121     private String JavaDoc m_replaceTagsSuffix = "";
122     /** check if replaced content needs new lines. */
123     private boolean m_replaceTagsAddEveryLine;
124     /** check if default values are used. */
125     private boolean m_replaceTagsUseDefaults;
126
127     /** stores prefix for replaceblocks. */
128     private String JavaDoc m_replaceBlocksPrefix = "";
129     /** stores suffix for replaceblocks. */
130     private String JavaDoc m_replaceBlocksSuffix = "";
131     /** check if replaced content needs new lines. */
132     private boolean m_replaceBlocksAddEveryLine;
133     /** check if default values are used. */
134     private boolean m_replaceBlocksUseDefaults;
135
136     /** stores prefix for replacestrings. */
137     private String JavaDoc m_replaceStringsPrefix = "";
138     /** stores suffix for replacestrings. */
139     private String JavaDoc m_replaceStringsSuffix = "";
140     /** check if replaced content needs new lines. */
141     private boolean m_replaceStringsAddEveryLine;
142     /** check if default values are used. */
143     private boolean m_replaceStringsUseDefaults;
144
145     /** list with objects which will be replaced in run #1. */
146     private ArrayList JavaDoc m_replaceContent = new ArrayList JavaDoc();
147     /** list with tags to be removed. */
148     private HashSet JavaDoc m_removeTags = new HashSet JavaDoc();
149     /** list with blocks to be removed. */
150     private HashSet JavaDoc m_removeBlocks = new HashSet JavaDoc();
151     /** list with all inline tags. */
152     private HashSet JavaDoc m_inlineTags = new HashSet JavaDoc();
153     /** list with extended chars which are replaced in text nodes. */
154     private ArrayList JavaDoc m_replaceExtendedChars = new ArrayList JavaDoc();
155     /** list with Strings whihch are replaced. */
156     private ArrayList JavaDoc m_replaceStrings = new ArrayList JavaDoc();
157     /** list with tags which are replaced. */
158     private ArrayList JavaDoc m_replaceTags = new ArrayList JavaDoc();
159     /** list with blocks which are replaced. */
160     private ArrayList JavaDoc m_replaceBlocks = new ArrayList JavaDoc();
161
162     /** temporary list of replacecontent. */
163     private ArrayList JavaDoc m_tempReplaceContent = new ArrayList JavaDoc();
164     /** temporary list of replacestrings. */
165     private ArrayList JavaDoc m_tempReplaceStrings = new ArrayList JavaDoc();
166     /** temporary list of replacetags. */
167     private ArrayList JavaDoc m_tempReplaceTags = new ArrayList JavaDoc();
168     /** temporary list of replaceblocks. */
169     private ArrayList JavaDoc m_tempReplaceBlocks = new ArrayList JavaDoc();
170
171     /** instance of CmsHtmlConverterTools. */
172     private CmsHtmlConverterTools m_tools = new CmsHtmlConverterTools();
173
174     /** to check if instance has already been configured. */
175     private boolean m_isConfigured;
176
177     /**
178      * Default constructor.<p>
179      */

180     protected CmsHtmlConverterConfig() {
181         // empty
182
}
183
184     /**
185      * Creates configuration from String.<p>
186      *
187      * @param confString String with XML configuration
188      */

189     protected CmsHtmlConverterConfig(String JavaDoc confString) {
190         init(confString);
191     }
192
193     /**
194      * Creates configuration from InputStream.<p>
195      *
196      * @param in InputStream with XML configuration
197      */

198     protected CmsHtmlConverterConfig(InputStream JavaDoc in) {
199         init(in);
200     }
201
202     /**
203      * Returns all tags which are removed from html input.<p>
204      *
205      * @return HashSet with tags
206      */

207     protected HashSet JavaDoc getRemoveTags() {
208         return m_removeTags;
209     }
210
211     /**
212      * Returns all blocks which are removed from html input.<p>
213      *
214      * @return HashSet with blocks
215      */

216     protected HashSet JavaDoc getRemoveBlocks() {
217         return m_removeBlocks;
218     }
219
220     /**
221      * Returns all inline tags defined in configuration.<p>
222      *
223      * @return HashSet with inline tags
224      */

225     protected HashSet JavaDoc getInlineTags() {
226         return m_inlineTags;
227     }
228
229     /**
230      * Returns all Strings which are replaced in run #1.<p>
231      *
232      * @return ArrayList with CmsHtmlConverterObjectReplaceContent
233      */

234     protected ArrayList JavaDoc getReplaceContent() {
235         return m_replaceContent;
236     }
237
238     /**
239      * Returns extended characters which are replaced in text nodes.<p>
240      *
241      * @return ArrayList with CmsHtmlConverterObjectReplaceExtendedChars
242      */

243     protected ArrayList JavaDoc getReplaceExtendedChars() {
244         return m_replaceExtendedChars;
245     }
246
247     /**
248      * Returns all Strings which are replaced in run #2.<p>
249      *
250      * @return ArrayList with CmsHtmlConverterObjectReplaceStrings
251      */

252     protected ArrayList JavaDoc getReplaceStrings() {
253         return m_replaceStrings;
254     }
255
256     /**
257      * Returns all tags which are replaced in html input.<p>
258      *
259      * @return ArrayList with CmsHtmlConverterObjectReplaceTags
260      */

261     protected ArrayList JavaDoc getReplaceTags() {
262         return m_replaceTags;
263     }
264
265     /**
266      * Returns all Blocks which are replaced in html input.<p>
267      *
268      * @return ArrayList with CmsHtmlConverterObjectReplaceBlocks
269      */

270     protected ArrayList JavaDoc getReplaceBlocks() {
271         return m_replaceBlocks;
272     }
273
274     /**
275      * Returns boolean if output is in XHTML format.<p>
276      *
277      * @return true, if output has to be XHTML, otherwise false
278      */

279     protected boolean getXhtmlOutput() {
280         return m_xhtmlOutput;
281     }
282
283     /**
284      * Returns global prefix defined in configuration.<p>
285      *
286      * @return String with global prefix
287      */

288     protected String JavaDoc getGlobalPrefix() {
289         return m_globalPrefix;
290     }
291
292     /**
293      * Returns global suffix defined in configuration.<p>
294      *
295      * @return String with global suffix
296      */

297     protected String JavaDoc getGlobalSuffix() {
298         return m_globalSuffix;
299     }
300
301     /**
302      * Returns boolean if global prefix and suffix have to be added to every new line.<p>
303      *
304      * @return true, if prefix and suffix are added in every new line, otherwise false
305      */

306     protected boolean getGlobalAddEveryLine() {
307         return m_globalAddEveryLine;
308     }
309
310     /**
311      * Returns boolean if encoded brackets are used.<p>
312      *
313      * @return true, when encoded brackets are defined, otherwise false
314      */

315     protected boolean getUseBrackets() {
316         return m_useBrackets;
317     }
318
319     /**
320      * Returns boolean if quotationmarks must be encoded.<p>
321      *
322      * @return true, when quotationmarks must be encoded
323      */

324     protected boolean getEncodeQuotationmarks() {
325         return m_encodeQuotationmarks;
326     }
327
328     /**
329      * Returns the String for quotationmarks.<p>
330      *
331      * @return String with value for quotationmarks
332      */

333     protected String JavaDoc getQuotationmark() {
334         return m_quotationmark;
335     }
336
337     /**
338      * Adds new object to ArrayList m_replaceTags.<p>
339      *
340      * @param prefix prefix String
341      * @param tagName tagname String
342      * @param attributeName attributeName String
343      * @param attributeValue attributeNalue String
344      * @param replaceStartTag replaceStartTag String
345      * @param replaceEndTag replaceEndTag String
346      * @param suffix suffix String
347      * @param getReplaceFromAttrs getReplaceFromAttrs boolean
348      * @param startAttribute startAttribute String
349      * @param endAttribute endAttribute String
350      * @param parameter parameter String
351      * @param replaceParamAttr flag to indicate the parameter replacement
352      * @return true if object was successfully added, otherwise false
353      */

354     protected boolean addObjectReplaceTag(String JavaDoc prefix, String JavaDoc tagName,
355             String JavaDoc attributeName, String JavaDoc attributeValue, String JavaDoc replaceStartTag,
356             String JavaDoc replaceEndTag, String JavaDoc suffix, boolean getReplaceFromAttrs,
357             String JavaDoc startAttribute, String JavaDoc endAttribute, String JavaDoc parameter, boolean replaceParamAttr) {
358
359         return m_replaceTags.add(
360             new CmsHtmlConverterObjectReplaceTags(
361                 prefix,
362                 tagName,
363                 attributeName,
364                 attributeValue,
365                 replaceStartTag,
366                 replaceEndTag,
367                 suffix,
368                 getReplaceFromAttrs,
369                 startAttribute,
370                 endAttribute,
371                 parameter,
372                 replaceParamAttr));
373     }
374
375     /**
376      * Removes object from position index from ArrayList m_replaceTags.<p>
377      *
378      * @param index index of removed object
379      */

380     protected void removeObjectReplaceTag(int index) {
381         m_replaceTags.remove(index);
382     }
383
384     /**
385      * Adds new object to ArrayList m_replaceBlocks.<p>
386      *
387      * @param prefix prefix String
388      * @param tagName tagname String
389      * @param attributeName attributeName String
390      * @param attributeValue attributeNalue String
391      * @param replaceString replaceString String
392      * @param suffix suffix String
393      * @param getReplaceFromAttrs getReplaceFromAttrs boolean
394      * @param replaceAttribute replaceAttribute String
395      * @param parameter parameter String
396      * @return true if object was successfully added, otherwise false
397      */

398     protected boolean addObjectReplaceBlock(String JavaDoc prefix, String JavaDoc tagName,
399             String JavaDoc attributeName, String JavaDoc attributeValue, String JavaDoc replaceString,
400             String JavaDoc suffix, boolean getReplaceFromAttrs, String JavaDoc replaceAttribute, String JavaDoc parameter) {
401
402         return m_replaceBlocks.add(
403             new CmsHtmlConverterObjectReplaceBlocks(
404                 prefix,
405                 tagName,
406                 attributeName,
407                 attributeValue,
408                 replaceString,
409                 suffix,
410                 getReplaceFromAttrs,
411                 replaceAttribute,
412                 parameter));
413     }
414
415     /**
416      * Removes object from position index from ArrayList m_replaceBlocks.<p>
417      *
418      * @param index index of removed object
419      */

420     protected void removeObjectReplaceBlock(int index) {
421         m_replaceBlocks.remove(index);
422     }
423
424     /**
425      * Scans a String for coded bracket subStrings and replaces them.<p>
426      *
427      * @param content String to scan
428      * @return String with real "<" and ">"
429      */

430     protected String JavaDoc scanBrackets(String JavaDoc content) {
431         content = m_tools.replaceString(content, m_openBracket, "<");
432         content = m_tools.replaceString(content, m_closeBracket, ">");
433         return content;
434     }
435
436     /**
437      * Initialises configuration from String.<p>
438      *
439      * @param confString String with XML configuration
440      */

441     protected void init(String JavaDoc confString) {
442         InputStream JavaDoc in = new ByteArrayInputStream JavaDoc(confString.getBytes());
443         init(in);
444     }
445
446     /**
447      * Initialises configuration from InputStream.<p>
448      *
449      * @param in InputStream with XML configuration
450      */

451     protected void init(InputStream JavaDoc in) {
452         Node JavaDoc node;
453         Tidy tidy = new Tidy();
454         /* initialise Tidy */
455         tidy.setXmlTags(true);
456         tidy.setQuiet(true);
457         tidy.setOnlyErrors(true);
458         tidy.setShowWarnings(false);
459         /* if converter was configured, clear previous configuration */
460         if (m_isConfigured) {
461             clearConfiguration();
462         }
463         node = tidy.parseDOM(in, null);
464         parseConfig(node);
465         buildObjects();
466         m_isConfigured = true;
467     }
468
469     /**
470      * Clears all variables and objects if the configuration is redefined.<p>
471      */

472     private void clearConfiguration() {
473         m_globalAddEveryLine = false;
474         m_useBrackets = false;
475         m_globalPrefix = "";
476         m_globalSuffix = "";
477         m_openBracket = "";
478         m_closeBracket = "";
479         m_encodeQuotationmarks = false;
480         m_quotationmark = "";
481         m_replaceTagsPrefix = "";
482         m_replaceTagsSuffix = "";
483         m_replaceTagsAddEveryLine = false;
484         m_replaceTagsUseDefaults = false;
485         m_replaceBlocksPrefix = "";
486         m_replaceBlocksSuffix = "";
487         m_replaceBlocksAddEveryLine = false;
488         m_replaceBlocksUseDefaults = false;
489         m_replaceStringsPrefix = "";
490         m_replaceStringsSuffix = "";
491         m_replaceStringsAddEveryLine = false;
492         m_replaceStringsUseDefaults = false;
493         m_tempReplaceContent.clear();
494         m_tempReplaceStrings.clear();
495         m_tempReplaceTags.clear();
496         m_tempReplaceBlocks.clear();
497         m_replaceContent.clear();
498         m_removeTags.clear();
499         m_removeBlocks.clear();
500         m_inlineTags.clear();
501         m_replaceExtendedChars.clear();
502         m_replaceStrings.clear();
503         m_replaceTags.clear();
504         m_replaceBlocks.clear();
505         m_isConfigured = false;
506     }
507
508     /**
509      * Builds all objects after XML configuration was parsed.<p>
510      */

511     private void buildObjects() {
512         boolean added = true;
513         /* scan global prefix and suffix for brackets */
514         if (m_useBrackets) {
515             m_globalPrefix = scanBrackets(m_globalPrefix);
516             m_globalSuffix = scanBrackets(m_globalSuffix);
517         }
518         /* set normal quotationmarks, if no encoding is required */
519         if (!m_encodeQuotationmarks) {
520             m_quotationmark = "\"";
521         }
522         /* builds ArrayList m_replaceContent */
523         buildObjectReplaceContent();
524         /* builds ArrayList m_replaceTags */
525         buildObjectReplaceTags();
526         /* builds ArrayList m_replaceBlocks */
527         buildObjectReplaceBlocks();
528         /* builds ArrayList m_replaceStrings */
529         buildObjectReplaceStrings();
530         /* build ArrayList m_extendedChars */
531         // Encoding project:
532
// String Chars = "ä,&auml;,Ä,&Auml;,ö,&ouml;,Ö,&Ouml;,ü,&uuml;,Ü,&Uuml;,ß,&szlig;,©,&copy;,\",&quot;,<,&lt;,>,&gt;,&lt;!--,<!--,--&gt;,-->,€,&euro;";
533
String JavaDoc Chars = "\",&quot;,<,&lt;,>,&gt;";
534         StringTokenizer JavaDoc T = new StringTokenizer JavaDoc(Chars, ",");
535         while (T.hasMoreTokens()) {
536             added = m_replaceExtendedChars.add(new CmsHtmlConverterObjectReplaceExtendedChars(T.nextToken(), T.nextToken()));
537             if (!added) {
538                 System.err.println("Configuration error: failed adding object to ArrayList m_replaceExtendedChars.");
539             }
540         }
541         /* clear temporary ArrayLists */
542         m_tempReplaceContent.clear();
543         m_tempReplaceStrings.clear();
544         m_tempReplaceTags.clear();
545         m_tempReplaceBlocks.clear();
546     }
547
548     /**
549      * Creates ArrayList of objects with CmsHtmlConverterObjectReplaceContent.<p>
550      */

551     private void buildObjectReplaceContent() {
552         boolean added = true;
553         int len = m_tempReplaceContent.size();
554         String JavaDoc content, replace;
555         CmsHtmlConverterObjectReplaceContent objectReplaceContent = new CmsHtmlConverterObjectReplaceContent();
556         /* get temporary objects and scan replace for encoded brackets */
557         for (int i=0; i<len; i++) {
558             objectReplaceContent = (CmsHtmlConverterObjectReplaceContent) (m_tempReplaceContent.get(i));
559             content = objectReplaceContent.getSearchString();
560             replace = objectReplaceContent.getReplaceItem();
561             if (m_useBrackets) {
562                 replace = scanBrackets(replace);
563             }
564             added = m_replaceContent.add(new CmsHtmlConverterObjectReplaceContent(content, replace));
565             if (!added) {
566                 System.err.println("Configuration error: failed adding object to ArrayList m_replaceContent.");
567             }
568         }
569         added = m_replaceContent.add(new CmsHtmlConverterObjectReplaceContent("&nbsp;", "$nbsp$"));
570         if (!added) {
571                 System.err.println("Configuration error: failed adding object to ArrayList m_replaceContent.");
572         }
573     }
574
575     /**
576      * Creates ArrayList of objects with CmsHtmlConverterObjectReplaceTags.<p>
577      */

578     private void buildObjectReplaceTags() {
579         boolean added = true;
580         int len = m_tempReplaceTags.size();
581         String JavaDoc name, attrib, value, replaceStartTag, replaceEndTag, startAttribute, endAttribute, parameter;
582         boolean getReplaceFromAttrs, replaceParamAttr;
583         CmsHtmlConverterObjectReplaceTags objectReplaceTags = new CmsHtmlConverterObjectReplaceTags();
584         /* create prefix, suffix for replaceTags */
585         if (m_useBrackets) {
586                 m_replaceTagsPrefix = scanBrackets(m_replaceTagsPrefix);
587                 m_replaceTagsSuffix = scanBrackets(m_replaceTagsSuffix);
588         }
589         if (m_replaceTagsUseDefaults) {
590                 m_replaceTagsPrefix = m_globalSuffix;
591                 m_replaceTagsSuffix = m_globalPrefix;
592                 m_replaceTagsAddEveryLine = m_globalAddEveryLine;
593         }
594         if (m_replaceTagsAddEveryLine) {
595                 m_replaceTagsPrefix += "\n";
596                 m_replaceTagsSuffix = "\n" + m_replaceTagsSuffix;
597         }
598         /* get temporary objects and add them to ArrayList m_replaceTags */
599         for (int i=0; i<len; i++) {
600             objectReplaceTags = (CmsHtmlConverterObjectReplaceTags) (m_tempReplaceTags.get(i));
601             name = objectReplaceTags.getTagName();
602             attrib = objectReplaceTags.getTagAttrib();
603             value = objectReplaceTags.getTagAttribValue();
604             replaceStartTag = objectReplaceTags.getReplaceStartTag();
605             replaceEndTag = objectReplaceTags.getReplaceEndTag();
606             getReplaceFromAttrs = objectReplaceTags.getReplaceFromAttrs();
607             startAttribute = objectReplaceTags.getStartAttribute();
608             endAttribute = objectReplaceTags.getEndAttribute();
609             parameter = objectReplaceTags.getParameter();
610             replaceParamAttr = objectReplaceTags.getReplaceParamAttr();
611             if (m_useBrackets) {
612                 replaceStartTag = scanBrackets(replaceStartTag);
613                 replaceEndTag = scanBrackets(replaceEndTag);
614             }
615             added =
616                 m_replaceTags.add(
617                     new CmsHtmlConverterObjectReplaceTags(
618                         m_replaceTagsPrefix,
619                         name,
620                         attrib,
621                         value,
622                         replaceStartTag,
623                         replaceEndTag,
624                         m_replaceTagsSuffix,
625                         getReplaceFromAttrs,
626                         startAttribute,
627                         endAttribute,
628                         parameter,
629                         replaceParamAttr));
630             if (!added) {
631                 System.err.println("Configuration error: failed adding object to ArrayList m_replaceTags.");
632             }
633         }
634     }
635
636     /**
637      * Creates ArrayList of objects with CmsHtmlConverterObjectReplaceBlocks.<p>
638      */

639     private void buildObjectReplaceBlocks() {
640         boolean added = true;
641         int len = m_tempReplaceBlocks.size();
642         String JavaDoc name, attrib, value, replaceString, replaceAttribute, parameter;
643         boolean getReplaceFromAttrs;
644         CmsHtmlConverterObjectReplaceBlocks objectReplaceBlocks = new CmsHtmlConverterObjectReplaceBlocks();
645         /* create prefix, suffix for replaceBlocks */
646         if (m_useBrackets) {
647                 m_replaceBlocksPrefix = scanBrackets(m_replaceBlocksPrefix);
648                 m_replaceBlocksSuffix = scanBrackets(m_replaceBlocksSuffix);
649         }
650         if (m_replaceBlocksUseDefaults) {
651                 m_replaceBlocksPrefix = m_globalSuffix;
652                 m_replaceBlocksSuffix = m_globalPrefix;
653                 m_replaceBlocksAddEveryLine = m_globalAddEveryLine;
654         }
655         if (m_replaceBlocksAddEveryLine) {
656                 m_replaceBlocksPrefix += "\n";
657                 m_replaceBlocksSuffix = "\n" + m_replaceBlocksSuffix;
658         }
659         /* get temporary objects and add them to ArrayList m_replaceBlocks */
660         for (int i=0; i<len; i++) {
661             objectReplaceBlocks = (CmsHtmlConverterObjectReplaceBlocks) (m_tempReplaceBlocks.get(i));
662             name = objectReplaceBlocks.getTagName();
663             attrib = objectReplaceBlocks.getTagAttrib();
664             value = objectReplaceBlocks.getTagAttribValue();
665             replaceString = objectReplaceBlocks.getReplaceString();
666             getReplaceFromAttrs = objectReplaceBlocks.getReplaceFromAttrs();
667             replaceAttribute = objectReplaceBlocks.getReplaceAttribute();
668             parameter = objectReplaceBlocks.getParameter();
669             if (m_useBrackets) {
670                 replaceString = scanBrackets(replaceString);
671             }
672             added =
673                 m_replaceBlocks.add(
674                     new CmsHtmlConverterObjectReplaceBlocks(
675                         m_replaceBlocksPrefix,
676                         name,
677                         attrib,
678                         value,
679                         replaceString,
680                         m_replaceBlocksSuffix,
681                         getReplaceFromAttrs,
682                         replaceAttribute,
683                         parameter));
684             if (!added) {
685                 System.err.println("Configuration error: failed adding object to ArrayList m_replaceBlocks.");
686             }
687         }
688     }
689
690     /**
691      * Creates ArrayList of objects with CmsHtmlConverterObjectReplaceStrings.<p>
692      */

693     private void buildObjectReplaceStrings() {
694         boolean added = true;
695         int len = m_tempReplaceStrings.size();
696         String JavaDoc content, replace;
697         CmsHtmlConverterObjectReplaceStrings objectReplaceStrings = new CmsHtmlConverterObjectReplaceStrings();
698         /* create prefix, suffix for replaceStrings */
699         if (m_useBrackets) {
700                 m_replaceStringsPrefix = scanBrackets(m_replaceStringsPrefix);
701                 m_replaceStringsSuffix = scanBrackets(m_replaceStringsSuffix);
702         }
703         if (m_replaceStringsUseDefaults) {
704                 m_replaceStringsPrefix = m_globalSuffix;
705                 m_replaceStringsSuffix = m_globalPrefix;
706                 m_replaceStringsAddEveryLine = m_globalAddEveryLine;
707         }
708         if (m_replaceStringsAddEveryLine) {
709                 m_replaceStringsPrefix += "\n";
710                 m_replaceStringsSuffix = "\n" + m_replaceStringsSuffix;
711         }
712         /* get temporary objects and add them to ArrayList m_replaceStrings */
713         for (int i=0; i<len; i++) {
714             objectReplaceStrings = (CmsHtmlConverterObjectReplaceStrings) (m_tempReplaceStrings.get(i));
715             content = objectReplaceStrings.getSearchString();
716             replace = objectReplaceStrings.getReplaceItem();
717             if (m_useBrackets) {
718                 replace = scanBrackets(replace);
719             }
720             added =
721                 m_replaceStrings.add(
722                     new CmsHtmlConverterObjectReplaceStrings(
723                         content,
724                         m_replaceStringsPrefix,
725                         replace,
726                         m_replaceStringsSuffix));
727             if (!added) {
728                 System.err.println("Configuration error: failed adding object to ArrayList m_replaceStrings.");
729             }
730         }
731         added =
732             m_replaceStrings.add(
733                 new CmsHtmlConverterObjectReplaceStrings(
734                     "$nbsp$",
735                     "",
736                     "&nbsp;",
737                     ""));
738         if (!added) {
739                 System.err.println("Configuration error: failed adding object to ArrayList m_replaceStrings.");
740         }
741     }
742
743     /**
744      * Parses XML configuration input.<p>
745      *
746      * @param node actual node of XML configuration
747      */

748     private void parseConfig(Node JavaDoc node) {
749         int type = node.getNodeType();
750         int len = 0;
751         boolean added = true;
752         String JavaDoc valueString = "";
753         switch (type) {
754         case Node.DOCUMENT_NODE:
755             parseConfig(((Document JavaDoc)node).getDocumentElement());
756             break;
757         case Node.ELEMENT_NODE:
758             int nodeName = getConfigNodeName(node.getNodeName());
759             NodeList JavaDoc children = node.getChildNodes();
760             if (children != null) {
761                 len = children.getLength();
762             }
763             switch (nodeName) {
764             case C_COMMENT_NODE:
765                 break;
766             case C_CONFIG_NODE:
767                 for (int i = 0; i < len; i++) {
768                     /* recursively call parseConfig with all child nodes */
769                     parseConfig(children.item(i));
770                 }
771                 break;
772             case C_DEFAULT_NODE:
773                  for (int i = 0; i < len; i++) {
774                     /* set defaults in configuration */
775                     parseDefaults(children.item(i));
776                  }
777                  break;
778             case C_REPLACECONTENT_NODE:
779                 for (int i = 0; i < len; i++) {
780                     /* add replacecontent to configuration */
781                     parseReplaceContent(children.item(i));
782                 }
783                 break;
784             case C_INLINETAG_NODE:
785                 for (int i = 0; i < len; i++) {
786                     /* add inlinetags to configuration */
787                     valueString = parseTag(children.item(i));
788                     if (!valueString.equals("")) {
789                         added = m_inlineTags.add(new String JavaDoc(valueString));
790                     }
791                     if (!added) {
792                         System.err.println("Configuration error: failed adding object to ArrayList m_inlineTags.");
793                     }
794                 }
795                 break;
796             case C_REMOVETAG_NODE:
797                 for (int i = 0; i < len; i++) {
798                     /* add removetags to configuration */
799                     valueString = parseTag(children.item(i));
800                     if (!valueString.equals("")) {
801                         added = m_removeTags.add(new String JavaDoc(valueString));
802                     }
803                     if (!added) {
804                         System.err.println("Configuration error: failed adding object to ArrayList m_removeTags.");
805                     }
806                 }
807                 break;
808             case C_REMOVEBLOCK_NODE:
809                 for (int i = 0; i < len; i++) {
810                     /* add removeblocks to configuration */
811                     valueString = parseTag(children.item(i));
812                     if (!valueString.equals("")) {
813                         added = m_removeBlocks.add(new String JavaDoc(valueString));
814                     }
815                     if (!added) {
816                         System.err.println("Configuration error: failed adding object to ArrayList m_removeBlocks.");
817                     }
818                 }
819                 break;
820             case C_REPLACETAG_NODE:
821                 m_replaceTagsUseDefaults = checkBoolean(node, 0);
822                 for (int i = 0; i < len; i++) {
823                     parseReplaceTags(children.item(i));
824                 }
825                 break;
826             case C_REPLACEBLOCK_NODE:
827                 m_replaceBlocksUseDefaults = checkBoolean(node, 0);
828                 for (int i = 0; i < len; i++) {
829                     parseReplaceBlocks(children.item(i));
830                 }
831                 break;
832             case C_REPLACESTRING_NODE:
833                 m_replaceStringsUseDefaults = checkBoolean(node, 0);
834                 for (int i = 0; i < len; i++) {
835                     parseReplaceStrings(children.item(i));
836                 }
837                 break;
838             default:
839                 System.err.println("Configuration error: Tag <"+node.getNodeName()+"> not recognized.");
840                 break;
841             }
842         default:
843             break;
844         }
845     }
846
847     /**
848      * Reads default values from XML configuration.<p>
849      *
850      * @param node analysed node from default block
851      */

852     private void parseDefaults(Node JavaDoc node) {
853         NamedNodeMap JavaDoc attrs = node.getAttributes();
854         int nodeName = getConfigNodeName(node.getNodeName());
855         String JavaDoc attrName;
856         switch (nodeName) {
857         case C_COMMENT_NODE:
858             break;
859         case C_XHTMLOUTPUT_NODE:
860             m_xhtmlOutput = checkBoolean(node, 0);
861             break;
862         case C_GLOBALPREFIX_NODE:
863             m_globalPrefix = attrs.item(0).getNodeValue();
864             break;
865         case C_GLOBALSUFFIX_NODE:
866             m_globalSuffix = attrs.item(0).getNodeValue();
867             break;
868         case C_GLOBALADDEVERYLINE_NODE:
869             m_globalAddEveryLine = checkBoolean(node, 0);
870             break;
871         case C_USEBRACKETS_NODE:
872             for (int i=0; i<attrs.getLength(); i++) {
873                 attrName = attrs.item(i).getNodeName();
874                 if (attrName.equalsIgnoreCase("value")) {
875                     m_useBrackets = checkBoolean(node, i);
876                 }
877                 if (attrName.equalsIgnoreCase("openbracket")) {
878                     m_openBracket = attrs.item(i).getNodeValue();
879                 }
880                 if (attrName.equalsIgnoreCase("closebracket")) {
881                     m_closeBracket = attrs.item(i).getNodeValue();
882                 }
883             }
884             if ((m_useBrackets) && ((m_openBracket.equals("")) || (m_closeBracket.equals("")))) {
885                 System.err.println("Fatal configuration error: Wrong definition of <usebrackets> in block <defaults>.");
886                 System.exit(1);
887             }
888             break;
889         case C_ENCODEQUOTATIONMARKS_NODE:
890             for (int i=0; i<attrs.getLength(); i++) {
891                 attrName = attrs.item(i).getNodeName();
892                 if (attrName.equalsIgnoreCase("value")) {
893                     m_encodeQuotationmarks = checkBoolean(node, i);
894                 }
895                 if (attrName.equalsIgnoreCase("code")) {
896                     m_quotationmark = attrs.item(i).getNodeValue();
897                 }
898             }
899             if ((m_encodeQuotationmarks) && (m_quotationmark.equals(""))) {
900                 System.err.println("Fatal configuration error: Wrong definition of <encodequotationsmarks> in block <defaults>.");
901                 System.exit(1);
902             }
903             break;
904         default:
905             System.err.println("Fatal configuration error: Tag <"+node.getNodeName()+"> not recognized in block <defaults>.");
906             System.exit(1);
907         }
908     }
909
910     /**
911      * Reads replacecontent definitions from XML configuration.<p>
912      *
913      * @param node analysed node from replacecontent block
914      */

915     private void parseReplaceContent(Node JavaDoc node) {
916         if (node.getNodeName().equals("#comment")) {
917             return;
918         }
919         NamedNodeMap JavaDoc attrs = node.getAttributes();
920         String JavaDoc attrName;
921         String JavaDoc content = "";
922         String JavaDoc replace = "";
923         boolean added = true;
924         for (int i=0; i<attrs.getLength(); i++) {
925             attrName = attrs.item(i).getNodeName();
926             if (attrName.equalsIgnoreCase("content")) {
927                 content = attrs.item(i).getNodeValue();
928             }
929             if (attrName.equalsIgnoreCase("replace")) {
930                 replace = attrs.item(i).getNodeValue();
931             }
932         }
933         if (content.equals("")) {
934             System.err.println("Fatal configuration error: Empty content in block <replacecontent>.");
935             System.exit(1);
936         }
937         added = m_tempReplaceContent.add(new CmsHtmlConverterObjectReplaceContent(content, replace));
938         if (!added) {
939             System.err.println("Configuration error: Failed adding object to ArrayList m_tempReplaceContent.");
940         }
941     }
942
943     /**
944      * Reads replacetags definitions from XML configuration.<p>
945      *
946      * @param node analysed node from replacetags block
947      */

948     private void parseReplaceTags(Node JavaDoc node) {
949         boolean added = true;
950         NamedNodeMap JavaDoc attrs = node.getAttributes();
951         int nodeName = getConfigNodeName(node.getNodeName());
952         String JavaDoc attrName;
953         String JavaDoc attrNameValue = "";
954         String JavaDoc attrAttribValue = "";
955         String JavaDoc attrValueValue = "";
956         String JavaDoc attrStartValue = "";
957         String JavaDoc attrEndValue = "";
958         boolean attrGetReplace = false;
959         String JavaDoc attrStartAttribute = "";
960         String JavaDoc attrEndAttribute = "";
961         String JavaDoc attrParameter = "";
962         boolean attrReplaceParamAttr = false;
963         switch (nodeName) {
964         case C_COMMENT_NODE:
965             break;
966         case C_PREFIX_NODE:
967             //m_replaceTagsPrefix = attrs.item(0).getNodeValue();
968
m_replaceTagsPrefix = attrs.getNamedItem("value").getNodeValue();
969             break;
970         case C_SUFFIX_NODE:
971             m_replaceTagsSuffix = attrs.item(0).getNodeValue();
972             break;
973         case C_ADDEVERYLINE_NODE:
974             m_replaceTagsAddEveryLine = checkBoolean(node, 0);
975             break;
976         case C_TAG_NODE:
977             for (int i=0; i<attrs.getLength(); i++) {
978                 attrName = attrs.item(i).getNodeName();
979                 if (attrName.equalsIgnoreCase("name")) {
980                     attrNameValue = attrs.item(i).getNodeValue();
981                 }
982                 if (attrName.equalsIgnoreCase("attrib")) {
983                     attrAttribValue = attrs.item(i).getNodeValue();
984                 }
985                 if (attrName.equalsIgnoreCase("value")) {
986                     attrValueValue = attrs.item(i).getNodeValue();
987                 }
988                 if (attrName.equalsIgnoreCase("replacestarttag")) {
989                     attrStartValue = attrs.item(i).getNodeValue();
990                 }
991                 if (attrName.equalsIgnoreCase("replaceendtag")) {
992                     attrEndValue = attrs.item(i).getNodeValue();
993                 }
994                 if (attrName.equalsIgnoreCase("getreplacefromattrs")) {
995                     attrGetReplace = checkBoolean(node, i);
996                 }
997                 if (attrName.equalsIgnoreCase("startattribute")) {
998                     attrStartAttribute = attrs.item(i).getNodeValue();
999                 }
1000                if (attrName.equalsIgnoreCase("endattribute")) {
1001                    attrEndAttribute = attrs.item(i).getNodeValue();
1002                }
1003                if (attrName.equalsIgnoreCase("parameter")) {
1004                    attrParameter = attrs.item(i).getNodeValue();
1005                }
1006                if (attrName.equalsIgnoreCase("replaceparamattr")) {
1007                    attrReplaceParamAttr = checkBoolean(node, i);
1008                }
1009            }
1010            if (attrNameValue.equals("")) {
1011                System.err.println("Fatal configuration error: Tagname not specified in block <replacetags>.");
1012                System.exit(1);
1013            }
1014            added =
1015                m_tempReplaceTags.add(
1016                    new CmsHtmlConverterObjectReplaceTags(
1017                        "",
1018                        attrNameValue,
1019                        attrAttribValue,
1020                        attrValueValue,
1021                        attrStartValue,
1022                        attrEndValue,
1023                        "",
1024                        attrGetReplace,
1025                        attrStartAttribute,
1026                        attrEndAttribute,
1027                        attrParameter,
1028                        attrReplaceParamAttr));
1029            if (!added) {
1030                System.err.println("Configuration error: Failed adding object to ArrayList m_tempReplaceTags.");
1031            }
1032            break;
1033        default:
1034            System.err.println("Fatal configuration error: Tag <"+node.getNodeName()+"> not recognized in block <replacetags>.");
1035            System.exit(1);
1036        }
1037    }
1038
1039    /**
1040     * Reads replaceblocks definitions from XML configuration.<p>
1041     *
1042     * @param node analysed node from replaceblocks block
1043     */

1044    private void parseReplaceBlocks(Node JavaDoc node) {
1045        boolean added = false;
1046        NamedNodeMap JavaDoc attrs = node.getAttributes();
1047        int nodeName = getConfigNodeName(node.getNodeName());
1048        String JavaDoc attrName;
1049        String JavaDoc attrNameValue = "";
1050        String JavaDoc attrAttribValue = "";
1051        String JavaDoc attrValueValue = "";
1052        String JavaDoc attrStringValue = "";
1053        boolean attrGetReplace = false;
1054        String JavaDoc attrReplaceAttribute = "";
1055        String JavaDoc attrParameter = "";
1056        switch (nodeName) {
1057        case C_COMMENT_NODE:
1058            break;
1059        case C_PREFIX_NODE:
1060            m_replaceBlocksPrefix = attrs.item(0).getNodeValue();
1061            break;
1062        case C_SUFFIX_NODE:
1063            m_replaceBlocksSuffix = attrs.item(0).getNodeValue();
1064            break;
1065        case C_ADDEVERYLINE_NODE:
1066            m_replaceBlocksAddEveryLine = checkBoolean(node, 0);
1067            break;
1068        case C_TAG_NODE:
1069            for (int i=0; i<attrs.getLength(); i++) {
1070                attrName = attrs.item(i).getNodeName();
1071                if (attrName.equalsIgnoreCase("name")) {
1072                    attrNameValue = attrs.item(i).getNodeValue();
1073                }
1074                if (attrName.equalsIgnoreCase("attrib")) {
1075                    attrAttribValue = attrs.item(i).getNodeValue();
1076                }
1077                if (attrName.equalsIgnoreCase("value")) {
1078                    attrValueValue = attrs.item(i).getNodeValue();
1079                }
1080                if (attrName.equalsIgnoreCase("replacestring")) {
1081                    attrStringValue = attrs.item(i).getNodeValue();
1082                }
1083                if (attrName.equalsIgnoreCase("getreplacefromattrs")) {
1084                    attrGetReplace = checkBoolean(node, i);
1085                }
1086                if (attrName.equalsIgnoreCase("replaceattribute")) {
1087                    attrReplaceAttribute = attrs.item(i).getNodeValue();
1088                }
1089                if (attrName.equalsIgnoreCase("parameter")) {
1090                    attrParameter = attrs.item(i).getNodeValue();
1091                }
1092            }
1093            added =
1094                m_tempReplaceBlocks.add(
1095                    new CmsHtmlConverterObjectReplaceBlocks(
1096                        "",
1097                        attrNameValue,
1098                        attrAttribValue,
1099                        attrValueValue,
1100                        attrStringValue,
1101                        "",
1102                        attrGetReplace,
1103                        attrReplaceAttribute,
1104                        attrParameter));
1105            if (!added) {
1106                System.err.println("Configuration error: Failed adding object to ArrayList m_tempReplaceBlocks.");
1107            }
1108            if (attrNameValue.equals("")) {
1109                System.err.println("Fatal configuration error: Tagname not specified in block <replaceblocks>.");
1110                System.exit(1);
1111            }
1112
1113            break;
1114        default:
1115            System.err.println("Fatal configuration error: Tag <"+node.getNodeName()+"> not recognized in block <replaceblocks>.");
1116            System.exit(1);
1117        }
1118    }
1119
1120    /**
1121     * Reads replacestrings definitions from XML configuration.<p>
1122     *
1123     * @param node analysed node from replacestrings block
1124     */

1125    private void parseReplaceStrings(Node JavaDoc node) {
1126        boolean added = false;
1127        NamedNodeMap JavaDoc attrs = node.getAttributes();
1128        int nodeName = getConfigNodeName(node.getNodeName());
1129        String JavaDoc attrName;
1130        String JavaDoc attrContentValue = "";
1131        String JavaDoc attrReplaceValue = "";
1132        switch (nodeName) {
1133        case C_COMMENT_NODE:
1134            break;
1135        case C_PREFIX_NODE:
1136            m_replaceStringsPrefix = attrs.item(0).getNodeValue();
1137            break;
1138        case C_SUFFIX_NODE:
1139            m_replaceStringsSuffix = attrs.item(0).getNodeValue();
1140            break;
1141        case C_ADDEVERYLINE_NODE:
1142            m_replaceStringsAddEveryLine = checkBoolean(node, 0);
1143            break;
1144        case C_STRING_NODE:
1145            for (int i=0; i<attrs.getLength(); i++) {
1146                attrName = attrs.item(i).getNodeName();
1147                if (attrName.equalsIgnoreCase("content")) {
1148                    attrContentValue = attrs.item(i).getNodeValue();
1149                }
1150                if (attrName.equalsIgnoreCase("replace")) {
1151                    attrReplaceValue = attrs.item(i).getNodeValue();
1152                }
1153            }
1154            if (attrContentValue.equals("")) {
1155                System.err.println("Fatal configuration error: Empty content in block <replacestrings>.");
1156                System.exit(1);
1157            }
1158            added =
1159                m_tempReplaceStrings.add(
1160                    new CmsHtmlConverterObjectReplaceStrings(
1161                        attrContentValue,
1162                        "",
1163                        attrReplaceValue,
1164                        ""));
1165            if (!added) {
1166                System.err.println("Configuration error: Failed adding object to ArrayList m_tempReplaceStrings.");
1167            }
1168            break;
1169        default:
1170            System.err.println("Fatal configuration error: Tag <"+node.getNodeName()
1171                    +"> not recognized in block <replacestrings>.");
1172            System.exit(1);
1173        }
1174    }
1175
1176    /**
1177     * Reads tag definitions (removetags, removeblocks, inlinetags) from XML configuration.<p>
1178     *
1179     * @param node analysed node from blocks removetags, removeblocks, inlinetags
1180     * @return value of attribute "name" of analysed node
1181     */

1182    private String JavaDoc parseTag(Node JavaDoc node) {
1183        if (node.getNodeName().equals("#comment")) {
1184            return "";
1185        }
1186        NamedNodeMap JavaDoc attrs = node.getAttributes();
1187        if (attrs.getLength()<1) {
1188            System.err.println("Fatal configuration error: Tag <"+node.getNodeName()
1189                    +"> has no attributes.");
1190            System.exit(1);
1191        }
1192        String JavaDoc name=attrs.item(0).getNodeName();
1193        if (name.equalsIgnoreCase("name")) {
1194            return attrs.item(0).getNodeValue();
1195        }
1196        System.err.println("Fatal configuration error: Attribute \""+name
1197                +"\" not recognized in tag <"+node.getNodeName()+">.");
1198        System.exit(1);
1199        return "";
1200    }
1201
1202    /**
1203     * Analyses attribute values and returns.<p>
1204     *
1205     * @param node analysed node
1206     * @param number analysed attribute number of node
1207     * @return true, if attribute value is "true"; false, if value is "false"
1208     */

1209    private boolean checkBoolean(Node JavaDoc node, int number) {
1210        NamedNodeMap JavaDoc attrs = node.getAttributes();
1211        if (attrs.item(number).getNodeValue().equalsIgnoreCase(CmsStringUtil.TRUE)) {
1212            return true;
1213        } else if (attrs.item(number).getNodeValue().equalsIgnoreCase(CmsStringUtil.FALSE)) {
1214            return false;
1215        }
1216        System.err.println("Fatal configuration error: Attribute value \""
1217                +attrs.item(number).getNodeValue()+"\" not recognized in tag <"+node.getNodeName()+">.");
1218        System.exit(1);
1219        return false;
1220    }
1221
1222    /**
1223     * Tests if a node name is allowed in XML configuration.<p>
1224     *
1225     * @param name String which is tested
1226     * @return value of node name, -1 for commentnode, exit if name was not recognized
1227     */

1228    private int getConfigNodeName(String JavaDoc name) {
1229        if (name.equalsIgnoreCase("tag")) {
1230            return C_TAG_NODE;
1231        }
1232        if (name.equalsIgnoreCase("string")) {
1233            return C_STRING_NODE;
1234        }
1235        if (name.equalsIgnoreCase("converterconfig")) {
1236            return C_CONFIG_NODE;
1237        }
1238        if (name.equalsIgnoreCase("replacecontent")) {
1239            return C_REPLACECONTENT_NODE;
1240        }
1241        if (name.equalsIgnoreCase("defaults")) {
1242            return C_DEFAULT_NODE;
1243        }
1244        if (name.equalsIgnoreCase("inlinetags")) {
1245            return C_INLINETAG_NODE;
1246        }
1247        if (name.equalsIgnoreCase("removetags")) {
1248            return C_REMOVETAG_NODE;
1249        }
1250        if (name.equalsIgnoreCase("removeblocks")) {
1251            return C_REMOVEBLOCK_NODE;
1252        }
1253        if (name.equalsIgnoreCase("replacetags")) {
1254            return C_REPLACETAG_NODE;
1255        }
1256        if (name.equalsIgnoreCase("replaceblocks")) {
1257            return C_REPLACEBLOCK_NODE;
1258        }
1259        if (name.equalsIgnoreCase("replacestrings")) {
1260            return C_REPLACESTRING_NODE;
1261        }
1262        if (name.equalsIgnoreCase("xhtmloutput")) {
1263            return C_XHTMLOUTPUT_NODE;
1264        }
1265        if (name.equalsIgnoreCase("globalprefix")) {
1266            return C_GLOBALPREFIX_NODE;
1267        }
1268        if (name.equalsIgnoreCase("globalsuffix")) {
1269            return C_GLOBALSUFFIX_NODE;
1270        }
1271        if (name.equalsIgnoreCase("globaladdeveryline")) {
1272            return C_GLOBALADDEVERYLINE_NODE;
1273        }
1274        if (name.equalsIgnoreCase("usebrackets")) {
1275            return C_USEBRACKETS_NODE;
1276        }
1277        if (name.equalsIgnoreCase("encodequotationmarks")) {
1278            return C_ENCODEQUOTATIONMARKS_NODE;
1279        }
1280        if (name.equalsIgnoreCase("addeveryline")) {
1281            return C_ADDEVERYLINE_NODE;
1282        }
1283        if (name.equalsIgnoreCase("prefix")) {
1284            return C_PREFIX_NODE;
1285        }
1286        if (name.equalsIgnoreCase("suffix")) {
1287            return C_SUFFIX_NODE;
1288        }
1289        if (name.equalsIgnoreCase("#comment")) {
1290            return C_COMMENT_NODE;
1291        }
1292        /* if tagname is not recognized, return -1 */
1293        return -1;
1294    }
1295
1296}
Popular Tags