1 28 29 package com.caucho.xsl; 30 31 import com.caucho.xpath.Env; 32 import com.caucho.xpath.Expr; 33 import com.caucho.xpath.NamespaceContext; 34 import com.caucho.xpath.Pattern; 35 import com.caucho.xpath.XPathException; 36 37 import org.w3c.dom.Node ; 38 39 import java.util.HashMap ; 40 41 46 public class JavaStylesheet extends StylesheetImpl { 47 protected Pattern []patterns; 48 protected Expr []exprs; 49 protected Sort [][]_xsl_sorts; 50 protected NamespaceContext []_namespaces; 51 protected XslNumberFormat []_xsl_formats; 52 53 protected int getTemplateId(HashMap templates, 54 Node node, Env env, int min, int max) 55 throws XPathException 56 { 57 Template template = null; 58 59 Template []templateList = (Template []) templates.get(node.getNodeName()); 60 if (templateList == null) 61 templateList = (Template []) templates.get("*"); 62 63 int funId = 0; 64 65 int oldPosition = env.setContextPosition(0); 66 int oldSize = env.setContextSize(0); 67 Node oldNode = env.setContextNode(null); 68 69 for (int i = 0; templateList != null && i < templateList.length; i++) { 70 Template subtemplate = templateList[i]; 71 72 if (min <= subtemplate.maxImportance && 73 subtemplate.maxImportance <= max && 74 subtemplate.pattern.match(node, env)) { 75 funId = subtemplate.funId; 76 break; 77 } 78 } 79 80 env.setContextPosition(oldPosition); 81 env.setContextSize(oldSize); 82 env.setContextNode(oldNode); 83 84 return funId; 85 } 86 } 87 | Popular Tags |