Altova Mailing List Archives>Archive Index >comp.text.xml Archive Home >Recent entries >Thread Prev - Nodes with the same name in one XML doc [Thread Next] Re: Nodes with the same name in one XML docTo: NULL Date: 11/5/2007 9:49:00 PM On Mon, 05 Nov 2007 21:25:57 +0000, engwar wrote: > How do you created a DTD that will allow for node with the same name at > different places in the XML document? > > Here's my XML > > <parentNode> > <someNode> > <myNode/> > </someNode> > </parentNode> > <parentNode> > <someOtherNode> > <myNode/> > </someNode> > </parentNode> > > Here's my dtd > > <!ELEMENT parentNode (someNode|someOtherNode) > <!ELEMENT someNode (myNode)> > <!ELEMENT myNode (#PCDATA)> > <!ELEMENT someOtherNode (myNode)> > <!ELEMENT myNode (#PCDATA)> > > The problem is that if both of these nodes can have a myNode child node > then the application I'm using to validate my XML (Oxygen XML editor) > says that my Element type "myNode" must not be declared more than once. You don't declare element types more than once. Once is enough. Just remove the second declaration. And remove the TABs: as Joe pointed out, DTDs are not hierarchical (in fact the element type declarations can occur in any order so long as they satisfy all the necessary constraints by the end of the DTD :-) You'll also need a root element type to enclose the whole thing, if you want your parentNode to occur more than once. ///Peter -- XML FAQ: http://xml.silmaril.ie/ | ||||||
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | Mobile | Full Site | |||
|
