Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Wrong answer?

 
Dhananjay Goswami
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I took a sample XML test in a reputed site, witscale.com. I was doubtful about one of the answers that the site gave me. Here is the question and the answer:
----------------------------------------------
Q 8. Select all statements which are true about XML Schema but which are not so true about
DTD.

1. You can create your own data types.

2. You can define multiple elements with the same name but different content.
3. You can define the child elements to occur in any order.

4. You can define the child elements to occur in particular order.

5. You can define elements with no content.

6. You can define substitutable elements.
(For example one element (say <CAB> ) is substitutable by another element (say
<TAXI> and the document is still valid after substitution.)


--------------------------------------------------------------------------------
The correct answers (according to witscale) are options 1, 2, 3 and 6.
Option 4 and 5 are incorrect because they are also true about DTDs.
You can empty tags in DTDs also. For ex. <!ELEMENT color EMPTY> will define
tag <color> which does not contain anything.
You can also define the order of child elements in DTD.
-----------------------------------------------
But I feel that 3 should not be considered as a correct answer since you can define the elements to appear in any order in DTD too.
<!ELEMENT someElem (child1 | child2)* >
With such a declaration for an element someElem, we can allow its children child1 and child2 to appear in any order.
<someElem>
<child1/>
<child2/>
</someElem>
as well as
<someElem>
<child2/>
<child1/>
</someElem>
are both correct.
Please help me clarify my doubt.
Appreciating all help.
Thanks,
Dhananjay.
 
Anonymous
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Option 2 is talking about <all> element of schemas which is not available in DTDs.
 
Anonymous
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I did not understand Option 2.
2. You can define multiple elements with the same name but different content.
Can someone explain with an example.
 
anandkrisnan variar
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi dhananjay
i tried to access the same site u mentioned:
witscale.com.
but as i am not a registered member i cannot login.
but the problem is the link for new registration is also not enabled.
can u please help for the same.
 
Anonymous
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There is a Signup link just below that which will take u to the registration page
 
Karthik Jayaraman
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
2. You can define multiple elements with the same name but different content
I think this means to say in schemas you can have two elements with the same name( different namespaces.) which is not so in DTDs. Hope its related to namespace support in schemas.

Any comments?
 
calvin zhu
Ranch Hand
Posts: 54
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, Dhananjay.
I think the option 3 is wrong.
And though the situation u give seems reasonable, but it's not quite the right example for option 3. <child1> and <child2> are actually the same child-element to <someElem>. They are not 2 differen child elements.
let's see this http://www.w3schools.com/dtd/dtd_elements.asp)
<!ELEMENT element-name
(child-element-name)>
or
<!ELEMENT element-name
(child-element-name,child-element-name,.....)>
When children are declared in a sequence separated by commas, the children must appear in the same sequence in the document.
and the example u give is like:
<!ELEMENT element-name (child-name*)>
it's the zero or more occurrences of the same element.
So still in order to define sequence for child elements in DTD(of course for different child elements), they must be separated by commas and appear in the same sequence.
[ May 07, 2003: Message edited by: calvin zhu ]
 
Roseanne Zhang
Ranch Hand
Posts: 1953
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by karthik jayaraman:
2. You can define multiple elements with the same name but different content
I think this means to say in schemas you can have two elements with the same name( different namespaces.) which is not so in DTDs. Hope its related to namespace support in schemas.

Any comments?

No, different namespaces are actually different names.
In xml schema, same name but different contents elements can appear in different scopes, in other words, under different parents, which is not allowed in DTDs.
See your detailed answer with an interesting XML example and its xschema and DTD.
Q. Xschema allows same name element with different contents and DTD does not. Can you give an example?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic