Hey you cocoon professionals!
I wrote the transformer below. It does nothing except
creates an empty temp.xml-file. Why it does not
respond to sax events (from TraxTransformer)?
Appreciate all advice.
Simo K.
package org.apache.cocoon.transformation;
public class StoreTransformer extends
AbstractSAXTransformer {
private String storeKey = null;
private String filePath = "C:\\Program Files\\Apache
Group\\Tomcat 4.1\\webapps\\cocoon\\RF\\store\\";
private PrintWriter out = null;
public void configure(Configuration conf) throws
ConfigurationException {
super.configure(conf);
if (conf != null) {
/*Configuration child;
this.storeKey =
conf.getChild("map:parameter").getAttribute("value");
*/
filePath += "temp.xml";
try {this.out = new PrintWriter(new
FileOutputStream(filePath), true);}
catch(IOException e) {throw new
ConfigurationException("I/O Exception " + e);}
}
}
public void startDocument() throws SAXException {
emit("<?xml version=\"1.0\"
encoding=\"ISO-8859-1\"?>");
}
public void characters(char buf[], int offset, int
len) throws SAXException {
String s = new String(buf, offset, len);
if (textBuffer == null) {
textBuffer = new StringBuffer(s);
} else {
textBuffer.append(s);
}
}
public void startElement(String namespaceURI, String
sName, String qName, Attributes attrs)
throws SAXException
{
String eName = sName; // element name
if ("".equals(eName)) eName = qName; //
not namespaceAware
emit("<"+eName);
if (attrs != null) {
for (int i = 0; i < attrs.getLength();
i++) {
String aName =
attrs.getLocalName(i); // Attr name
if ("".equals(aName)) aName =
attrs.getQName(i);
emit(" ");
emit(aName+"=\""+attrs.getValue(i)+"\"");
}
}
emit(">");
}
public void endElement(String namespaceURI,
String sName, String qName)
throws SAXException
{
String eName = sName; // element name
if ("".equals(eName)) eName = qName; //
not namespaceAware
emit("<"+eName+">");
}
private void emit(String s) throws SAXException
{this.out.write(s);}
}
__________________________________________________
Do You Yahoo!?
Everything you'll ever need on one web page
from News and Sport to Email and Music Charts
http://uk.my.yahoo.com
---------------------------------------------------------------------
Please check that your question has not already been answered in the
FAQ before posting. <http://xml.apache.org/cocoon/faq/index.html>
To unsubscribe, e-mail: <[EMAIL PROTECTED]>
For additional commands, e-mail: <[EMAIL PROTECTED]>