开发者

How to create XML file that uses two DTDs?

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 th开发者_JS百科e 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?


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>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜