01: package gnu.kawa.xslt;
02:
03: import gnu.mapping.Procedure;
04: import gnu.mapping.Symbol;
05:
06: /** Manages the set of xslt templates that have the same 'mode'. */
07:
08: public class TemplateTable {
09: /** The "mode" parameter of xsl:template. */
10: Symbol name;
11:
12: static final TemplateTable nullModeTable = new TemplateTable(
13: XSLT.nullMode);
14:
15: public TemplateTable(Symbol mode) {
16: this .name = mode;
17: }
18:
19: static TemplateTable getTemplateTable(Symbol name) {
20: if (name == XSLT.nullMode)
21: return nullModeTable;
22: return null; // FIXME
23: }
24:
25: TemplateEntry entries; // For now - later use HashTable.
26:
27: public void enter(String pattern, double priority,
28: Procedure procedure) {
29: TemplateEntry entry = new TemplateEntry();
30: entry.procedure = procedure;
31: entry.priority = priority;
32: entry.pattern = pattern;
33: entry.next = entries;
34: entries = entry;
35: }
36:
37: public Procedure find(String name) {
38: for (TemplateEntry entry = entries; entry != null; entry = entry.next) {
39: if (entry.pattern.equals(name))
40: return entry.procedure;
41: }
42: return null;
43: }
44: }
45:
46: /** Each xsl:template creates a TemplateEntry. */
47:
48: class TemplateEntry {
49: Procedure procedure;
50: double priority;
51: String pattern;
52: TemplateEntry next;
53: }
|