Solucionado (ver solução)
Solucionado
(ver solução)
3
respostas

ERRO AULA 6 VIDEO 1

CÓDIGO

package br.com.alura.Teste;

import java.io.FileInputStream;
import java.io.InputStream;

import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.stream.StreamResult;
import javax.xml.transform.stream.StreamSource;

public class ConversorParaHtml {
    public static void main(String[] args) throws Exception {
        InputStream xsl = new FileInputStream("src/xmlParaHtml.xsl");
        StreamSource xslSource = new StreamSource(xsl);

        InputStream dados = new FileInputStream("src/vendas.xml");
        StreamSource xmlSource = new StreamSource(dados);

        Transformer transformer = TransformerFactory.newInstance().newTransformer(xslSource);
        StreamResult saida = new StreamResult("src/vendas.xml");
        transformer.transform(xmlSource, saida);

    }
}

SAÍDA

ERROR:  'Fim prematuro do arquivo.'
ERROR:  'com.sun.org.apache.xml.internal.utils.WrappedRuntimeException: Fim prematuro do arquivo.'
Exception in thread "main" javax.xml.transform.TransformerException: javax.xml.transform.TransformerException: com.sun.org.apache.xml.internal.utils.WrappedRuntimeException: Fim prematuro do arquivo.
    at com.sun.org.apache.xalan.internal.xsltc.trax.TransformerImpl.transform(Unknown Source)
    at com.sun.org.apache.xalan.internal.xsltc.trax.TransformerImpl.transform(Unknown Source)
    at br.com.alura.Teste.ConversorParaHtml.main(ConversorParaHtml.java:21)
Caused by: javax.xml.transform.TransformerException: com.sun.org.apache.xml.internal.utils.WrappedRuntimeException: Fim prematuro do arquivo.
    at com.sun.org.apache.xalan.internal.xsltc.trax.TransformerImpl.getDOM(Unknown Source)
    ... 3 more
Caused by: com.sun.org.apache.xml.internal.utils.WrappedRuntimeException: Fim prematuro do arquivo.
    at com.sun.org.apache.xalan.internal.xsltc.dom.XSLTCDTMManager.getDTM(Unknown Source)
    at com.sun.org.apache.xalan.internal.xsltc.dom.XSLTCDTMManager.getDTM(Unknown Source)
    ... 4 more
---------
javax.xml.transform.TransformerException: com.sun.org.apache.xml.internal.utils.WrappedRuntimeException: Fim prematuro do arquivo.
    at com.sun.org.apache.xalan.internal.xsltc.trax.TransformerImpl.getDOM(Unknown Source)
    at com.sun.org.apache.xalan.internal.xsltc.trax.TransformerImpl.transform(Unknown Source)
    at com.sun.org.apache.xalan.internal.xsltc.trax.TransformerImpl.transform(Unknown Source)
    at br.com.alura.Teste.ConversorParaHtml.main(ConversorParaHtml.java:21)
Caused by: com.sun.org.apache.xml.internal.utils.WrappedRuntimeException: Fim prematuro do arquivo.
    at com.sun.org.apache.xalan.internal.xsltc.dom.XSLTCDTMManager.getDTM(Unknown Source)
    at com.sun.org.apache.xalan.internal.xsltc.dom.XSLTCDTMManager.getDTM(Unknown Source)
    ... 4 more
---------
3 respostas
solução!

Fala ai Paulo, tranquilo ?

Cara pelo erro parece que o arquivo acabou antes do previsto pelo código, o que está gerando essa exception.

Ah cara eu vi aqui qual foi o problema, vlw.

Boa !