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.ValueOf; 6 import net.sf.saxon.om.AttributeCollection; 7 import net.sf.saxon.value.StringValue; 8 import net.sf.saxon.trans.XPathException; 9 10 import javax.xml.transform.TransformerConfigurationException ; 11 12 13 14 18 19 public class SaxonEntityRef extends StyleElement { 20 21 String nameAttribute; 22 23 27 28 public boolean isInstruction() { 29 return true; 30 } 31 32 33 public void prepareAttributes() throws XPathException { 34 35 AttributeCollection atts = getAttributeList(); 36 37 for (int a=0; a<atts.getLength(); a++) { 38 int nc = atts.getNameCode(a); 39 String f = getNamePool().getClarkName(nc); 40 if (f==StandardNames.NAME) { 41 nameAttribute = atts.getValue(a).trim(); 42 } else { 43 checkUnknownAttribute(nc); 44 } 45 } 46 47 if (nameAttribute==null) { 48 reportAbsence("name"); 49 } 50 } 51 52 public void validate() throws XPathException { 53 checkWithinTemplate(); 54 checkEmpty(); 55 } 56 57 public Expression compile(Executable exec) throws XPathException { 58 ValueOf text = new ValueOf(new StringValue('&' + nameAttribute + ';'), true, false); 59 ExpressionTool.makeParentReferences(text); 65 return text; 66 } 67 68 } 69 | Popular Tags |