How to add internal DTD subset to the newly created xml file using javax.xml
Posted: Sun Oct 02, 2022 8:19 am
Hello Team , I know this is a general java question
am using the API
import javax.xml.parsers.DocumentBuilder;
import javax.xml.transform.Transformer;
to create a xml
I am trying to add the DOCTYPE and DTD declaration as below
but my final doctype declaration should be
I want add at the end an empty internal subset [] ..how to do this in java ?
am using the API
import javax.xml.parsers.DocumentBuilder;
import javax.xml.transform.Transformer;
to create a xml
I am trying to add the DOCTYPE and DTD declaration as below
Code: Select all
TransformerFactory transformerFactory = TransformerFactory.newInstance();
transformer = transformerFactory.newTransformer();
transformer.setOutputProperty(
OutputKeys.DOCTYPE_PUBLIC, "-//XXX//DTD XXX YYY XXX//EN");
transformer.setOutputProperty(
OutputKeys.DOCTYPE_SYSTEM, "XXX.dtd");
Code: Select all
DOCTYPE XXX PUBLIC "-//XXX//DTD XXX YYY XXX//EN" "XXX.dtd"[]