1 package com.icl.saxon.style; 2 import com.icl.saxon.tree.AttributeCollection; 3 import com.icl.saxon.*; 4 import com.icl.saxon.expr.*; 5 import javax.xml.transform.*; 6 7 8 13 14 public class XSLIf extends StyleElement { 15 16 private Expression test; 17 18 22 23 public boolean isInstruction() { 24 return true; 25 } 26 27 31 32 public boolean doesPostProcessing() { 33 return false; 34 } 35 36 40 41 public boolean mayContainTemplateBody() { 42 return true; 43 } 44 45 public void prepareAttributes() throws TransformerConfigurationException { 46 47 String testAtt=null; 48 49 StandardNames sn = getStandardNames(); 50 AttributeCollection atts = getAttributeList(); 51 52 for (int a=0; a<atts.getLength(); a++) { 53 int nc = atts.getNameCode(a); 54 int f = nc & 0xfffff; 55 if (f==sn.NAME) { 56 } else if (f==sn.TEST) { 58 testAtt = atts.getValue(a); 59 } else { 60 checkUnknownAttribute(nc); 61 } 62 } 63 64 if (testAtt==null) { 65 reportAbsence("test"); 66 } else { 67 test = makeExpression(testAtt); 68 } 69 } 70 71 public void validate() throws TransformerConfigurationException { 72 checkWithinTemplate(); 73 } 74 75 public void process(Context context) throws TransformerException 76 { 77 if (test.evaluateAsBoolean(context)) { 78 processChildren(context); 79 } 80 } 81 82 } 83 | Popular Tags |