1 16 19 package org.apache.xalan.processor; 20 21 import javax.xml.transform.TransformerException ; 22 23 import org.apache.xalan.res.XSLTErrorResources; 24 import org.apache.xalan.templates.ElemTemplateElement; 25 26 import org.xml.sax.Attributes ; 27 28 33 public class ProcessorTemplateElem extends XSLTElementProcessor 34 { 35 36 47 public void startElement( 48 StylesheetHandler handler, String uri, String localName, String rawName, Attributes attributes) 49 throws org.xml.sax.SAXException 50 { 51 52 super.startElement(handler, uri, localName, rawName, attributes); 53 try 54 { 55 XSLTElementDef def = getElemDef(); 57 Class classObject = def.getClassObject(); 58 ElemTemplateElement elem = null; 59 60 try 61 { 62 elem = (ElemTemplateElement) classObject.newInstance(); 63 64 elem.setDOMBackPointer(handler.getOriginatingNode()); 65 elem.setLocaterInfo(handler.getLocator()); 66 elem.setPrefixes(handler.getNamespaceSupport()); 67 } 68 catch (InstantiationException ie) 69 { 70 handler.error(XSLTErrorResources.ER_FAILED_CREATING_ELEMTMPL, null, ie); } 72 catch (IllegalAccessException iae) 73 { 74 handler.error(XSLTErrorResources.ER_FAILED_CREATING_ELEMTMPL, null, iae); } 76 77 setPropertiesFromAttributes(handler, rawName, attributes, elem); 78 appendAndPush(handler, elem); 79 } 80 catch(TransformerException te) 81 { 82 throw new org.xml.sax.SAXException (te); 83 } 84 } 85 86 97 protected void appendAndPush( 98 StylesheetHandler handler, ElemTemplateElement elem) 99 throws org.xml.sax.SAXException 100 { 101 102 ElemTemplateElement parent = handler.getElemTemplateElement(); 103 if(null != parent) { 105 parent.appendChild(elem); 106 handler.pushElemTemplateElement(elem); 107 } 108 } 109 110 121 public void endElement( 122 StylesheetHandler handler, String uri, String localName, String rawName) 123 throws org.xml.sax.SAXException 124 { 125 super.endElement(handler, uri, localName, rawName); 126 handler.popElemTemplateElement().setEndLocaterInfo(handler.getLocator()); 127 } 128 } 129 | Popular Tags |