The Author Online Book Forums are Moving

The Author Online Book Forums will soon redirect to Manning's liveBook and liveVideo. All book forum content will migrate to liveBook's discussion forum and all video forum content will migrate to liveVideo. Log in to liveBook or liveVideo with your Manning credentials to join the discussion!

Thank you for your engagement in the AoF over the years! We look forward to offering you a more enhanced forum experience.

chrismech (3) [Avatar] Offline

I have thoroughly enjoyed "Ajax in Action" and found practical use for my existing application for the live search example in chapter 12. The only problem is I am pretty new to XSLT and XML, and have run into a problem. I am using IE for my application, but every time I run it I get the following javascript error:
The stylesheet does not contain a document element.
The stylesheet may be empty, or may not be well formed.

Here is the my xsl file:

<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0" xmlnssmiliesl="">
<xsl:template match="/">
<table id="table1">
<th align="left">First Name</th>
<th align="left">Last Name</th>
<th align="left">City</th>
<th align="left">State</th>
<th align="left">DEA</th>
<xsl:for-each select="physicianList/physician">
<td><xsl:value-of select="firstName"/></td>
<td><xsl:value-of select="lastName"/></td>
<td><xsl:value-of select="city"/></td>
<td><xsl:value-of select="state"/></td>
<td><xsl:value-of select="dea"/></td>

As well as a snippet of my Java server-side code that creates the xml:

ArrayList physicianList = (ArrayList);

StringBuffer sb = new StringBuffer();
sb.append("<?xml version='1.0' encoding='utf-8'?>");

if (physicianList.size() > 0)
Iterator physicianIT = physicianList.iterator();

Physician tempPhysician = (Physician);

sb.append("<firstName>" + tempPhysician.getFirstName() + "</firstName>");
sb.append("<lastName>" + tempPhysician.getLastName() + "</lastName>");
sb.append("<city>" + tempPhysician.getCity() + "</city>");
sb.append("<state>" + tempPhysician.getState() + "</state>");
sb.append("<dea>" + tempPhysician.getPhysicianDEA() + "</dea>");
sb.append("<firstName>No Results</firstName>");

response.setHeader("Cache-Control", "no-cache");
response.getWriter().write(sb.toString() + "</physicianList>");

Any thoughts, thanks in advance.

Chris Cornelius
Pascarello (208) [Avatar] Offline
Re: XSLT and XML Help
See if the viewing the XML document directly gives you an error:

chrismech (3) [Avatar] Offline
Re: XSLT and XML Help
Thanks Eric.

I have found that the dynamic xml is fine by running it in IE. The problem now seems to be the xsl file. For some reason it is not being set in the onXSLLoad function. It has "
" in it, does that matter?
Without Firebug debugging this would have been alot harder. Does anyone know of a good xml editor?


Message was edited by:
chrismech (3) [Avatar] Offline
Re: XSLT and XML Help
After further debugging sessions using Firebug, I noticed that the content-type for the xsl file was set to "text/plain" so I ran the file through my server code and set the response to "text/xml" and now it seems to be working.

Thanks again for the tips,