• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to Declare Namespace in DTD

 
Lakshmi Kishore
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi anybody know how to declare the namespaces in a DTD? I am not able to decide whenther actually cna we define Namespaces??? i am really confused, can anybody help me......
 
Dan Drillich
Ranch Hand
Posts: 1183
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Even though DTDs are not namespace aware, you can define namespaces in the DTD as regular attributes.
For example (XML in a Nutshell #66), this ATTLIST declaration fixes the default namespace of all svg elements as http://www.w3.org/2000:
<!ATTLIST svg xmlns CDATA #FIXED "http://www.w3.org/2000">
This allows you to omit xmlns attributes from all your svg elements.
A document does not need to be valid to take advantage of this omission. All that's required is that the parser read the DTD. All parsers read the internal DTD subset and process any ATTLIST declarations they find there.
Cheers,
Dan
 
Lakshmi Kishore
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
if i declare this, how to use the namespace prefix? if that book contains, i will go through it soon as i don't have the book right now.
if not please some one could tell me how to refer prefix.
Thanks in Advance
 
Dan Drillich
Ranch Hand
Posts: 1183
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The book explains the issue in pages 66-68.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic