[xsl] Modifying a DTD with XSLT

Subject: [xsl] Modifying a DTD with XSLT
From: Michael Müller-Hillebrand <mmh@xxxxxxxxxxxxx>
Date: Mon, 4 Oct 2010 12:08:36 +0200
Hello,

My original task is to split a source XML file into certain chunks to make
handling with translation systems easier (if you want to have several
translators work in parallel some systems apparently cannot split received
data into chunks on their own). Since the source document contains
cross-references with idref/id attributes throughout the content I cannot use
the original DTD which specifies attributes like

<!ATTLIST crossref   idref     IDREF     #IMPLIED>
<!ATTLIST section    id        ID        #IMPLIED>

because @idref and @id might end up in different chunks. The XML parser would
then complain.

I could create XML chunks without any DTD reference, but this would not allow
validation of the structure after translation. So I  thought of creating a
slightly modified version of the DTD with

<!ATTLIST crossref   idref     CDATA     #IMPLIED>

Since the original DTD is likely to change at other places, I plan to make
that change on-the-fly with the splitting of the source XML.

Long story short: Can you think of another way to make such a change than with
a combination of
<xsl:result-document method="text">,
unparsed-text($dtdpath), and
replace($dtdstring, 'idref\s+IDREF', 'idref CDATA')

Thanks a lot for your comments,

- Michael M|ller-Hillebrand

PS: I can see that XSL could be used more elegantly with an XML Schema, but
this is no option currently.

Current Thread