1 package com.icl.saxon.style; 2 import com.icl.saxon.tree.AttributeCollection; 3 import com.icl.saxon.*; 4 import com.icl.saxon.om.*; 5 import com.icl.saxon.expr.*; 6 import javax.xml.transform.*; 7 8 12 13 public class SAXONHandler extends XSLTemplate { 14 15 private NodeHandler handler; 16 17 public void checkUnknownAttribute(int nc) 18 throws TransformerConfigurationException { 19 20 StandardNames sn = getStandardNames(); 21 AttributeCollection atts = getAttributeList(); 22 23 int f = nc & 0xfffff; 24 if (f==sn.HANDLER) { 25 String handlerAtt = atts.getValueByFingerprint(f); 26 handler = makeHandler(handlerAtt); 27 } else { 28 super.checkUnknownAttribute(nc); 29 } 30 31 if (handler==null) { 32 reportAbsence("handler"); 33 } 34 35 } 36 37 38 public void validate() throws TransformerConfigurationException { 39 if (handler==null) { 40 reportAbsence("handler"); 41 } 42 checkTopLevel(); 43 } 44 45 48 49 public void preprocess() throws TransformerConfigurationException 50 { 51 RuleManager mgr = getPrincipalStyleSheet().getRuleManager(); 52 Mode mode = mgr.getMode(modeNameCode); 53 if (match!=null) { 54 if (prioritySpecified) { 55 mgr.setHandler(match, handler, mode, getPrecedence(), priority); 56 } else { 57 mgr.setHandler(match, handler, mode, getPrecedence()); 58 } 59 } 60 61 } 62 63 67 68 public void process(Context context) throws TransformerException { 69 } 70 71 74 75 public void expand(Context context) throws TransformerException { 76 handler.start(context.getCurrentNodeInfo(), context); 77 } 78 79 82 83 protected NodeHandler makeHandler (String className) 84 throws TransformerConfigurationException 85 { 86 try { 87 return (NodeHandler)(Loader.getInstance(className)); 88 } catch (TransformerException err) { 89 compileError(err); 90 } catch (ClassCastException e) { 91 compileError("Node handler " + className + 92 " does not implement the NodeHandler interface"); 93 } 94 return null; 95 } 96 97 } 98 99 | Popular Tags |