homepage Welcome to WebmasterWorld Guest from 54.198.139.141
register, free tools, login, search, subscribe, help, library, announcements, recent posts, open posts,
Pubcon Website
Home / Forums Index / Code, Content, and Presentation / XML Development
Forum Library, Charter, Moderators: httpwebwitch

XML Development Forum

    
elements with the same name, and DTD rules?
needing tips from a DTD whiz
httpwebwitch




msg:3406599
 7:14 pm on Jul 27, 2007 (gmt 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?

 

cmarshall




msg:3406609
 7:25 pm on Jul 27, 2007 (gmt 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.

httpwebwitch




msg:3409469
 1:05 pm on Jul 31, 2007 (gmt 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

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / XML Development
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About
© Webmaster World 1996-2014 all rights reserved