views:

38

answers:

1

When Eclipse detects an invalid XML document, in my case a web.xml file, it dumps the content model of the DTD and tells me that the element is invalid. This is quite unhelpful, since it ends up telling me that:

The content of element type "web-app" must match "(icon?,display-name?,description?,distributable?,context-param*,filter*,filter-mapping*,listener*,servlet*,servlet-mapping*,session-config?,mime-mapping*,welcome-file-list?,error-page*,taglib*,resource-env-ref*,resource-ref*,security-constraint*,login-config?,security-role*,env-entry*,ejb-ref*,ejb-local-ref*)".

In a 900-line web.xml file, the error is not easy to find.

How can I single out the first element which causes the document to be invalid?

+1  A: 

I would create a copy of the web.xml and cut the content in halves, (ensuring it stays well-formed) until I found the element. After that you add the remaining parts of your copied file.

stacker
Well, that's a good start. I found the problem by manual inspection, but it sounds _really_ silly to do this when Eclipse should point out the exact error line.
Robert Munteanu