I am transforming xml to another xml using XSLT. Some xmls will have DOCTYPE declaration and some donot. I am trying to insert doctype declaration from XSLT stylesheet but I couldn't find enough information on How to do that.
Asked
Active
Viewed 2,310 times
3
-
3https://www.w3.org/TR/xslt/#output – michael.hor257k Feb 05 '17 at 00:26
-
Possible duplicate of [Set HTML5 doctype with XSLT](http://stackoverflow.com/questions/3387127/set-html5-doctype-with-xslt). The accepted answer is outdated, but there is plenty of information in the other answers. – Mathias Müller Feb 06 '17 at 12:54
1 Answers
5
You can easily add a doctype declaration with the xsl:output element:
<xsl:output
method="xml"
standalone="no"
doctype-public="-//Org//DTD XYZ 2017-02-06//DE"
doctype-system="myStructure.dtd"
/>
With "doctype-public" you define the PUBLIC identifier and with "doctype-system" the filename of your DTD. The xsl:output element typically is at the top of your XSL right after xsl:stylesheet (or xsl:import if any).

SomeStupid
- 101
- 1
- 10