views:

130

answers:

1

We're creating a REST service where the client will send XML containing a financial portfolio. The portfolio XML will use a published standard XML DTD. We would like to add a few bits of data to the portfolio XML.

We would like to keep the ability to validate the XML against the published DTD. But if we add extra fields the DTD validation will now fail. Is there a way to create a new DTD that comprises the existing DTD plus our new fields?

+1  A: 

You can include the published standard DTD as an external DTD, then create an internal DTD together with your XML document, or create another DTD that add the new elements and add that one as well.
This is an example of an internal DTD (taken from w3schools):

<?xml version="1.0"?>
<!DOCTYPE note [
<!ELEMENT note (to,from,heading,body)>
<!ELEMENT to (#PCDATA)>
<!ELEMENT from (#PCDATA)>
<!ELEMENT heading (#PCDATA)>
<!ELEMENT body (#PCDATA)>
]>
<note>
<to>Tove</to>
<from>Jani</from>
<heading>Reminder</heading>
<body>Don't forget me this weekend</body>
</note>
phunehehe
Where is the reference to the published standard DTD?
Marcus
put it as another `<!DOCTYPE ...>` declaration, such as `<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">`<br/>`<!DOCTYPE note [ ... internal doctype ... ]>`
phunehehe