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

Question on Namespace

 
Ricky Gohil
Ranch Hand
Posts: 87
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Could some one help me with this...

<?xml version="1.0" encoding="UTF-8"?>
<po xmlns="http://www.abhijeet.com/PO" >
<addr:address xmlns:addr="http://www.abhijeet.com/addr">
<name>AMAZON</name>
<city>Lexington</city>
</addr:address>
<book xmlns="">
<title>J2EE Web Services</title>
</book>
</po>


Question 1> Choose the namespace to which name element belongs

a. http://www.abhijeet.com/PO
b. None

I think option a is the correct answer

Question 2> Choose the namespace to which book element belongs

a. http://www.abhijeet.com/PO
b. None

I think option b is the correct answer

Question 3> Choose the namespace to which title element belongs

a. http://www.abhijeet.com/PO
b. None

I think option b is the correct answer
 
Niranjan Deshpande
Ranch Hand
Posts: 1277
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Could some one help me with this...

<?xml version="1.0" encoding="UTF-8"?>
<po xmlns="http://www.abhijeet.com/PO" >
<addr:address xmlns:addr="http://www.abhijeet.com/addr">
<name>AMAZON</name>
<city>Lexington</city>
</addr:address>
<book xmlns="">
<title>J2EE Web Services</title>
</book>
</po>


Question 1> Choose the namespace to which name element belongs

a. http://www.abhijeet.com/PO
b. None

I think option a is the correct answer

Question 2> Choose the namespace to which book element belongs

a. http://www.abhijeet.com/PO
b. None

I think option b is the correct answer

Question 3> Choose the namespace to which title element belongs

a. http://www.abhijeet.com/PO
b. None

I think option b is the correct answer


I am fine with your response 1.
But about 2: will the xmlns="" work in first place? Is it valid to write it that way.
And about 3: <title> belongs to http://www.abhijeet.com/PO, as per my understanding, if no namespace is mentioned, it defaults to the default.

People, please correct us if we are wrong.
 
Ricky Gohil
Ranch Hand
Posts: 87
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
http://www.w3.org/TR/REC-xml-names/#defaulting

The attribute value in a default namespace declaration may be empty...

Look at the last example in section "6.2 Namespace Defaulting" in the above link
[ July 20, 2008: Message edited by: Ricky Gohil ]
 
Vignesh Murali Natarajan
Ranch Hand
Posts: 65
Firefox Browser Hibernate Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Ricky,
This is what I feel are the correct options.

As explained in RMH, Section 3.1.6, last 2 paragraphs, any element that is prefixed will be assigned the default namespace

Question 1 > Option a. The local elements assume the default namespace "http://www.abhijeet.com/PO" declared by PO element.

Question 2 > Option a. For the same reason as above

Question 3 > Option a. For the same reason as above


Please let me know if I am wrong.
[ July 21, 2008: Message edited by: Vignesh Murali Natarajan ]
 
Ricky Gohil
Ranch Hand
Posts: 87
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Finally i have got my answer in this website http://www.jclark.com/xml/xmlns.htm



Hi Vignesh,

I guess the below explanation picked from the above site will clear the picture.

An empty value for xmlns makes the mapping treat unprefixed element type names as local names (which is the default behaviour in the absence of xmlns attributes). Thus

<section xmlns='urn:com:books-r-us'>
<title>Book-Signing Event</title>
<signing xmlns=''>
<author title="Mr" name="Vikram Seth" />
<book title="A Suitable Boy" price="$22.95" />
</signing>
</section>
maps to

<{urn:com:books-r-us}section>
<{urn:com:books-r-us}title
>Book-Signing Event</{urn:com:books-r-us}title>
<signing>
<author title="Mr" name="Vikram Seth" />
<book title="A Suitable Boy" price="$22.95" />
</signing>
</{urn:com:books-r-us}section>
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic