Project

Profile

Help

Bug #6212

closed

net.sf.saxon.s9api.Serializer tries to guess doctype from content and fails at it.

Added by Vivien Guillet 8 months ago. Updated 6 months ago.

Status:
Closed
Priority:
Low
Assignee:
Category:
Documentation
Sprint/Milestone:
-
Start date:
2023-10-02
Due date:
% Done:

100%

Estimated time:
Legacy ID:
Applies to branch:
12, trunk
Fix Committed on Branch:
12, trunk
Fixed in Maintenance Release:
Platforms:
Java

Description

Given a org.w3c.dom.Document named doc, I run serialisation using

Processor processor = new Processor(false);
Serializer serializer = processor.newSerializer();
Source domSource = new DOMSource(doc);
String s = serializer.serializeToString(domSource);

When the root node of the document is anything other than html the document is correctly serialized, but is incorrectly serialized when the root element is html

i.e. a document consisting of only a root node whose tagName is " ztml " is serialized as

<?xml version="1.0" encoding="UTF-8"?><ztml/>

But if the tagName of the root node append to be " html ", the serializer makes a wild guess at the doctype and outputs

The root node should not be used to guess the doctype resulting in some xml documents beeing serialized as a html documents.

(If a temporary fix or bypass exists for it, it would be great for now !)

Thanks.

Please register to edit this issue

Also available in: Atom PDF