This week's book giveaway is in the Jobs Discussion forum.
We're giving away four copies of Java Interview Guide and have Anthony DePalma on-line!
See this thread for details.
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

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "Content is not allowed in prolog." Watch "Content is not allowed in prolog." New topic

Content is not allowed in prolog.


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(
at com.portal.PDFWriter.printDocument(
at com.portal.PDFWriter.<init>(
at com.portal.PDFWriter.main(

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

Joined: Mar 22, 2000
Posts: 13037
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.
[ November 05, 2004: Message edited by: William Brogden ]
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

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="" %>
<%@ taglib prefix="x" uri="" %>
<c:import url="test5.xml" var="xml" charEncoding="ISO-8859-1"/>
<x arse xml="${xml}" varDom="doc" />

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"?>

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?

William Brogden
Author and all-around good cowpoke

Joined: Mar 22, 2000
Posts: 13037

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.
I agree. Here's the link:
subject: Content is not allowed in prolog.
It's not a secret anymore!