Set - 4

Question 11 :

Can I use XML namespaces in DTDs?

Answer :

Yes and no.
In particular, DTDs can contain qualified names but XML namespace declarations do not apply to DTDs .
This has a number of consequences. Because XML namespace declarations do not apply to DTDs:
1. There is no way to determine what XML namespace a prefix in a DTD points to. Which means...
2. Qualified names in a DTD cannot be mapped to universal names. Which means...
3. Element type and attribute declarations in a DTD are expressed in terms of qualified names, not universal names. Which means...
4. Validation cannot be redefined in terms of universal names as might be expected.
This situation has caused numerous complaints but, as XML namespaces are already a recommendation, is unlikely to change. The long term solution to this problem is an XML schema language: all of the proposed XML schema languages provide a mechanism by which the local name in an element type or attribute declaration can be associated with an XML namespace. This makes it possible to redefine validity in terms of universal names.


Question 12 :

Do XML namespace declarations apply to DTDs?

Answer :

No.
In particular, an xmlns attribute declared in the DTD with a default is not an XML namespace declaration for the DTD.. (Note that an earlier version of MSXML (the parser used by Internet Explorer) did use such declarations as XML namespace declarations, but that this was removed in MSXML 4.


Question 13 :

Can I use qualified names in DTDs?

Answer :

Yes. 
For example, the following is legal:

<!ELEMENT google:A (google:B)>
<!ATTLIST google:A
google:C CDATA #IMPLIED>
<!ELEMENT google:B (#PCDATA)>

However, because XML namespace declarations do not apply to DTDs , qualified names in the DTD cannot be converted to universal names. As a result, qualified names in the DTD have no special meaning. For example, google:A is just google:A -- it is not A in the XML namespace to which the prefix google is mapped. 
The reason qualified names are allowed in the DTD is so that validation will continue to work.


Question 14 :

Can the content model in an element type declaration contain element types whose names come from other XML namespaces?

Answer :

Yes and no. 
The answer to this question is yes in the sense that a qualified name in a content model can have a different prefix than the qualified name of the element type being declared. For example, the following is legal:

<!ELEMENT google:A (bar:B, baz:C)>

The answer to this question is no in the sense that XML namespace declarations do not apply to DTDs so the prefixes used in an element type declaration are technically meaningless. In particular, they do not specify that the name of a certain element type belongs to a certain namespace. Nevertheless, the ability to mix prefixes in this manner is crucial when: a) you have a document whose names come from multiple XML namespaces , and b) you want to construct that document in a way that is both valid and conforms to the XML namespaces recommendation .


Question 15 :

Can the attribute list of an element type contain attributes whose names come from other XML namespaces? 

Answer :

Yes and no. 
For example, the following is legal:

<!ATTLIST google:A  bar:B CDATA #IMPLIED>