1

I have the following document specific DTD at the top of an XML file created by our editing software:

<!DOCTYPE front SYSTEM "file:///M:/Library/AMH-Paed.dtd" [
<!NOTATION cgm PUBLIC "" >
<!-- Begin Document Specific Declarations --><!ENTITY fm.tcont " (Continued)">
<!ENTITY equation1 SYSTEM "equation11.cgm" NDATA cgm>
<!ENTITY equation2 SYSTEM "equation26.cgm" NDATA cgm>
<!ENTITY equation3 SYSTEM "equation32.cgm" NDATA cgm>
<!ENTITY equation4 SYSTEM "equation41.cgm" NDATA cgm>
<!ENTITY equation5 SYSTEM "equation51.cgm" NDATA cgm>
<!ENTITY equation6 SYSTEM "equation62.cgm" NDATA cgm>
<!-- End Document Specific Declarations -->]>

We're updating the general doctype for our content, and so transforming the current XML files through XSLT.

We have a couple of hundred documents, but only a handful of them have any specific declarations (which vary in number, name, and value) which we have to maintain through the transformation.

However, I can't find a way to maintain the above entity declarations through the transformation.

Is it possible, and how would you do it?

HorusKol
  • 8,375
  • 10
  • 51
  • 92
  • you mean by document specific it will change from document to document and there are multiple documents? – Tony Shih Mar 21 '13 at 06:42
  • yes, that is exactly what I mean - in reality, the number of documents with specific entities won't be that great compared with the total number of documents. I'd prefer not to have to use them, but this is how the third party editing software works and I need to maintain them through the transformation where they occur. – HorusKol Mar 21 '13 at 06:45
  • Here's a similar question that I asked a while back: http://stackoverflow.com/questions/5985615/preserving-entity-references-when-transforming-xml-with-xslt lexev was also suggested to me, but I never did try it. If you try it, please post an update on your question. – Daniel Haley Mar 21 '13 at 21:26

1 Answers1

1

DTD declarations aren't part of the data model presented to the XSLT processor so this can't be done directly.

A workaround is to use the Lexev tool from Andrew Welch. This converts the DTD into an XML representation as a pre-processing step, and then does the reverse as a post-processing step.

Michael Kay
  • 156,231
  • 11
  • 92
  • 164