How can I prevent the Java XML Transformer from using the "HTML" method to add the <META> tag?
I use the built-in Java XML Transformer to serialize an XML document into text. I have a problem, but when I output in HTML mode.
Whenever I insert an element head, the built-in transformer decides to insert a tag METAwith data such as content. I do not want this tag to be inside my data, and I cannot find an output parameter that will disable this function. I know that I could create an xslt stylesheet and remove the corresponding tag, but it would be easier to just set the parameter on the transformer itself, which will disable it.
You can answer "but you really should have this tag" - believe me, I don’t need it, for brevity I won’t go into it.
Code example
Document d;
//d = <html><head><title></title></head><body></body></html>
Transformer t; //properly inited with no xslt specified
t.setOutputProperty(OutputKeys.METHOD,"html");
t.setOutputProperty(OutputKeys.INDENT,"no");
t.transform(new DOMSource(d), result);
System.out.println(result);
returns
<html><head><META http-equiv="Content-Type" content="text/html; charset=UTF-8"><title></title><style type="text/css"></style></head><body></body></html>
Case, I do not want the tag METAthere. How can I get rid of it in the easiest way?
UPDATE:
I came across an option {http://xml.apache.org/xalan}omit-meta-tagthat should do what I'm looking for. However, it seems to be ignored.