How to fix the problem: Make sure the markup after the document root element is well-formed
P粉590428357
2023-08-21 22:01:26
<p>I put my code on the XML validation website and it gave me this error: </p>
<blockquote>
<p>Line 8: The document markup after the 4 root element must be well-formed. </p>
</blockquote>
<p>The problematic line is <code><xsl:output method = "html" doctype-system = "about:legacy-compat"/></code>. </p>
<h2>XML</h2>
<pre class="brush:php;toolbar:false;"><?xml version="1.0"?>
<!-- Fig. 15.21: sorting.xsl -->
<xsl:stylesheet version = "1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"/>
<!-- Write XML declaration and DOCTYPE DTD information -->
*<xsl:output method = "html" doctype-system = "about:legacy-compat" />*
<!-- Match document root element -->
<xsl:template match="/"> -<html> <xsl:apply-templates/> </html>
</xsl:template></pre>
<p><br /></p>
This may also occur due to incorrect whitespace in this file
General situation
This error means that your XML has tags after the root element. To comply with well-formed requirements, XML must have only one root element, and no other tags after the single root element .
An example of a root element (correct)
The most common causes of this error are:
Contains extra closing tags (error):
Intentionally having multiple root elements (error):
Inadvertently having multiple root elements (error):
The parsed XML is different than you think (wrong):
Log the XML immediately before feeding it to the parser to ensure that the XML the parser sees is the same XML you think it is. Common mistakes here include:
Your specific question
In your specific case, your XML appears to have multiple root elements because the
xsl:stylesheet
element is closed prematurely (case #3 above).Will
change to
to address your immediate question and add a closing tag
If it doesn't exist yet in your actual document.