开发者

WrappedRuntimeException during processing of an XSLT transformation

开发者 https://www.devze.com 2022-12-23 18:18 出处:网络
I\'m using this code to generate contents file. try { StreamResult result = new StreamResult(); TransformerFactory tf = TransformerFactory.newInstance();

I'm using this code to generate contents file.

try {
        StreamResult result = new StreamResult();
        TransformerFactory tf = TransformerFactory.newInstance();
        Templates templ =  tf.newTemplates(xsltSource);
        Transformer transf = templ.newTransformer();
        for (String item: groups){
            item = item.replaceAll(" ", "-").toLowerCase();
            result.setOutputStream(new FileOutputStream(path+item+".html"));
            transf.clearParameters();
            transf.setParameter("group", item);
            transf.transform(xmlSource, result);
        }
    } catch (TransformerConfigurationException e) {
    throw new SinkException(e.getMessage());
    } catch (TransformerException e) {
    throw new SinkException(e.getMessage());
    }

But on second iteration I have an exception

ERROR: javax.xml.transform.TransformerException: com.sun.org.apache.xml.internal.utils.WrappedRuntimeException: Read error

Cann't understand what开发者_如何学运维 is the reason?


Thank a lot for assistance. Th error was in not properly closed Source resource. Was:

Source xmlSource = new StreamSource(new FileInputStream(path+Constants.MANIFEST_FILE_NAME));

Fixed:

Source xmlSource = new StreamSource(path+Constants.MANIFEST_FILE_NAME);
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号