1 package com.icl.saxon.style; 2 import com.icl.saxon.tree.AttributeCollection; 3 import com.icl.saxon.*; 4 5 import com.icl.saxon.output.*; 6 7 import javax.xml.transform.*; 8 9 10 11 15 16 public class SAXONEntityRef extends StyleElement { 17 18 String nameAttribute; 19 20 24 25 public boolean isInstruction() { 26 return true; 27 } 28 29 30 public void prepareAttributes() throws TransformerConfigurationException { 31 32 StandardNames sn = getStandardNames(); 33 AttributeCollection atts = getAttributeList(); 34 35 for (int a=0; a<atts.getLength(); a++) { 36 int nc = atts.getNameCode(a); 37 int f = nc & 0xfffff; 38 if (f==sn.NAME) { 39 nameAttribute = atts.getValue(a); 40 } else { 41 checkUnknownAttribute(nc); 42 } 43 } 44 45 if (nameAttribute==null) { 46 reportAbsence("name"); 47 } 48 } 49 50 public void validate() throws TransformerConfigurationException { 51 checkWithinTemplate(); 52 checkEmpty(); 53 } 54 55 public void process(Context context) throws TransformerException { 56 Outputter out = context.getOutputter(); 57 out.setEscaping(false); 58 out.writeContent('&' + nameAttribute + ';'); 59 out.setEscaping(true); 60 } 61 62 } 63 | Popular Tags |