EOFException when reading in streamSource from String

Discussion in 'Java' started by jwasp, May 8, 2009.

  1. jwasp

    jwasp

    Joined:
    Dec 5, 2007
    Messages:
    2
    Likes Received:
    0
    I have something like:

    String baseXSL = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n .... "

    (I want to be able to modify the XSL on the fly)

    Then I create a streamSource like ...

    StreamSource theXSL = new StreamSource(new ByteArrayInputStream(baseXSL.getBytes()));

    for use in something like ...

    Templates template = tFactory.newTemplates(theXSL);
    Transformer xslTrans = template.newTransformer();

    ByteArrayOutputStream byteStream = new ByteArrayOutputStream();
    Result res = new StreamResult(byteStream);

    xslTrans.transform(theXML, res);

    I get an:
    ERROR Servlet.service() for servlet action threw exception
    java.io.EOFException
    when trying to build the streamSource out of the String instead of out of a filePath (which works just fine).

    Any ideas?

    TIA!
     
    jwasp, May 8, 2009
    #1
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.