my dog learned polymorphism
The moose likes XML and Related Technologies and the fly likes DTD & Namespace Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "DTD & Namespace" Watch "DTD & Namespace" New topic

DTD & Namespace

Madhu VN

Joined: Jul 13, 2004
Posts: 2
The following code throws an error : Reference to undeclared namespace prefix:test

<?xml version="1.0"?>
<!DOCTYPE test:firstname [
<!ELEMENT test:firstname (#PCDATA) >
<!ATTLIST test:firstname xmlns:test CDATA "namespace">

Could anyone let me know why this code is throwing the error?
akshaya bhatt

Joined: Dec 24, 2000
Posts: 6
The error is with namespace declaration. Try to provide xslns, the general namespace from w3c, and also tyr to put "test:firstname"(try this)
Lasse Koskela

Joined: Jan 23, 2002
Posts: 11962
DTD doesn't support namespaces. You should use the W3C XML Schema instead (here's a nice tutorial).

Author of Test Driven (2007) and Effective Unit Testing (2013) [Blog] [HowToAskQuestionsOnJavaRanch]
I agree. Here's the link:
subject: DTD & Namespace
jQuery in Action, 3rd edition