- public static Template getTemplate(Res r) throws JSExn {
- try {
- r = r.addExtension(".xwt");
- if (r.t != null) return r.t;
- r.t = new Template(r);
- new TemplateHelper().parseit(r.getInputStream(), r.t);
- return r.t;
- } catch (Exception e) { throw new JSExn(e.toString());
- }
- }
-
- public static Res resolveStringToResource(String str, XWT xwt, boolean permitAbsolute) throws JSExn {
- // URL
- if (str.indexOf("://") != -1) {
- if (permitAbsolute) return (Res)xwt.url2res(str);
- throw new JSExn("absolute URL " + str + " not permitted here");
- }
-
- // root-relative
- Res ret = xwt.rr;
- while(str.indexOf('.') != -1) {
- String path = str.substring(0, str.indexOf('.'));
- str = str.substring(str.indexOf('.') + 1);
- ret = (Res)ret.get(path);
- }
- ret = (Res)ret.get(str);
- return ret;
- }
-
+ // for non-root nodes
+ private Template(Template t, int startLine) { prev = t; this.xwt = t.xwt; this.startLine = startLine; }
+ private Template(XWT xwt) { this.xwt = xwt; }
+