3

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.

pk.avj
  • 131
  • 3
  • 11

1 Answers1

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