Altova Mailing List Archives>Archive Index >comp.text.xml Archive Home >Recent entries >Thread Prev - particular costraints in mixed contents [Thread Next] Re: particular costraints in mixed contentsTo: NULL Date: 7/3/2006 2:25:00 AM JU wrote: > Hello, > I am pretty new in XML and I'm studying the DTD definition. I cannot > solve a problem, or better, I cannot define what I want in my DTD file. > What I would like to do is that something like > <el>text <child/> text</el> > is accepted but not > <el>text <child/> text<child/></el> > > I know that <!ELEMENT el (#PCDATA|child)*> declares the element el as a > mixed content of PCDATA and child but what I want to define is that the > element child occurs exactly once and not more. Instead of PCDATA can > occur either before, after or never. I tried with > (#PCDATA,child+,#PCDATA) but it's not working. Do you know if what I > want is possible? You can't declare that in XML using a DTD (it would be possible in SGML, though, but you don't want to go there). If it's essential to use a DTD, you could use subelements of el, for example <!ELEMENT el (text,child,text)> ... <el><text>stuff</text><child/><text>more stuff</text></el> or use a W3C Schema instead as Martin suggests. ///Peter | ||||||
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | Mobile | Full Site | |||
|
