Examples of SAXConsumer


Examples of org.apache.cocoon.sax.SAXConsumer

import org.xml.sax.SAXException;

public class TimestampGenerator extends AbstractSAXGenerator {

    public void execute() {
        SAXConsumer consumer = this.getSAXConsumer();
        try {
            try {
                Thread.sleep(500);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }

            consumer.startDocument();
            consumer.startElement("", "timestamp", "timestamp", new ImmutableAttributesImpl());
            String timestamp = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.S").format(new Date());
            consumer.characters(timestamp.toCharArray(), 0, timestamp.length());
            consumer.endElement("", "timestamp", "timestamp");

            consumer.endDocument();
        } catch (SAXException e) {
            throw new ProcessingException(e);
        }
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.