-2

Assume that my DTD code have this following listing:

<!ELEMENT body
  ((verse, bridge?, chorus)+) , coda)>

Can I write XSD code, which defines that a sequence of three element (one optional) can be repeated one or more? If it can, what's the listing for that XSD?

  • 1
    DTD and XSD are not 1-to-1 equivalent. _"If it can, what's the listing for that XSD?"_ - StackOverflow is not a code translation service. We are not going to do your work for you. Please visit the [help] and read [ask] to learn how to use this site. You are expected to attempt the work and post a specific question when you encounter a problem. – Jim Garrison Dec 04 '17 at 07:08
  • Sorry, I know. I don't think so – Bagas Sanjaya Dec 04 '17 at 09:09

1 Answers1

0

It's true, as Jim Garrison has pointed out in a comment, that the DTD and XSD schema languages are not 1:1 equivalent. But XSD was designed to be able to define any language that can be defined by a DTD (modulo some things like hard-coding namespace prefixes, which were regarded as flaws rather than capabilities of DTDs).

So the short answer to your question is yes, you can write equivalent XSD declarations.

For the long answer, you will want to consult a tutorial on XSD (most question answerers on Stack Overflow will be happy to help you correct errors in your attempts to solve the problem, but not to solve it for you -- there are of course exceptions); the tutorial in Part 0 of XSD 1.0 is accurate and accessible. You will want to pay particular attention to the xsd:sequence and xsd:element elements, and to the minOccurs and maxOccurs attributes on those elements.

C. M. Sperberg-McQueen
  • 24,596
  • 5
  • 38
  • 65