Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


Re: Nodes with the same name in one XML doc

From: Peter Flynn <peter.nosp@-.--------.-->
To: 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/



transparent
Print
Mail
Like It
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent