Question

For my assignment I have been assigned the task of creating a DTD for representing a virtual-geocaching game.

I am having a problem representing the location which can be either gps or wifi or both but not more then one of each. How would i represent this? The closest I could think of is listed below.

<!ELEMENT location ((gps|wifi)+)> 

The full DTD is here.

<!ELEMENT game (information, caches)>
    <!ELEMENT information (gameID, gameName, gameDescription, date, author)>
        <!ELEMENT gameID (#PCDATA)>
        <!ELEMENT gameName (#PCDATA)>
        <!ELEMENT gameDescription (#PCDATA)>
        <!ELEMENT date (#PCDATA)>
        <!ELEMENT author (#PCDATA)>
    <!ELEMENT caches (cache+)>
        <!ELEMENT cache (cacheID, cacheName, location, value)>
            <!ELEMENT cacheID (#PCDATA)>
            <!ELEMENT cacheName (#PCDATA)>
            <!ELEMENT location ((gps|wifi)+)>
                <!ELEMENT gps (longitude, latitude)>
                    <!ELEMENT latitude (#PCDATA)>
                    <!ELEMENT longitude (#PCDATA)>
                <!ELEMENT wifi (#PCDATA)>
            <!ELEMENT value (#PCDATA)>

Where each game contains some information about it and a number of caches.

Cheers in advance.

Was it helpful?

Solution

Try this:

<!ELEMENT location ((gps|wifi|(gps,wifi)|(wifi,gps)))>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top