Altober
Altober

Reputation: 966

Dtd XML Elements in any order and any number

I need to write a dtd for the first time. I have being reading for a while and the only solution I could come up to have any number of elements of any type is the following.

 <!ELEMENT sentence ((word?,punc?)*)>

It looks very fishy to me. Does anyone know a better way? Does this really does what I want?

Thanks in advance

Altober

Upvotes: 0

Views: 165

Answers (1)

Daniel Haley
Daniel Haley

Reputation: 52888

You could use ANY...

<!ELEMENT sentence ANY>

This will allow any element any number of times in any order. This will also allow #PCDATA though. In addition, you will still need to have a declaration for any element that appears in sentence.

If you know which elements will appear in sentence, you could write the declaration like this instead:

<!ELEMENT sentence (word|punc)*>

Upvotes: 2

Related Questions