1 15 package org.apache.tapestry.script; 16 17 import org.apache.hivemind.ClassResolver; 18 import org.apache.hivemind.Resource; 19 import org.apache.tapestry.IScript; 20 import org.apache.tapestry.coerce.ValueConverter; 21 import org.apache.tapestry.services.ExpressionEvaluator; 22 import org.apache.tapestry.util.xml.DocumentParseException; 23 import org.apache.tapestry.util.xml.RuleDirectedParser; 24 25 50 51 public class ScriptParser 52 { 53 private RuleDirectedParser _parser; 54 55 public static final String SCRIPT_DTD_1_0_PUBLIC_ID = "-//Primix Solutions//Tapestry Script 1.0//EN"; 56 57 public static final String SCRIPT_DTD_1_1_PUBLIC_ID = "-//Howard Ship//Tapestry Script 1.1//EN"; 58 59 public static final String SCRIPT_DTD_1_2_PUBLIC_ID = "-//Howard Lewis Ship//Tapestry Script 1.2//EN"; 60 61 62 public static final String SCRIPT_DTD_3_0_PUBLIC_ID = "-//Apache Software Foundation//Tapestry Script Specification 3.0//EN"; 63 64 public ScriptParser(ClassResolver resolver, ExpressionEvaluator evaluator, 65 ValueConverter valueConverter) 66 { 67 _parser = new RuleDirectedParser(); 68 69 _parser.registerEntity( 70 SCRIPT_DTD_1_0_PUBLIC_ID, 71 "/org/apache/tapestry/script/Script_1_0.dtd"); 72 _parser.registerEntity( 73 SCRIPT_DTD_1_1_PUBLIC_ID, 74 "/org/apache/tapestry/script/Script_1_1.dtd"); 75 _parser.registerEntity( 76 SCRIPT_DTD_1_2_PUBLIC_ID, 77 "/org/apache/tapestry/script/Script_1_2.dtd"); 78 _parser.registerEntity( 79 SCRIPT_DTD_3_0_PUBLIC_ID, 80 "/org/apache/tapestry/script/Script_3_0.dtd"); 81 82 _parser.addRule("script", new ScriptRule(evaluator, valueConverter)); 83 _parser.addRule("let", new LetRule()); 84 _parser.addRule("set", new SetRule()); 85 _parser.addRule("include-script", new IncludeScriptRule()); 86 _parser.addRule("input-symbol", new InputSymbolRule(resolver)); 87 _parser.addRule("body", new BodyRule()); 88 _parser.addRule("initialization", new InitRule()); 89 _parser.addRule("if", new IfRule(true)); 90 _parser.addRule("if-not", new IfRule(false)); 91 _parser.addRule("foreach", new ForeachRule()); 92 _parser.addRule("unique", new UniqueRule()); 93 94 _parser.addRule("insert", new InsertRule()); 96 97 } 98 99 102 103 public IScript parse(Resource resourceLocation) throws DocumentParseException 104 { 105 return (IScript) _parser.parse(resourceLocation); 106 } 107 108 } | Popular Tags |