XML, XLST and Encodings

I have a relatively simple Java servlet that does some magic with a database and generates some XML.

The JSP that calls this servlet imports a transform to render the XML. This worked seemlessly until I deployed it live. Its probably worth noting that my development machine is Windows XP, and I believe my deployment environment to be Solaris.

When it was deployed live I got an error similar to this (unfortunately I didn’t record the actual error at the time):

javax.servlet.ServletException: javax.servlet.jsp.JspException: Could not compile stylesheet

I then checked the GlassFish server logs and found entries along the lines of:

:1:1: Content is not allowed in prolog

After much searching around and checking, I found these 3 common fixes:

1. Make sure there is no leading white space before the ‘<xml’ tag. This wasn’t applicable to me.
2. Make sure the XML is correctly formatted. This wasn’t applicable to me.
3. Make sure the xml tag has an encoding specified, and that this encoding matches the encoding specified in the transform.


Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s