September 2003
Intermediate to advanced
336 pages
7h 20m
English
Namespaces use URIs to distinguish elements and attributes. The prefix is syntax sugar, nothing more—it's the URI that counts, not the prefix. All code you write should depend on the URI, not the prefix. For example, suppose you're writing a Java program that uses the DOM API to search for XLink elements. The following code fragment is correct because it relies on the URI and the local name.
public boolean isSimpleLink(Element candidate) {
if (candidate.hasAttributeNS("http://www.w3.org/1999/xlink",
"type"); {
return true;
}
return false;
}
However, the following code is incorrect because it assumes the prefix is xlink and does not consider the URI.
public boolean isSimpleLink(Element candidate) ...
Read now
Unlock full access