• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

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
 
It means our mission is in jeapordy! Quick, read this tiny ad!
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic