1 16 package org.apache.cocoon.taglib.core; 17 18 import org.apache.cocoon.ProcessingException; 19 import org.apache.cocoon.components.source.SourceUtil; 20 import org.apache.cocoon.taglib.XMLProducerTagSupport; 21 import org.apache.cocoon.xml.EmbeddedXMLPipe; 22 23 import org.apache.excalibur.source.Source; 24 25 import org.xml.sax.SAXException ; 26 27 31 public class SourceTag extends XMLProducerTagSupport { 32 private String src; 33 34 public void setSrc(String src) { 35 this.src = src; 36 } 37 38 41 public int doEndTag(String namespaceURI, String localName, String qName) 42 throws SAXException { 43 Source source = null; 44 try { 45 source = resolver.resolveURI(src); 46 SourceUtil.toSAX(source, new EmbeddedXMLPipe(this.xmlConsumer)); 47 } catch (SAXException e) { 48 throw e; 49 } catch (Exception e) { 50 if (e instanceof ProcessingException) { 51 ProcessingException pe = (ProcessingException) e; 52 Throwable t = pe.getCause(); 53 if (t != null && t instanceof SAXException ) 54 throw (SAXException ) t; 55 } 56 throw new SAXException (e.getMessage(), e); 57 } finally { 58 if (source != null) { 59 resolver.release(source); 60 } 61 } 62 return EVAL_PAGE; 63 } 64 65 68 public void recycle() { 69 this.src = null; 70 super.recycle(); 71 } 72 } 73 | Popular Tags |