JavaScript Error IE only - Using YUI DataTable with XML

I am using the YUI Libray DataTable with XML and generating the XML via JDOM in a
Java Servlet. I got this working in Firefox without any errors, but
when I tested in IE7, the DataTable does not display and I get the
following JavaScript error:
'children' is null or not an object

My XML:
<?xml version="1.0" encoding="UTF-8"?>
<ResultSet>
<Result>
<ROUNDS>3</ROUNDS>
<USERNAME>testuser</USERNAME>
<BIRDIES>2</BIRDIES>
<PARS>13</PARS>
<BOGIES>28</BOGIES>
<DOUBLES>11</DOUBLES>
<GH>10</GH>
<FH>10</FH>
<PUTTS>108</PUTTS>
<SCORES>264</SCORES>
</Result>
</ResultSet>

My Javascript:

var myColumnHeaders = [
{key:"ROUNDS",text:"Rounds",type:"number",sortable:true},
{key:"USERNAME",text:"User",sortable:true},
{key:"BIRDIES",text:"Birdies",type:"number",sortable:true},
{key:"PARS",text:"Pars",type:"number",sortable:true},
{key:"BOGIES",text:"Bogies",type:"number",sortable:true},
{key:"DOUBLES",text:"Doubles",type:"number",sortable:true},
{key:"GH",text:"Greens",type:"number",sortable:true},
{key:"FH",text:"Fairways",type:"number",sortable:true},
{key:"PUTTS",text:"Putts",type:"number",sortable:true},
{key:"SCORES",text:"Scores",type:"number",sortable:true},
];
var myColumnSet = new YAHOO.widget.ColumnSet(myColumnHeaders);

// Show over 1000 records
var myDataSource = new YAHOO.util.DataSource("/gw/LeagueStandings");

// Set the responseType as XML
myDataSource.responseType = YAHOO.util.DataSource.TYPE_XML;

// Define the data schema
myDataSource.responseSchema = {
resultNode: "Result", // Node name of each result item
fields:
["ROUNDS","USERNAME","BIRDIES","PARS","BOGIES","DOUBLES","GH","FH","PUTTS","SCOR\
ES"]
// Field names
};


var initialRequest = "get=all&output=xml";
var oConfigs = {
initialRequest:initialRequest,
pageCurrent: 1,
rowsPerPage: 25,
startRecordIndex: 1,
pageLinksLength: 10,
rowsPerPageDropdown: [25,50,100,500]
};
var myDataTable = new YAHOO.widget.DataTable("paginated", myColumnSet,
myDataSource, oConfigs);

I am using a Java Servlet to generate the XML. Any assistance would be
greatly appreciated. Thanks
fortneciAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

GitchoCommented:
this sounds like a tough one ... the ['children' is null or not an object] is an error I've received when the xml response was poorly formed.  Try confirming the XML output from the Java Servlet is formed properly - IE & firefox may be parsing the XML differently, so IE may not pick up on the complete XML document heirarchy.

You're using the firebug in firefox for this kind of debugging, right ? ;)  https://addons.mozilla.org/en-US/firefox/addon/1843
0
fortneciAuthor Commented:
I will run it through firebug and see if I get anything. I wasn't getting anything in the Firefox Error Console.
0
fortneciAuthor Commented:
When I call my servlet from IE it will return the XML. Is there a resource that I can use to verify the XML for well formed?

I didn't pick any errors up in Firebug. Below is a snippet of the servlet code that returns the XML.

            RStoXML rsxml = new RStoXML(results, "ResultSet", "Result");
            //create the XML from recordset
            Document jDOMDoc = rsxml.build();            
            results.close();
            XMLOutputter outputter = new XMLOutputter() ;
            rep.setContentType("text/xml");
            outputter.output( jDOMDoc, rep.getWriter() );
0
The Ultimate Tool Kit for Technolgy Solution Provi

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy for valuable how-to assets including sample agreements, checklists, flowcharts, and more!

fortneciAuthor Commented:
Here is where I am at with this. If anyone has any other ideas, please share.

I have added a DocType to the XML that is being returned in the response, but still can't seem to pass a XML validator with this DTD and XML: Any Suggestions?

DTD:
<!ELEMENT ResultSet (Results*)>
<!ELEMENT Results ANY>
<!ELEMENT ROUNDS (#PCDATA)>
<!ELEMENT USERNAME (#PCDATA)>
<!ELEMENT BIRDIES (#PCDATA)>
<!ELEMENT PARS (#PCDATA)>
<!ELEMENT BOGIES (#PCDATA)>
<!ELEMENT DOUBLES (#PCDATA)>
<!ELEMENT FH (#PCDATA)>
<!ELEMENT GH (#PCDATA)>
<!ELEMENT PUTTS (#PCDATA)>
<!ELEMENT SCORES (#PCDATA)>

XML:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE ResultSet SYSTEM "DTDresultset.dtd">
<ResultSet>
<Result>
<ROUNDS>3</ROUNDS>
<USERNAME>testuser</USERNAME>
<BIRDIES>2</BIRDIES>
<PARS>13</PARS>
<BOGIES>28</BOGIES>
<DOUBLES>11</DOUBLES>
<GH>10</GH>
<FH>10</FH>
<PUTTS>108</PUTTS>
<SCORES>264</SCORES>
</Result>
</ResultSet>

Also, I am still getting the errror in IE and no errors in FireBug
0
fortneciAuthor Commented:
Ok, I got this to return valid XML, but I AM STILL GETTING 'children' is null or not an object ERROR in IE. Below is the new XML and DTD

DTD
<!ELEMENT ResultSet (Result)>
<!ELEMENT Result ANY>
<!ELEMENT ROUNDS (#PCDATA)>
<!ELEMENT USERNAME (#PCDATA)>
<!ELEMENT BIRDIES (#PCDATA)>
<!ELEMENT PARS (#PCDATA)>
<!ELEMENT BOGIES (#PCDATA)>
<!ELEMENT DOUBLES (#PCDATA)>
<!ELEMENT FH (#PCDATA)>
<!ELEMENT GH (#PCDATA)>
<!ELEMENT PUTTS (#PCDATA)>
<!ELEMENT SCORES (#PCDATA)>

XML:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE ResultSet SYSTEM "DTDresultset.dtd">
<ResultSet>
<Result>
<ROUNDS>3</ROUNDS>
<USERNAME>testuser</USERNAME>
<BIRDIES>2</BIRDIES>
<PARS>13</PARS>
<BOGIES>28</BOGIES>
<DOUBLES>11</DOUBLES>
<GH>10</GH>
<FH>10</FH>
<PUTTS>108</PUTTS>
<SCORES>264</SCORES>
</Result>
</ResultSet>
0
GitchoCommented:
Do you still get the error when you strip out the <!DOCTYPE ResultSet SYSTEM "DTDresultset.dtd"> ?
0
fortneciAuthor Commented:
Yes, because the <!DOCTYPE ResultSet SYSTEM "DTDresultset.dtd"> wasn't originally in the XML. I added the DOCTYPE after I explored the option that my XML was malformed and I used a XML validator to validate this XML with this DTD.
0
GitchoCommented:
Nothing in your code is jumping out at me - syntax looks OK .... i can suggest hard coding an xml flat file (with the least amount of code necessary) and point yui to the file instead to see if the error has anything to do with the servelet output.
0
fortneciAuthor Commented:
Thanks, I haven't tried that yet with the properly formatted XML, I will give that a try and let you know. I have hit a wall with this, so any suggestions are good suggestions. Thanks
0
fortneciAuthor Commented:
Found the error. It was in the Javascript, an extra comma at the end of the myColumnHeaders array. Here is the updated Javascript.

var myColumnHeaders = [
{key:"ROUNDS",text:"Rounds",type:"number",sortable:true},
{key:"USERNAME",text:"User",sortable:true},
{key:"BIRDIES",text:"Birdies",type:"number",sortable:true},
{key:"PARS",text:"Pars",type:"number",sortable:true},
{key:"BOGIES",text:"Bogies",type:"number",sortable:true},
{key:"DOUBLES",text:"Doubles",type:"number",sortable:true},
{key:"GH",text:"Greens",type:"number",sortable:true},
{key:"FH",text:"Fairways",type:"number",sortable:true},
{key:"PUTTS",text:"Putts",type:"number",sortable:true},
{key:"SCORES",text:"Scores",type:"number",sortable:true}
];
var myColumnSet = new YAHOO.widget.ColumnSet(myColumnHeaders);

// Show over 1000 records
var myDataSource = new YAHOO.util.DataSource("/gw/LeagueStandings");

// Set the responseType as XML
myDataSource.responseType = YAHOO.util.DataSource.TYPE_XML;

// Define the data schema
myDataSource.responseSchema = {
resultNode: "Result", // Node name of each result item
fields:
["ROUNDS","USERNAME","BIRDIES","PARS","BOGIES","DOUBLES","GH","FH","PUTTS","SCOR\
ES"]
// Field names
};

0
Computer101Commented:
PAQed with points refunded (500)

Computer101
EE Admin
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
JavaScript

From novice to tech pro — start learning today.