stochastic13
stochastic13

Reputation: 423

"hl" must end with delimeter error in google gadget code

I am trying to use a custom google gadget in a google site so as to be able to use javascript. I have put the code below. It basically links to a published spreadsheet, and creates a sortable, searchable interface using the google visualisation API.

I do not know any free site to host a XML file. So I uploaded the file in the same google-site page, and used the download link of that file as the URL in the add gadget dialogue box. I got the following error.

The gadget you added is not valid

Unsupported feature: org.apache.shindig.common.xml.XmlException: The reference to entity "hl" must end with the ';' delimiter. At: (34,97)

I do not understand the problem here.There is no entity "hl" in the code except in the link to the spreadsheet, which I have linked properly, as far as I know. How to fix this?

I am very new to HTML/Javascript. I did a google search for the problem, but could not find the same issue. A lot of other cases with the error had some server error.

Here's the code:

<?xml version="1.0" encoding="UTF-8" ?> 
<Module>
  <ModulePrefs title="Database Search" /> 
  <Content type="html">

<html>
<head>

<title>Example of Google Spreadsheet Data Visualisation</title>
</head>

<body>

<form id="form1" method="post" > <label>
<input id="search" name="search" type="text" />
</label>
<label>
<input type="submit" />
</label>
</form>
<p>


<script type="text/javascript" src="http://www.google.com/jsapi"></script>
<script type="text/javascript">
      google.load('visualization', '1', {packages: ['table']});
</script>
<script type="text/javascript">
    var visualization;

    function drawVisualization() {

      var query = new google.visualization.Query(
          'http://spreadsheets.google.com/tq?key=0Au0WkOi_oKm0dDNwYkUxRkRqUzVKa1ZEWnFyYXpnaWc&hl=en_GB');

      query.setQuery('SELECT A, B, C where upper(A) like upper("%<?php echo $search; ?>%") or upper(B) like upper("%<?php echo $search; ?>%") order by A asc label A "Type", B "Title", C "Date added"');

      query.send(handleQueryResponse);
    }

    function handleQueryResponse(response) {
      if (response.isError()) {
        alert('Error in query: ' + response.getMessage() + ' ' + response.getDetailedMessage());
        return;
      }

      var data = response.getDataTable();

     visualization = new google.visualization.Table(document.getElementById('table'));
     visualization.draw(data, {legend: 'bottom'});

    }

    google.setOnLoadCallback(drawVisualization);
    </script>

   <div id="table"></div>

</div>

</body>
</html>
  </Content> 
</Module>

Upvotes: 0

Views: 760

Answers (1)

ThW
ThW

Reputation: 19492

It's the url ...naWc&hl=en_GB. It seems that it is used in an XML context. So it thinks the & is the start of an XML entity. The syntax for entities is &...; (Example: &gt;). = is not allowed in an entity so the parser ends up with &hl and reporting the missing ;.

You need to encode the & as an entity itself (&amp;) to avoid this error.

But are you sure that you can provide an URL to this method? From the error I would more expect an XML string.

Upvotes: 1

Related Questions