aspose file tools*
The moose likes XML and Related Technologies and the fly likes Content is not allowed in prolog. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "Content is not allowed in prolog." Watch "Content is not allowed in prolog." New topic
Author

Content is not allowed in prolog.

LazyCoder
Greenhorn

Joined: Jul 08, 2004
Posts: 11
org.xml.sax.SAXParseException: Content is not allowed in prolog.
at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
at org.apache.fop.apps.Driver.render(Driver.java:424)
at org.apache.fop.apps.Driver.run(Driver.java:508)
at com.portal.PDFWriter.printDocument(PDFWriter.java:83)
at com.portal.PDFWriter.<init>(PDFWriter.java:32)
at com.portal.PDFWriter.main(PDFWriter.java:93)

can anybody suggest why we get the above
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12769
    
    5
Probably the start of your document is not clean - perhaps an extra character or two accidently got in. You should be able to extract the line and column it is objecting to from the SAXException.
Bill
[ November 05, 2004: Message edited by: William Brogden ]
Anonymous
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
William is right.
Actually I faced such a problem when I had saved an xml document's specific parts from within Windows Notepad into UltraEdit (via CTRL-C CTRL-V) The 1st hexadecimal numbers are: FFFE 3C00 3F00 7800 6D00 6C00 which maps to FFFE<?xml By the way FFFE: means Unicode UTF-8 Big Endian Encoding .
Actually nothing was wrong. I donot figure out WHY but it is so.. then I chose DOS Schema and could process the files.
[ February 18, 2005: Message edited by: R�stem-� Zal� ]
Rashmi Gouder
Greenhorn

Joined: Jan 02, 2006
Posts: 3
I dont have access to UNIX system, cant test if my xml file has those special characters before the prolog.

but heres my code

<%@ page language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jstl/core" %>
<%@ taglib prefix="x" uri="http://java.sun.com/jsp/jstl/xml" %>
<html>
<head>
<title></title></head>
<body>
<c:import url="test5.xml" var="xml" charEncoding="ISO-8859-1"/>
<x arse xml="${xml}" varDom="doc" />
</body>
</html>

this is my xml file, but I still get the error "Content is not allowed in prolog"

<?xml version="1.0" encoding="ISO-8859-1"?>
<test><value1>valuex</value1></test>

this is really frustrating, what can I do to fix this problem, when I dont have access to Unix or Linux

Is there an editor for Windows which allows me to check for the special characters which appear before the prolog?


-Rashmi
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12769
    
    5

All of that goes into the output stream before your XML - no wonder you get that error. Your central mistake is trying to use a JSP where you should be using a servlet.
Bill
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Content is not allowed in prolog.