Feature request for XProc: please add <p:validate-with-dtd>

XProc 3.0 offers a whole range of possibilities for validating documents using:

However, there is no equivalent for validating XML documents with DTD.

Even though XML Schema became a W3C recommendation already in 2001, and RELAX NG was also defined then, there are still legacy systems that only support DTD. In rare cases, it is possible to enhance these systems by switching to XML Schema, but this is generally not an option and these systems have to be supported nevertheless.

The lack of DTD validation in XProc 3.0 means that the pipelines have to use a workaround. The XML result must first be stored to the file system and then loaded immediately from there again using <p:load>. This is because, surprisingly, DTD validation is possible with XProc 3.0 but only while loading a document. Finally, the previously stored and validated XML result has to be deleted, because its no longer needed. While this workaround does its job, the ability to do this in memory using something like <p:validate-with-dtd> would be much more effective.

There is perhaps an argument for adding DTD validation to the pipeline using <p:declare-step>. However, this requires the XProc processor to realise that only a memory stream is needed, causing it to perform an optimisation and avoid storing the result to the file system and reloading it. Even if this would work, anybody who wants to support DTD has to add the following step to their pipelines instead of just using <p:validate-with-dtd>.

<p:declare-step type="tcg:validate-with-dtd">
    <p:input port="source" sequence="false" content-types="xml" />
    <p:output port="result" sequence="true" content-types="xml" />

    <p:pipe step="load" />

    <p:store href="foo.xml" name="store" />

    <p:load href="foo.xml" name="load" parameters="map{'dtd-validate' : true()}" depends-on="store" />

    <p:file-delete href="foo.xml" depends-on="load" /> 
</p:declare-step>

So please, XProc working group, support DTD validation natively and add <p:validate-with-dtd> and Bob's your uncle.