XStandard knowledge base - I get the error message: Code inserted into the editor contains errors and will be discarded. Would you like XStandard to attempt to fix these errors?

The XHTML WYSIWYG Editor For Desktop & Web Applications

I get the error message: "Code inserted into the editor contains errors and will be discarded. Would you like XStandard to attempt to fix these errors?"

The "Operation Failed" dialog box (seen below) is displayed when code loaded into the editor contains errors. Selecting "Yes" in the Operation Failed dialog box requests XStandard to attempt to fix the errors. Selecting "No" discards the data.

Errors will be of two types:

Screenshot of the dialog box: Code inserted into the editor contains errors and will be discarded. Would you like XStandard to attempt to fix these errors?

Incorrect Value <param> tag

Typically, the error is due to putting data that is not HTML escaped into the Value <param> tag. This is an example of an incorrectly constructed Value <param> tag:

  1. <param name="Value" value="<p class="left">Hello World</p>" />

The reason for the error is that the value attribute uses quotes to identify the start and end of content. If the content itself contains quotes, then the Web browser does not know where the content starts or ends and so will pass only a fragment of the content to the editor.

To fix this, HTML reserved characters in the Value param tag need to be HTML escaped, by replacing:

  • & with &amp;
  • < with &lt;
  • > with &gt;
  • " with &quot;

The corrected version of our Value <param> tag will therefore look like this:

  1. <param name="Value" value="&lt;p class=&quot;left&quot;&gt;Hello World&lt;/p&gt;" />

Most scripting environments have functions to escape HTML reserved characters. For example, in ASP, the function is called Server.HTMLEncode(). Check out examples of how to HTML escape content.

Invalid markup

XStandard is an XHTML editor, so the markup inserted into the editor must follow the rules of XML. Below are some of the rules of XML that must be observed when loading content into the editor:

  • Empty elements must be closed. For example, <br> would be written <br /> and <img ...> would be written <img ... />.
  • A non-empty element must have an accompanying closing element. For example, every opening <p> element must be closed by </p>.
  • Attributes need to be quoted. For example, <p class=left> should be written as <p class="left">.
  • Escape & in URLs. For example: <a href="page.php?name=Jack&amp;age=34">.