01: package net.sf.saxon.event;
02:
03: import net.sf.saxon.om.NamePool;
04: import net.sf.saxon.om.NamespaceConstant;
05: import net.sf.saxon.sort.IntHashSet;
06:
07: /**
08: * XHTMLIndenter: This class indents XHTML elements, by adding whitespace
09: * character data where appropriate. This class differs from its superclass,
10: * HTMLIndenter, only in the way it classifies elements as being inline or
11: * formatted elements: unlike the HTML indenter, it requires the element names
12: * to be in lower case and to be in the XHTML namespace.
13: *
14: * @author Michael Kay
15: */
16:
17: public class XHTMLIndenter extends HTMLIndenter {
18:
19: private IntHashSet inlineTagSet;
20: private IntHashSet formattedTagSet;
21:
22: protected int classifyTag(int nameCode) {
23: if (inlineTagSet == null) {
24: NamePool pool = getNamePool();
25: inlineTagSet = new IntHashSet(40);
26: formattedTagSet = new IntHashSet(10);
27: for (int i = 0; i < inlineTags.length; i++) {
28: int nc = pool.allocate("", NamespaceConstant.XHTML,
29: inlineTags[i]);
30: inlineTagSet.add(nc);
31: }
32: for (int i = 0; i < formattedTags.length; i++) {
33: int nc = pool.allocate("", NamespaceConstant.XHTML,
34: formattedTags[i]);
35: formattedTagSet.add(nc);
36: }
37: }
38: int r = 0;
39: int key = nameCode & NamePool.FP_MASK;
40: if (inlineTagSet.contains(key)) {
41: r |= IS_INLINE;
42: }
43: if (formattedTagSet.contains(key)) {
44: r |= IS_FORMATTED;
45: }
46: return r;
47: }
48:
49: public XHTMLIndenter() {
50: }
51:
52: };
53:
54: //
55: // The contents of this file are subject to the Mozilla Public License Version 1.0 (the "License");
56: // you may not use this file except in compliance with the License. You may obtain a copy of the
57: // License at http://www.mozilla.org/MPL/
58: //
59: // Software distributed under the License is distributed on an "AS IS" basis,
60: // WITHOUT WARRANTY OF ANY KIND, either express or implied.
61: // See the License for the specific language governing rights and limitations under the License.
62: //
63: // The Original Code is: all this file.
64: //
65: // The Initial Developer of the Original Code is Michael H. Kay.
66: //
67: // Portions created by (your name) are Copyright (C) (your legal entity). All Rights Reserved.
68: //
69: // Contributor(s): none.
70: //
|