Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>So... Finally I made it. Still there is a small bug </p> <blockquote> <p>SystemId Unknown; Line #-1; Column #-1; Premature end of file.</p> </blockquote> <p>but I hope it is one not very difficult to fix.<br><br> As you can see below the output stream is now written to StringWriter, and then StringWriter is written to a XML file. Still I can't understand why there is no result (file is just cleared) if you pass a file to StreamResult. May be just my hands growing out of a wrong place. May be I'll make a little research tomorrow. </p> <p>So, method executeWrite(...) was changed a lot</p> <pre><code> protected void executeWrite(PrintWriter out, ReadWriteLock readWriteLock, Transformer transformer) throws HandledException { Lock readLock = readWriteLock.readLock(); StringWriter outWriter = new StringWriter(); Transformer t = null; try { readLock.lock(); StreamSource xmlStream = new StreamSource(/*path to XML*/); t = transformer; t.transform(xmlStream, new StreamResult(outWriter)); } catch (TransformerException e) { ExceptionHandler.logAndThrow(e, logger); } finally { readLock.unlock(); } Lock writeLock = readWriteLock.writeLock(); FileWriter fileWriter = null; try { writeLock.lock(); fileWriter = new FileWriter(new File(/*path to XML*/)); fileWriter.write(outWriter.toString()); } catch (IOException e) { ExceptionHandler.logAndThrow(e, logger); } finally { if (fileWriter != null) { try { fileWriter.close(); } catch (IOException e) { ExceptionHandler.logAndThrow(e, logger); } } writeLock.unlock(); } } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload