Actions
Bug #5852
closedXML Transformer generates invalid XHTML
Status:
Closed
Priority:
Normal
Assignee:
-
Category:
Serialization
Sprint/Milestone:
-
Start date:
2023-01-24
Due date:
% Done:
100%
Estimated time:
Legacy ID:
Applies to branch:
11, 12, trunk
Fix Committed on Branch:
11, 12, trunk
Description
I am using Saxon-HE 11.4 to serialize a XHTML document.
The document already defines the meta
element :
<meta charset="utf-8"/>
Using the xml transformer, the MetaTagAdjuster now adds an additional meta
element:
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
Having these two charset declarations in the XHTML document is illegal.
We can avoid inserting the content type at all with this setting:
transformer.setOutputProperty(SaxonOutputKeys.INCLUDE_CONTENT_TYPE, "no")
However, I think the MetaTagAdjuster should check if the charset is already defined.
Example: When having the following
<?xml version="1.0" encoding="UTF-8"?>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta charset="utf-8" />
</head>
</html>
in a Document object and transforming it to written XHTML. It results in
<?xml version="1.0" encoding="UTF-8"?>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta charset="utf-8" />
</head>
</html>
Please register to edit this issue
Actions