• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Liutauras Vilda
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Saloon Keepers:
  • Scott Selikoff
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
  • Frits Walraven
Bartenders:
  • Stephan van Hulst
  • Carey Brown

Can I use an attribute default in a DTD to declare an XML namespace?

 
Ranch Hand
Posts: 1011
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In the XML Namespace FAQ, the answer is YES.
An example is given:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE foo:A [
<!ELEMENT foo:A (foo:B)>
<!ATTLIST foo:A xmlns:foo CDATA #FIXED "http://www.foo.org/">
<!ELEMENT foo:B (#PCDATA)>
]>
<!-- foo prefix declared through default attribute. -->
<foo:A>
<foo:B>abc</foo:B>
</foo:A>
However, the validator says: the namespace prefix "foo" was not declared.
Anyone can help clarify this? Thanks!!
 
Ranch Hand
Posts: 1183
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
foo is declared as a fixed namespace for A elements. It is not declared for B elements. So, I agree with the validator. However, XML Spy disagrees with the validator and me. It concludes that the document is valid.
Beats me!
Dan
 
Dan Drillich
Ranch Hand
Posts: 1183
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
BTW, you don’t need to associate a prefix to the namespace, you can do the following –
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE A [
<!ELEMENT A (B)>
<!ATTLIST A xmlns CDATA #FIXED "http://www.foo.org/">
<!ELEMENT B (#PCDATA)>
<!ATTLIST B xmlns CDATA #FIXED "http://www.foo.org/">
]>
<A>
<B>abc</B>
</A>
Cheers,
Dan
 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Is it a sequence problem that foo ns is declared in line 4 and it is getting used in line 2 of the DTD
 
Did you ever grow anything in the garden of your mind? - Fred Rogers. Tiny ad:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic