Reputation: 9201
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?
Upvotes: 0
Views: 245
Reputation: 7143
The XML you've posted doesn't actually include any whitespace which is why it validates just fine. If you had something like this:
<person>
<picture> </picture>
</person>
you would have whitespace. An empty element can be written as either <picture/>
or <picture></picture>
. They are equivalent.
Upvotes: 2
Reputation: 18531
You may want to format the XML like
<person>
<picture />
</person>
I don't think there is any whitespace in your picture element in your example which is why Eclipse won't throw an error.
Upvotes: 0