I am using Saxon-He to process this code (I used this post to get the idea):
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0">
<xsl:key name="elelsById" match="elel" use="@elelEntity" />
<xsl:template match="/">
<xsl:text disable-output-escaping="yes">
<!DOCTYPE dmodule [
</xsl:text>
<xsl:text disable-output-escaping="yes"><!NOTATION cgm PUBLIC "-//USA-DOD//NOTATION Computer Graphics Metafile//EN">
</xsl:text>
<xsl:for-each select="//elel[generate-id() = generate-id(key('elelsById', @elelEntity)[1])]">
<xsl:text disable-output-escaping="yes"><!ENTITY </xsl:text>
<xsl:value-of select="@elelEntity" />
<xsl:text> SYSTEM "</xsl:text>
<xsl:value-of select="@elelEntity" />
<xsl:text disable-output-escaping="yes">.cgm" NDATA cgm >
</xsl:text>
</xsl:for-each>
<xsl:text disable-output-escaping="yes">]>
</xsl:text>
<xsl:apply-templates/>
</xsl:template>
<xsl:template match="@*|node()">
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>
My output looks like this:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE dmodule [
<!NOTATION cgm PUBLIC "-//USA-DOD//NOTATION Computer Graphics Metafile//EN">
<!ENTITY ELEL-A-01 SYSTEM "ELEL-A-01.cgm" NDATA cgm >
<!ENTITY ELEL-A-05 SYSTEM "ELEL-A-05.cgm" NDATA cgm >
]>
<!-- xml content -->
I was expecting that the <
and >
would be replaced to <
and >
I removed disable-output-escaping="yes"
and the result is the same.
I saw that Saxon contains this extension saxon:doctype
, but it is available only for Saxon-PE or Saxon-EE.
What am I missing in my implementation?
Your code as is should work if you let Saxon serialize the result so that it can take the DOE into account; if that doesn't work it usually means you are using a transformation destination like a DOM or XDM tree instead of a file or stream.
You can see part of your code working this online fiddle with Saxon HE. Result there is e.g.
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE dmodule [
<!NOTATION cgm PUBLIC "-//USA-DOD//NOTATION Computer Graphics Metafile//EN">
]>
<dmodule>...</dmodule>