homepage Welcome to WebmasterWorld Guest from 23.22.173.58
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

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

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



 
Msg#: 3406597 posted 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

WebmasterWorld Senior Member 5+ Year Member



 
Msg#: 3406597 posted 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

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



 
Msg#: 3406597 posted 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.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved