I put my code in the XML validation website and it gives me this error:
Line 8: 4 The markup in the document following the root element must be well-formed.
The line that is having an issue is the <xsl:output method = "html" doctype-system = "about:legacy-compat"/>
, line.
<?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 -->
<xsl:template match="/"> -<html> <xsl:apply-templates/> </html>
</xsl:template>
The XML root element represents the XML document that is being mapped. The XML root element is a looping structure that contains elements and content particles that repeat in sequence until either the group data ends or the maximum number of times that the loop is permitted to repeat is exhausted.
The markup in the document following the root element must be well-formed.
This error indicates that your XML has markup following the root element. In order to be well-formed, XML must have exactly one root element, and there can be no further markup following the single root element.
One root element example (GOOD)
<r>
<a/>
<b/>
<c/>
</r>
The most common sources for this error are:
Including stray or extra close tags (BAD):
<r>
<a/>
<b/>
<c/>
</r>
</r> <!-- shouldn't be here -->
Intentionally having multiple root elements (BAD):
<a/>
<b/> <!-- second root element shouldn't be here -->
<c/> <!-- third root element shouldn't be here -->
Unintentionally having multiple root elements (BAD):
<r/> <!-- shouldn't be self-closing -->
<a/>
<b/>
<c/>
</r>
Parsing different XML than you think (BAD):
Log the XML immediately before providing to the parse that's failing in order to make sure that the XML that the parser is seeing is the same as the XML you think it's seeing. Common errors here include:
In your particular case, your XML appears to have multiple root elements because the xsl:stylesheet
element is closed prematurely (case #3 above).
Change
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"/>
to
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
to fix your immediate problem, and add a closing tag,
</xsl:stylesheet>
if one does not already exist in your real document.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With