XML : XML DTD Validating elements that can be non-existent

I'm trying to create a DTD for a index where one element could simply not exist ie:

  <movies>    <movie>       <name>Django<name>       <oscars>5444</oscars>    </movie>    <movie>       <name>Star Wars<name>       <oscars>5444</oscars>    </movie>    <movie>       <name>Pixels<name>     <!-- NOTICE THE LACK OF "OSCARS" HERE -->    </movie>    </movies>    

Normally Id write the DTD for this like that:

  <!ELEMENT movies (movie+)>  <!ELEMENT movie (name, oscars*)>  <!ELEMENT name (#PCDATA)>  <!ELEMENT oscars (#PCDATA)>    

But when trying to validate it, I'd get " Element type "oscars" must be declared. "

Is there any right way to get over it?

Any help would be gladly appreciated.

No comments:

Post a Comment