I started learning XML yesterday but I cant get around the concept of DTD.
My thinking is that, this will cause an error since my picture tag contains a whitespace character and I explicitly mention in my DTD that this should contain only EMPTY element.
As per my understanding, empty element does not contain any character at all. Whitespace is a character I think.
But I am not sure why my eclipse editor is not displaying an error related to this?
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE person [
<!ELEMENT person (picture) >
<!ELEMENT picture EMPTY >
]>
<person>
<picture></picture>
</person>
Any thoughts?
The XML you’ve posted doesn’t actually include any whitespace which is why it validates just fine. If you had something like this:
you would have whitespace. An empty element can be written as either
<picture/>or<picture></picture>. They are equivalent.