Oi, alguém já usou DOMParser. Nunca usei, e estou encontrando problemas.
Quero recuperar um XML e executar o parse em um objeto DOMParse. Mas etsou me deparando com uma exceção.
protected InputStream cStream = new ByteArrayInputStream(request.getSession().getServletContext().getInitParameter("orcamento-config").getBytes());
InputSource inputSource = new InputSource();
inputSource.setByteStream(cStream);
DOMParser domParser = new DOMParser();
domParser.parse(inputSource);
A exceção é a seguinte:
17:38:56,437 INFO [STDOUT] [Fatal Error] :1:1: Content is not allowed in prolog.
17:38:56,437 INFO [STDOUT] org.xml.sax.SAXParseException: Content is not allowed in prolog.
17:38:56,437 INFO [STDOUT] at org.apache.xerces.parsers.DOMParser.parse(Unknown Source)
17:38:56,437 INFO [STDOUT] at prj_panteon.mod_orcamento.apl_orcamento_compras.BuscarOrcamentoCompras.getFlgOrcamentoPorItem(BuscarOrcamentoCompras.java:130)
17:38:56,437 INFO [STDOUT] at org.apache.jsp.prj_005fpanteon.mod_005forcamento.apl_005forcamento_005fcompras.jsp.cad_005fselect_005fitem_jsp._jspService(cad_005fselect_005fitem_jsp.java:79)
17:38:56,437 INFO [STDOUT] at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:94)
17:38:56,453 INFO [STDOUT] at javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
17:38:56,453 INFO [STDOUT] at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:324)
17:38:56,453 INFO [STDOUT] at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
17:38:56,453 INFO [STDOUT] at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
17:38:56,453 INFO [STDOUT] at javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
17:38:56,453 INFO [STDOUT] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:237)
17:38:56,453 INFO [STDOUT] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:157)
17:38:56,453 INFO [STDOUT] at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:75)
17:38:56,453 INFO [STDOUT] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:186)
17:38:56,453 INFO [STDOUT] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:157)
17:38:56,453 INFO [STDOUT] at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:214)
17:38:56,453 INFO [STDOUT] at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
17:38:56,468 INFO [STDOUT] at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
17:38:56,468 INFO [STDOUT] at org.apache.catalina.core.StandardContextValve.invokeInternal(StandardContextValve.java:198)
17:38:56,468 INFO [STDOUT] at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:152)
17:38:56,468 INFO [STDOUT] at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
17:38:56,468 INFO [STDOUT] at org.jboss.web.tomcat.security.CustomPrincipalValve.invoke(CustomPrincipalValve.java:66)
17:38:56,468 INFO [STDOUT] at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:102)
17:38:56,468 INFO [STDOUT] at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:150)
17:38:56,468 INFO [STDOUT] at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:102)
17:38:56,468 INFO [STDOUT] at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:54)
17:38:56,468 INFO [STDOUT] at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:102)
17:38:56,468 INFO [STDOUT] at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
17:38:56,468 INFO [STDOUT] at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:137)
17:38:56,468 INFO [STDOUT] at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
17:38:56,468 INFO [STDOUT] at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:118)
17:38:56,468 INFO [STDOUT] at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:102)
17:38:56,468 INFO [STDOUT] at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
17:38:56,484 INFO [STDOUT] at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
17:38:56,484 INFO [STDOUT] at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
17:38:56,484 INFO [STDOUT] at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
17:38:56,484 INFO [STDOUT] at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:929)
17:38:56,484 INFO [STDOUT] at org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:160)
17:38:56,484 INFO [STDOUT] at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:799)
17:38:56,484 INFO [STDOUT] at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:705)
17:38:56,484 INFO [STDOUT] at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:577)
17:38:56,484 INFO [STDOUT] at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:683)
17:38:56,484 INFO [STDOUT] at java.lang.Thread.run(Thread.java:595)
… na última instrução.
Já ajuda muito se eu conseguir imprimir o conteúdo do meu InputStream pu InputSource, mas eu não sei fazer isso
Qualquer ajuda é bem vinda.
Meu XML:
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE orcamento-policies SYSTEM "orcamento-policies.dtd">
<orcamento-policies>
<definitions>
<filial>1</filial>
<agrupamento>2</agrupamento>
<orc-item>1</orc-item>
</definitions>
</orcamento-policies>