Forum How do I...?

error on select tag

mrossi
Hello,

I'm trying to use the Java wrapper on a HTML that contains the following fragment at lines 36-39

<select name="xyz" onchange="if (document.forms[0].click && document.forms[0].click.value) { document.forms[0].click.value = ''; } this.form.submit();">
<option>1</option>
<option>2</option>
</select>

The conversion fails, logging the following message

Mon Jul 30 10:54:30 2012: ---- begin
Mon Jul 30 10:54:30 2012: Loading document...
Mon Jul 30 10:54:30 2012: -:36: error: xmlParseEntityRef: no name
Mon Jul 30 10:54:30 2012: -:36: error: xmlParseEntityRef: no name
Mon Jul 30 10:54:30 2012: -: error: could not load input file
Mon Jul 30 10:54:30 2012: error: no input documents to process
Mon Jul 30 10:54:30 2012: finished: failure
Mon Jul 30 10:54:30 2012: ---- end

The same errors are reported when using the Prince GUI, but the conversion at least takes place, producing a PDF showing the first option of the select.

What is the underlying problem? The HTML passes the W3C validator and can be opened by any modern browser.
mikeday
The ampersands need to be escaped, eg. &amp;&amp; not &&.

However, if the document is HTML it should still work. Call prince.setHTML(true) to ensure that the document is not being parsed as XML.
mrossi
Hi,

afaik, the && in the Javascript snippet do not constitute ambiguous ampersands, so in principle they don't need to be escaped in HTML attribute values.

But I can confirm that by invoking setHTML(true) the PDF is indeed produced, even if the log reports errors, and that by escaping the ampersands the errors go away even in the log.

Can you please confirm my doubts about unambiguous ampersands? As said, the W3C HTML5 validator does not complain at all about them.
mikeday
Yes, HTML5 allows unescaped ampersands if they do not form character references. Our new HTML5 parser will not issue errors for this. You can try the new parser with "-i html5" on the command-line, although it is not currently accessible through the GUI or Java interface.