1 16 19 package org.apache.xalan.templates; 20 21 import java.util.Vector ; 22 23 import javax.xml.transform.TransformerException ; 24 25 import org.apache.xalan.res.XSLMessages; 26 import org.apache.xalan.res.XSLTErrorResources; 27 import org.apache.xalan.transformer.TransformerImpl; 28 import org.apache.xml.utils.QName; 29 30 38 public class ElemUse extends ElemTemplateElement 39 { 40 41 45 private QName m_attributeSetsNames[] = null; 46 47 58 public void setUseAttributeSets(Vector v) 59 { 60 61 int n = v.size(); 62 63 m_attributeSetsNames = new QName[n]; 64 65 for (int i = 0; i < n; i++) 66 { 67 m_attributeSetsNames[i] = (QName) v.elementAt(i); 68 } 69 } 70 71 82 public void setUseAttributeSets(QName[] v) 83 { 84 m_attributeSetsNames = v; 85 } 86 87 100 public QName[] getUseAttributeSets() 101 { 102 return m_attributeSetsNames; 103 } 104 105 120 public void applyAttrSets( 121 TransformerImpl transformer, StylesheetRoot stylesheet) 122 throws TransformerException 123 { 124 applyAttrSets(transformer, stylesheet, m_attributeSetsNames); 125 } 126 127 142 private void applyAttrSets( 143 TransformerImpl transformer, StylesheetRoot stylesheet, QName attributeSetsNames[]) 144 throws TransformerException 145 { 146 147 if (null != attributeSetsNames) 148 { 149 int nNames = attributeSetsNames.length; 150 151 for (int i = 0; i < nNames; i++) 152 { 153 QName qname = attributeSetsNames[i]; 154 Vector attrSets = stylesheet.getAttributeSetComposed(qname); 155 156 if (null != attrSets) 157 { 158 int nSets = attrSets.size(); 159 160 for (int k = nSets-1; k >= 0 ; k--) 163 { 164 ElemAttributeSet attrSet = 165 (ElemAttributeSet) attrSets.elementAt(k); 166 167 attrSet.execute(transformer); 168 } 169 } 170 else 171 { 172 throw new TransformerException ( 173 XSLMessages.createMessage(XSLTErrorResources.ER_NO_ATTRIB_SET, 174 new Object [] {qname}),this); 175 } 176 } 177 } 178 } 179 180 197 public void execute( 198 TransformerImpl transformer) 199 throws TransformerException 200 { 201 202 if (null != m_attributeSetsNames) 203 { 204 applyAttrSets(transformer, getStylesheetRoot(), 205 m_attributeSetsNames); 206 } 207 208 } 209 } 210 | Popular Tags |