1 package com.icl.saxon.style; 2 import com.icl.saxon.tree.AttributeCollection; 3 import com.icl.saxon.*; 4 import com.icl.saxon.om.Name; 5 import com.icl.saxon.om.NamespaceException; 6 7 import com.icl.saxon.handlers.*; 8 import com.icl.saxon.expr.*; 9 10 import org.w3c.dom.Node ; 11 import javax.xml.transform.*; 12 13 14 17 18 public class XSLAttributeSet extends StyleElement { 19 20 int fingerprint; String use; Procedure procedure = new Procedure(); 24 public int getAttributeSetFingerprint() { 25 return fingerprint; 26 } 27 28 public void prepareAttributes() throws TransformerConfigurationException { 29 30 String name = null; 31 use = null; 32 33 StandardNames sn = getStandardNames(); 34 AttributeCollection atts = getAttributeList(); 35 36 for (int a=0; a<atts.getLength(); a++) { 37 int nc = atts.getNameCode(a); 38 int f = nc & 0xfffff; 39 if (f==sn.NAME) { 40 name = atts.getValue(a); 41 } else if (f==sn.USE_ATTRIBUTE_SETS) { 42 use = atts.getValue(a); 43 } else { 44 checkUnknownAttribute(nc); 45 } 46 } 47 48 if (name==null) { 49 reportAbsence("name"); 50 return; 51 } 52 53 if (!Name.isQName(name)) { 54 compileError("Attribute set name must be a valid QName"); 55 } 56 57 try { 58 fingerprint = makeNameCode(name, false) & 0xfffff; 59 } catch (NamespaceException err) { 60 compileError(err.getMessage()); 61 } 62 63 } 64 65 public void validate() throws TransformerConfigurationException { 66 checkTopLevel(); 67 68 Node child = getFirstChild(); 69 while (child!=null) { 70 if (!(child instanceof XSLAttribute)) { 71 compileError("Only xsl:attribute is allowed within xsl:attribute-set"); 72 } 73 child = child.getNextSibling(); 74 } 75 76 if (use!=null) { 77 findAttributeSets(use); } 79 } 80 81 84 85 public Procedure getProcedure() { 86 return procedure; 87 } 88 89 public void preprocess() throws TransformerConfigurationException { 90 getPrincipalStyleSheet().allocateLocalSlots(procedure.getNumberOfVariables()); 91 } 92 93 public void process(Context context) throws TransformerException { 94 95 } 97 98 public void expand(Context context) throws TransformerException { 99 processAttributeSets(context); 100 if (procedure.getNumberOfVariables()==0) { 101 processChildren(context); 102 } else { 103 Bindery bindery = context.getController().getBindery(); 104 bindery.openStackFrame(null); 105 processChildren(context); 106 bindery.closeStackFrame(); 107 } 108 } 109 110 } 111 112 | Popular Tags |