Hi
I’m new to XML and am currently learning about Document Type Declaration. Anyways, when declaring elements in the body of DTD, the element name must appear exactly as it will within the XML document, including any namespace prefix, which means users can’t define their own namespace, but must use the prefix defined within DTD.
a) I assume that even though we must use prefixes defined within DTD, we are still able to choose to which URIs these prefixes point to?
b) Assuming we declare ( in DTD ) an element , where pers is a namespace prefix, does that mean all occurrences of this element within XML document will need to include a prefix “pers”? If that is the case, then that would mean that with DTDs we can’t use a default namespace feature?!
thanx
EDIT:
a)
Really, unless there is a particularly good reason to or you have simple syntactical requirements and no need for namespaces, you should consider using XML Schemas instead.
I do plan to use XML Schema instead, but I’d also like to learn the basics of DTDs.
b)
…there is no notion of namespace URIs (nor a default namespace).
If we declare attribute named “xmlns” within DTD:
<!ATTLIST contact xmlns CDATA #REQUIRED>
then XML document could use the default namespace feature( here child element <name>
is in the default namespace):
...
<contact xmlns=”www.somewhere.com” … >
<name></name>
</contact>
...
thanx