Welcome to WebmasterWorld Guest from 54.160.244.240

Forum Moderators: httpwebwitch

Message Too Old, No Replies

elements with the same name, and DTD rules?

needing tips from a DTD whiz

     
7:14 pm on Jul 27, 2007 (gmt 0)

Moderator This Forum from CA 

WebmasterWorld Administrator httpwebwitch is a WebmasterWorld Top Contributor of All Time 10+ Year Member

joined:Aug 29, 2003
posts:4059
votes: 0


I'll make up a hypothetical example to keep the code concise.

I want to create a DTD that enforces the following rules:


<!-- this is OK. -->
<o>
<pet>
<dog>
<collar/>
</dog>
</pet>
</>

<!-- this is also OK -->
<o>
<hot>
<dog>
<meat/>
</dog>
</hot>
</o>

<!-- however I want to prevent this -->
<o>
<pet>
<dog>
<meat/>
</dog>
</pet>
</o>

<!-- this is also NOT OK -->
<o>
<hot>
<dog>
<collar/>
</dog>
</hot>
</o>

the DTD definition I have of "dog" lets either happen
<!ELEMENT dog (collar,meat)>

is there a technique in DTD that will prevent a hotdog from having a collar, and a pet dog from containing meat?

7:25 pm on July 27, 2007 (gmt 0)

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:Feb 21, 2005
posts: 1526
votes: 0


I don't know DTD (but I will lay odds that it can do that. It is an enforcement mechanism).

I use XSD (schema) and schema can certainly do it.

1:05 pm on July 31, 2007 (gmt 0)

Moderator This Forum from CA 

WebmasterWorld Administrator httpwebwitch is a WebmasterWorld Top Contributor of All Time 10+ Year Member

joined:Aug 29, 2003
posts:4059
votes: 0


From my probing, seems like DTD doesn't do that kind of validation. "dog" is allowed within "hot" and "pet", but below that all "dog"s are alike, whether they're pets or food.

I'm using schema anyways now, to enforce some attribute values... one snag there but I'll post that in a different thread

 

Join The Conversation

Moderators and Top Contributors

Hot Threads This Week

Featured Threads

Free SEO Tools

Hire Expert Members