Annoying errors "ID foo already defined"
Princing<!DOCTYPE html>
<html><body>
<a href="#somename">Down</a>
<a name="somename" id="somename">test</a>
</body></html>
results in the warning
prince: princetest.html:4: error: ID somename already defined
Although <a name=".." is deprecated, it's still valid and needed for older browsers. In pages with lots of such constructs (
http://en.wikipedia.org/wiki/Glossary_of_cue_sports_terms), prince spews out hundreds or thousands of error messages. Prince should ignore the name attribute when id is present.
Did you verify that "somename" really is unique?
Jim Albright
Wycliffe Bible Translators
This is an issue with the HTML parser that we are using, we will try to resolve it in a future release.
We have now released Prince 9, with a new HTML parser that does not complain about duplicate name/id attributes.
@mikeday - I'm seeing this error again in Prince 10. I have existing documents that used to export without any problems. Now, with Prince 10, I get errors like <ID THE_ID already defined>. Can the Prince 9 behavior be reinstated?
Trevor DeVore
ScreenSteps
http://www.screensteps.com
Are you specifying -i html4 or calling SetInputType() in the server wrappers? Because by default you should not get these error messages.
I'm calling from the command line and I'm not specifying an input type. Here is what I call from the command line (with long paths removed):
"./prince" --server --baseurl=file:///article-layout.html --javascript -s "pdf_styles.css" "layout.html" -o "output.pdf"
And here is the header of the HTML file which I've been using since Prince 7 or 8 I believe:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<meta charset="utf-8"/>
Trevor DeVore
ScreenSteps
http://www.screensteps.com
Oh, and here is the HTML with matching div ids:
<div id="Step-Test" class="step-container">
</div>
<div id="Step-Test" class="step-container">
What happens is that multiple documents which can stand on their own can be combined into a single PDF. While the documents themselves don't have conflicting ids, sometimes different documents will.
Trevor DeVore
ScreenSteps
http://www.screensteps.com
Because you have specified an XHTML DTD, Prince will be treating the document as XML, which has stricter syntax rules. You can override this by specifying "-i html" on the command-line.
For the next release of Prince we are changing this behaviour so that files with a .html extension will be treated as HTML by default, and the XHTML DOCTYPE will be ignored (it is useless anyway).
Thanks,
-i html
worked @mikeday.
Trevor DeVore
ScreenSteps
http://www.screensteps.com
Hi Mike,
today I used PrinceXML 14.3 to convert an HTML file that has links to SVG graphs. Two graphs had duplicate IDs, and Prince hung at the error "error: ID xxxx already defined". Only after manually editing the SVG code and removing the duplicate would Prince work without hiccup.
It would be good if I could configure Prince to ignore duplicate IDs as I don't have control over the SVGs supplied by authors.
Here's the offending SVG code prior to my manual remediation:
<g id="Layer-1" data-name="Text"></g><g id="Layer-1" data-name="References"></g><g id="Layer-1" data-name="Layer 9"></g><g id="Layer-1" data-name="Circles"></g><g id="Layer-1" data-name="BG grey and line"></g><g id="Layer-1" data-name="text"></g><g id="Layer-1" data-name="Original price"></g><g id="Layer-1" data-name="Cost Push"></g>...
Prince should not hang in this situation, was the output being piped somewhere and it blocked?
Hi Mike,
yes, sorry, my app hangs when Prince encounters that error.
Does it hang in other situations with errors, like if you called Log.error("blah") many times from JavaScript? If you call Prince via the .NET or Java wrappers it should handle this situation properly for you.
I'm using PowerShell for the logic around Prince. I've never had this issue before, and it likely only appeared because those two SVGs were from different authors.
You may need to use the --structured-log option to buffer error output, depending on exactly how your app is reading from the stdout and stderr streams, to avoid blocking.