[xsl] replacing <!DOCTYPE> with <?xml-model?> in XSLT

Subject: [xsl] replacing <!DOCTYPE> with <?xml-model?> in XSLT
From: "Chris Papademetrious christopher.papademetrious@xxxxxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Wed, 27 Jul 2022 21:07:19 -0000
Hi everyone,

Given the following XML input:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE topic PUBLIC "-//OASIS//DTD DITA Topic//EN" "topic.dtd">
<topic id="topic">
  <title>My Topic</title>
</topic>

I would like to replace <!DOCTYPE> with <?xml-model?>. With the following:

<!-- remove the <!DOCTYPE> (works!) -->
<xsl:output doctype-system=""/>

<!-- add the <?xml-model?> (does not work) -->
<xsl:template match="/*">
  <xsl:processing-instruction
name="xml-model">href="urn:oasis:names:tc:dita:rng:topic.rng"
schematypens=http://relaxng.org/ns/structure/1.0</xsl:processing-instruction>
  <xsl:next-match/>
</xsl:template>

the <!DOCTYPE> removal works but the <?xml-model?> addition does not. Is there
a trick to emitting a PI before the root element?

If the <!DOCTYPE> gives you a problem when you fiddle with this, you could
probably remove it and just play with the PI addition.

Thanks in advance for any insights!

-----
Chris Papademetrious
Tech Writer, Implementation Group
(610) 628-9718 home office
(570) 460-6078 cell

Current Thread