Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
 package com.xmlcalabash.extensions.fileutils;
 
Created by IntelliJ IDEA. User: ndw Date: May 24, 2009 Time: 3:17:23 PM To change this template use File | Settings | File Templates.
public class Touch extends DefaultStep {
    private static final QName _href = new QName("href");
    private WritablePipe result = null;

    
Creates a new instance of UriInfo
    public Touch(XProcRuntime runtimeXAtomicStep step) {
        super(runtime,step);
    }
    public void setOutput(String portWritablePipe pipe) {
         = pipe;
    }
    public void reset() {
        .resetWriter();
    }
    public void run() throws SaxonApiException {
        super.run();
        if (.getSafeMode()) {
            throw XProcException.dynamicError(21);
        }
        RuntimeValue href = getOption();
        URI uri = href.getBaseURI().resolve(href.getString());
        File file;
        if (!"file".equals(uri.getScheme())) {
            throw new XProcException(.getNode(), "Only file: scheme URIs are supported by the touch step.");
        } else {
            file = new File(uri.getPath());
        }
        TreeWriter tree = new TreeWriter();
        tree.startDocument(.getNode().getBaseURI());
        tree.startContent();
        tree.addText(file.toURI().toASCIIString());
        try {
            file.createNewFile();
        } catch (IOException ioe) {
            throw new XProcException(ioe);
        }
        
        tree.addEndElement();
        tree.endDocument();
        .write(tree.getResult());
    }
New to GrepCode? Check out our FAQ X