Win a copy of Transfer Learning for Natural Language Processing (MEAP) this week in the Artificial Intelligence and Machine Learning forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Paul Clapham
  • Devaka Cooray
  • Bear Bibeault
Sheriffs:
  • Junilu Lacar
  • Knute Snortum
  • Liutauras Vilda
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Piet Souris
Bartenders:
  • salvin francis
  • Carey Brown
  • Frits Walraven

XML namespace doubt

 
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
From Skonnard's book
1) "A namespace declaration is in scope for the element on which it is declared and all of that elements descendent"
<pre:person xmlns:pre='uri:example-org:people'>
<name>Martin</name>
<age>33</age>
</pre:person>
2) "The element Person has children with local names of name and age. Both of these child elements are unqualified; that is , they are not in any namespace."
WHY ? Isn't point 2 contradicting point 1 above ? OR is it that child elements are not considered as descendents of the parent element ?
Can someone throw some light on this.
Thanks,
Prasen
[ May 12, 2003: Message edited by: Prasen K ]
[ May 12, 2003: Message edited by: Prasen K ]
[ May 12, 2003: Message edited by: Prasen K ]
[ May 12, 2003: Message edited by: Prasen K ]
 
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The namespace "declaration" is for all the elements below it. That means you can use pre as a qualifier for all the elements below name element. The same cannot be done for parent of name (if it is not declared in any ancestor of it)
The scope of the declared namespace and its "use" is limited to the element(where the namespace is defined.) and all descendant's of it.
 
Karthik Jayaraman
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
<ano:ancestor xmlns:ano="....">
<pre:child> <!--This is invalid-->
<pre:name xmlns: pre="....">
<pre:child1/>
<ano:child2/> <!-- This is valid-->
</pre:name>
</ano:ancestor>
In the above eg. the second line is an error as pre is only defined for "name" element and its descendant and cannot be used in a sibling element "child".
[ May 13, 2003: Message edited by: karthik jayaraman ]
[ May 13, 2003: Message edited by: karthik jayaraman ]
 
Parth K
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Karthik. Your explanation as well as example cleared my doubt.
 
This. Exactly this. This is what my therapist has been talking about. And now with a tiny ad:
Two software engineers solve most of the world's problems in one K&R sized book
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
    Bookmark Topic Watch Topic
  • New Topic