user2650277
user2650277

Reputation: 6739

XML - Elements having multiple values

I have an element that must contain only specific values in xml but there may be more that one of that element.However the dtd seems to be wrong(skipping irrelevant parts)

dtd

<!ELEMENT Country ( US | UK | France | Italy ) >

xml

<table>
    <details>
        <Country>US</CINEMA>
        <Country>Italy</CINEMA>
        <Country>UK</CINEMA>
    </details>

Here is the error that i get when using xmlvalidator

The content of element type "Country" must match "( US | UK | France | Italy )"

Upvotes: 0

Views: 626

Answers (1)

har07
har07

Reputation: 89295

Your DTD restricts content of <Country> elements to 4 possible child elements. So example of valid <Country> elements according to the DTD would be :

<Country>
    <US></US>
</Country>
<Country>
    <Italy></Italy>
</Country>

Unfortunately, there is no way to restrict text node content inside an element using DTD. Related question : Element that can only have one of two text values?

Upvotes: 1

Related Questions