Means to specify doctype in XML serializer.

Description

Applications need a way to force a doctype public ID and system ID. For example, an application may want to parse a legacy XHTML 1.1 file:

But the application may want to serialize the document in XHTML5:

Thus the XML serializer needs a way to specify a separate document type public ID and/or system ID, and just as importantly specify that a public ID and/or system ID not be included.

Look at javax.xml.transform.Transformer, which apparently allows setting of doctype public ID and system ID overrides:

Keep in mind that the org.w3c.dom.DocumentType of the serialized document also stores parsed with the original document type, so if some of those entities are used but another doctype is specified, it might result in a a non-well-formed document which could not be read. If the serializer's usePredefinedEntities setting is set to PredefinedEntitiesUse.AS_NEEDED (currently the default), this may not be a problem.

But maybe a better choice altogether would be to allow the caller to simply create a new doctype altogether using DOMImplementation.createDocumentType() and set it in the serializer. This would solve various problems, including the need for an ability to remove the public and/or system ID, and the need to make sure only available entities are used.

Environment

None

Assignee

Garret Wilson

Reporter

Garret Wilson

Labels

None

Components

Fix versions

Affects versions

Priority

Blocker
Configure