1 package net.sf.saxon.style; 2 import net.sf.saxon.expr.Expression; 3 import net.sf.saxon.expr.ExpressionTool; 4 import net.sf.saxon.instruct.Executable; 5 import net.sf.saxon.instruct.ProcessingInstruction; 6 import net.sf.saxon.om.AttributeCollectionImpl; 7 import net.sf.saxon.om.AttributeCollection; 8 import net.sf.saxon.value.StringValue; 9 import net.sf.saxon.trans.XPathException; 10 11 import javax.xml.transform.TransformerConfigurationException ; 12 13 16 17 public class XSLProcessingInstruction extends XSLStringConstructor { 18 19 Expression name; 20 21 public void prepareAttributes() throws XPathException { 22 23 String nameAtt = null; 24 String selectAtt = null; 25 26 AttributeCollection atts = getAttributeList(); 27 28 for (int a=0; a<atts.getLength(); a++) { 29 int nc = atts.getNameCode(a); 30 String f = getNamePool().getClarkName(nc); 31 if (f==StandardNames.NAME) { 32 nameAtt = atts.getValue(a).trim(); 33 } else if (f==StandardNames.SELECT) { 34 selectAtt = atts.getValue(a).trim(); 35 } else { 36 checkUnknownAttribute(nc); 37 } 38 } 39 40 if (nameAtt==null) { 41 reportAbsence("name"); 42 } else { 43 name = makeAttributeValueTemplate(nameAtt); 44 } 45 46 if (selectAtt!=null) { 47 select = makeExpression(selectAtt); 48 } 49 } 50 51 public void validate() throws XPathException { 52 checkWithinTemplate(); 53 name = typeCheck("name", name); 54 select = typeCheck("select", select); 55 super.validate(); 56 } 57 58 public Expression compile(Executable exec) throws XPathException { 59 ProcessingInstruction inst = new ProcessingInstruction(name); 60 compileContent(exec, inst, StringValue.SINGLE_SPACE); 61 ExpressionTool.makeParentReferences(inst); 63 return inst; 64 } 65 66 } 67 68 | Popular Tags |