0

I am having some trouble understanding the constraints in XML as I am still a beginner in XML.

I am not exactly sure what would happen if not enough constraint descriptions are given to the XML Document Type Definition.

Please give me a few examples of the XML Document Type Definition with lacking constraint descriptions, and why the DTD cannot be used. Also, would this be the same case for the XML Schema (Or can the XML Schema overcome the lack of constraint descriptions)?

Edit1: I heard that trying to model a database and requiring a specific element to be numeric while all others are text is not possible in a XML DTD, thus not possible to constrain data within a text-only element to a specific type.

Is this true and why? And how might this actually look in a XML code? Would this be possible in the XML Schema?

If possible, please also give me an example similar to this where something cannot be expressed in a DTD due to constraint descriptions.

Edit2: Does the XML schema provides more concrete constraints than the XML DTD? For example, if there wasn't any constraints about data type when doing addition, and you try to add a string to an integer, would that cause problems? I would like to know the consequence of not putting appropriate constraints.

LilyPod
  • 1
  • 1
  • 1
    You might want to look at https://stackoverflow.com/questions/1544200/what-is-difference-between-xml-schema-and-dtd – Progman Jul 22 '21 at 22:14
  • Thanks for the reply, I have looked through that but I am still not exactly sure how a XML DTD would look if there wasn't enough constraints. Any example of the XML DTD that lacks constraints would be appreciated. – LilyPod Jul 22 '21 at 22:33
  • Please take the [tour] to learn how Stack Overflow works and read [ask] on how to improve the quality of your question. Then check the [help/on-topic] to see what questions you can ask. It is unclear what you are asking or what the problem is. Your post is somehow too broad. Please [edit] your question to include a more detailed description of the problem you have or what you want to know. It is unclear what you mean by "what would happen". When describing your problem provide example data to support your question you are trying to ask. – Progman Jul 22 '21 at 22:42
  • Thank you for the suggestion. I have updated the question to be more specific. – LilyPod Jul 22 '21 at 22:55
  • I don't know what you mean by "not enough constraint descriptions". Declarations in a DTD generally say what's allowed, they don't say what isn't allowed, whereas a "constraint" generally defines something that isn't allowed. – Michael Kay Jul 23 '21 at 07:06
  • Thanks for the reply. From my understanding, the XML schema provides more concrete constraints than the XML DTD? Like if there weren't any constraints in place to limit text size, wouldn't the product be really hard to read when ported to other platforms? If there wasn't any constraints about data type when doing addition, and you try to add a string to an integer, wouldn't that also cause problems? I would like to know the consequence of not putting appropriate constraints. – LilyPod Jul 23 '21 at 17:13

0 Answers0