473,231 Members | 1,592 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,231 software developers and data experts.

DTD Question surrounding duplicate child elements

Below is a sample of my XML…

<MetaData>
<Table name="mytable">
<PrimaryKey name="pk"><Column name="mycolumn"/></PrimaryKey>
</Table>
</MetaData>

<Sequencer>
<Table name="mytable">
<Column name="mycolumn">
<Type>Object</Type>
</Column>
</Table>
</Sequencer>

Notice that I have two elements called, MetaData and Sequencer that
both have child elements called Table. How do I define the Table
child element in a DTD? Let me continue to explain what I mean. To
define the DTD for the two parent elements, I would do the following…

<!ELEMENT MetaData (Table+)>
<!ELEMENT Sequencer(Table+)>

Now I want to define the Table elements for both the MetaData and the
Sequencer elements. How do I do that when both child elements are
named Table. This is valid XML. But I can't see how I can create a
DTD for this XML when I can't define duplicate element names in a DTD.

I'm new to XML, so this may be a dumb question. I hope that it is,
because if this cannot be done, then defining a DTD is a worthless
exercise in any serious business application, in my opinion.

Your help is greatly appreciated. Please refrain from telling me how
I can work around this by structuring my XML in another way. I know
that I can do that. I am more interested in if it is possible to have
two parent elements with child elements that have the same name and be
able to define that in a DTD.

Thanks,
Doug
Jul 20 '05 #1
4 6707
In article <dc**************************@posting.google.com >,
Doug Estep <do***********@webtechinfo.com> wrote:
Notice that I have two elements called, MetaData and Sequencer that
both have child elements called Table. How do I define the Table
child element in a DTD?
You can't have two elements with the same name and different content
models in the same DTD. In DTDs, an element type is determined by its
name.

XML Schemas allow elements with the same name to have different types
in different context, but DTDs don't.
I'm new to XML, so this may be a dumb question. I hope that it is,
because if this cannot be done, then defining a DTD is a worthless
exercise in any serious business application, in my opinion.


I hear that DTDs have been used in thousands of serious business
applications, but I suppose it's possible that you're right and
they're all wrong.

-- Richard
--
Spam filter: to mail me from a .com/.net site, put my surname in the headers.

FreeBSD rules!
Jul 20 '05 #2
Thanks for your help Richard. If the purpose of a DTD is to define
the rules for an XML file and the XML file can define child elements
for a parent which may have the same name as another parents child
elements.... and the DTD cannot handle that situation.... then I do
think there is a flaw in the DTD design.

My solution is to name my child nodes uniquely with regards to the
entire XML file. Certainly that can be done.

My comment about "Serious" business applications was directed at
situations where you have very large XML files -- which "serious"
business applications are sure to have. With a very large XML file, I
think it would be challenging to put together a DTD if the XML file
can never have a child element with the same name as another child
element within another parent.

But hey...nothing personal man!
ri*****@cogsci.ed.ac.uk (Richard Tobin) wrote in message news:<bv**********@pc-news.cogsci.ed.ac.uk>...
In article <dc**************************@posting.google.com >,
Doug Estep <do***********@webtechinfo.com> wrote:
Notice that I have two elements called, MetaData and Sequencer that
both have child elements called Table. How do I define the Table
child element in a DTD?


You can't have two elements with the same name and different content
models in the same DTD. In DTDs, an element type is determined by its
name.

XML Schemas allow elements with the same name to have different types
in different context, but DTDs don't.
I'm new to XML, so this may be a dumb question. I hope that it is,
because if this cannot be done, then defining a DTD is a worthless
exercise in any serious business application, in my opinion.


I hear that DTDs have been used in thousands of serious business
applications, but I suppose it's possible that you're right and
they're all wrong.

-- Richard

Jul 20 '05 #3
In article <dc**************************@posting.google.com >,
Doug Estep <do***********@webtechinfo.com> wrote:
% Thanks for your help Richard. If the purpose of a DTD is to define
% the rules for an XML file and the XML file can define child elements
% for a parent which may have the same name as another parents child
% elements.... and the DTD cannot handle that situation.... then I do
% think there is a flaw in the DTD design.

You keep leaving out `but different content models' when you say `have
the same name'. If you want to go around slagging DTDs, at least make
your description of the problem complete. DTDs were not designed to
accomodate this sort of document, but that doesn't make them worthless for
any serious application. Anyway, you can write a DTD which will validate
your document, but it will also validate documents which don't conform
to your design. I don't think it's possible to create a well-formed XML
document for which you can't create a matching DTD.

You should probably look at RELAX NG or W3C Schemas and see if they are
better for your purposes.

--

Patrick TJ McPhee
East York Canada
pt**@interlog.com
Jul 20 '05 #4
On Mon, 02 Feb 2004 08:11:36 +0000, Doug Estep wrote:
Thanks for your help Richard. If the purpose of a DTD is to define
the rules for an XML file and the XML file can define child elements
for a parent which may have the same name as another parents child
elements.... and the DTD cannot handle that situation.... then I do
think there is a flaw in the DTD design.


My opinion is that it is a flaw in the XML Schema Design that it *does*
allow you to use context-dependent content models. (Or, in other words,
have two different elements with the same name.) This creates a lot of
headache and has no productive use, except to underline programmer's
preference for elegant solutions over comprehensible ones.

In DTDs, things are called by their names, and if two elements have the
same name, they are the same. You can have a TABLE in MetaData and a TABLE
in Sequencer, but they have to be interchangeable. You cannot define
different rules for TABLE in MetaData and for TABLE in Sequencer. If you
want to define different rules for TABLE in MetaData and for TABLE in
Sequencer, they are actually semantically different objects and should get
different names, such as MetaDataTable and SequencerTable.

Oliver
Jul 20 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Robert | last post by:
Im a beginner in PHP and Im having a problem with this code. Im trying to remove duplicate elements from an array created via $_GET. I want users to be able to click on a link which sends an email...
1
by: marx | last post by:
I have a bit of a problem and any help would be much appreciated. Problem: I have two dropdown list boxes with same data(all data driven). These are used for two separate entries. For every...
1
by: adamredwards | last post by:
I have a page with some form elements that are dynamically generated. They are inserted into the dom by first cloning a node, changing the values like name, and then inserted with insertBefore(). ...
1
by: Miguel Isidoro | last post by:
I generated a .cs class from a .xsd schema using the xsd.exe tool from Visual Studio 2005 and noticed that is generating duplicate class declarations. This happens because of my schema structure. I...
4
by: patrizio.trinchini | last post by:
Hi all, I'm new to XSLT and maybe my problem have a very trivial answer, but I need an expert that point me in the right direction. What I would obtain is to remove all the elements that have a...
4
by: Keith Patrick | last post by:
I'm trying to parse some XML via IXPathNavigable, handling elements, text, and attributes with the same code but without having a switch (node.NodeType). However, if I look at a parent element in...
14
by: marfi95 | last post by:
I'm trying to iterate through a list of child nodes. It seems like to get the text value of the node, you have to do a node->getFirstChild()->getNodeValue. This being said, there is a...
3
by: spl | last post by:
What is the fastest way to find a duplicate value in an array of 10 elements. I have to find just any one first occurrence of the duplication. Lets say I have ary={10, 20, 40, 90, 30, 60, 35, 40,...
7
by: swami | last post by:
What is the query for selecting non duplicate elements for eg: no name age 1 siva 28 2 blair 32 3 mano 28 i want to select blair which hasn't got any duplicate...
0
by: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
0
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
0
Git
by: egorbl4 | last post by:
Скачал я git, хотел начать настройку, а там вылезло вот это Что это? Что мне с этим делать? ...
1
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
0
by: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.