• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

A Question from PerfectXML Quiz

 
Satish Avadhanam
Ranch Hand
Posts: 697
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello all, again

The following question got marked wrong in xml quiz in perfect xml Guys, please clarify. Thanks.



The choices given are:
1. SampleElement and sampleAttribute both belong to namespace
2. SampleElement and sampleAttribute both do not belong to namespace
3. SampleElement only belongs to namespace
4. sampleAttribute only belongs to namespace

I think the answer is both SampleElement and sampleAttribute do not belong to namespace as both are not qualified. But if there are any elements inside of SampleElement then they all belong to namespace as it is default namespace unless explicitly prefixed with a different namespace.

I selected 2 and it's marked wrong
The answer given is 3.

Guys, appreciate your time. Thanks.
Satish.
 
Hari Vignesh Padmanaban
Ranch Hand
Posts: 578
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


The choices given are:
1. SampleElement and sampleAttribute both belong to namespace
2. SampleElement and sampleAttribute both do not belong to namespace
3. SampleElement only belongs to namespace
4. sampleAttribute only belongs to namespace

But if there are any elements inside of SampleElement then they all belong to namespace as it is default namespace unless explicitly prefixed with a different namespace.

I selected 2 and it's marked wrong
The answer given is 3.

Guys, appreciate your time. Thanks.
Satish.[/qb]<hr></blockquote>

Hey satishh, seems like u are preparing for teh XML exam in full flow

Anyway , here is what I think ( I have to refer some notes ..but thought I coudl say what I could recollect from my memory )

1. Default Namespaces do not Apply to attributes !!!. They DO apply to elemnts. Attributes HAVE TO BE Qualified with a namespace prefix !!! I think i read this from either w3schools,org or from Professional XML second edition. I can check it today and confirm it tommorow

COmming to your thoughts !!!


I think the answer is both SampleElement and sampleAttribute do not belong to namespace as both are not qualified.


Elements dont necessarily have to be prefixed with a namesapce prefix. They take the namespace of the scope in which they are . So in this case it would take the namespace given in the elemnt definition itself !!!

But as I mentioned, thats not the case with attributes. They have to be prefixed with a namespace prefix to belong to a particular namespace !!!

And I guess, that rules out answers 1,2 and 4.

And leaves us with 3

hope this helps . good luck for the exam
[ August 04, 2004: Message edited by: Hari Vignesh Padmanaban ]
 
Satish Avadhanam
Ranch Hand
Posts: 697
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey Hari
Thanks for explaining. I know that elements are not required to explicitly prefixed to belong to a namespace. But for a element where a namespace is declared as above, for this element to belong to declared namespace, I think it should be explicitly prefixed or else it belongs to default namespace of its parent element. I read it somewhere and I don't remember where

Ah! Now I remember. I think if this element is explicitly not prefixed, then it belongs to namespace declared in this element.

Little bit confused

Thanks Hari, once again.
 
Hari Vignesh Padmanaban
Ranch Hand
Posts: 578
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Satish Avadhanam:
But for a element where a namespace is declared as above, for this element to belong to declared namespace, I think it should be explicitly prefixed or else it belongs to default namespace of its parent element. I read it somewhere and I don't remember where

Ah! Now I remember. I think if this element is explicitly not prefixed, then it belongs to namespace declared in this element.

Little bit confused

Thanks Hari, once again.


I think that the element belongs to the namespace delared in the element.

Just to confirm what I had said in my previous post , I read about it from XML profesional, Second edition

If u have a copy, do read through abt namespaces in the book. Its really good

hope this helps
 
Andy Smith
Ranch Hand
Posts: 239
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Very Correct Hari.

From W3C Specs:

A default namespace is considered to apply to the element where it is declared (if that element has no namespace prefix), and to all elements with no prefix within the content of that element. If the URI reference in a default namespace declaration is empty, then unprefixed elements in the scope of the declaration are not considered to be in any namespace. Note that default namespaces do not apply directly to attributes.
[ August 24, 2004: Message edited by: Andy Smith ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic