how to make Eclipse ignore errors in certain .xml files?

A

Andreas Leitgeb

Some project developed in Eclipse needs certain "*.xml"-files
for running/testing. Some of these files are (and really have
to be) invalid XML and eclipse flags them red.

I'd like to tell eclipse to treat certain handpicked xml-files
as opaque files and to not even attempt to validate them any way.
There are also *other* xml-files in the project that I still want
to have validated and eventually red-flagged. These however are
in different folders than the "bad" ones, in case it matters...

I've tried googling for: eclipse xml errors ignore validate
(and subsets thereof) but couldn't find a relevant one among
the results, yet.
 
E

Eric Sosman

Some project developed in Eclipse needs certain "*.xml"-files
for running/testing. Some of these files are (and really have
to be) invalid XML and eclipse flags them red.

I'd like to tell eclipse to treat certain handpicked xml-files
as opaque files and to not even attempt to validate them any way.
There are also *other* xml-files in the project that I still want
to have validated and eventually red-flagged. These however are
in different folders than the "bad" ones, in case it matters...

I've tried googling for: eclipse xml errors ignore validate
(and subsets thereof) but couldn't find a relevant one among
the results, yet.

Have you tried giving the bad files a different extension,
like "foo.bad" instead of "foo.xml"?
 
A

Andreas Leitgeb

Eric Sosman said:
Have you tried giving the bad files a different extension,
like "foo.bad" instead of "foo.xml"?

Thanks for the response!
No I haven't. I actually thought of it, but it wasn't an option...
(it would have implied some complication on the build process, that
the coworkers wouldn't have agreed on - they preferred to just
ignore those red flags)

I really just came back to post that I did find a solution
myself. (well, it was behind one of those google-hits, that I
had previously discarded as irrelevant by the abstract :-} )


For the record: In the Window->Preferences dialog, I pick Validation,
and in the line "XML Validator" I click the triple-dot-button. In the
Window that pops up, I then click on "Exclude Group", then button "Add
Rule".

I then selected the folder that contained those purposefully bad
xml-files, but I could just as well have selected each file indi-
vidually, or (probably) specified a pattern like "testcase-42.*.xml"
for the files to ignore.

It didn't immediately show any effect, though (even after "OK"ing
all the dialogs up to and including "Preferences"). I then right-
clicked on the folder in the "Project Explorer" pane of eclipse,
and from the context menu I picked Validate. Only then, the red
flags disappeared.

Nice thing is that (unlike renaming the files) these preferences
only affect me, so the coworkers still see the red flags on those
xml-files in their eclipse...
 
E

EricF

Some project developed in Eclipse needs certain "*.xml"-files
for running/testing. Some of these files are (and really have
to be) invalid XML and eclipse flags them red.

I'd like to tell eclipse to treat certain handpicked xml-files
as opaque files and to not even attempt to validate them any way.
There are also *other* xml-files in the project that I still want
to have validated and eventually red-flagged. These however are
in different folders than the "bad" ones, in case it matters...

I've tried googling for: eclipse xml errors ignore validate
(and subsets thereof) but couldn't find a relevant one among
the results, yet.
I see that you figured out how to get past this but it has a bad smell to it.
If the files are bad xml and have to be bad xml, then they should not be
xml.Or the bad part should be cdata. Someone doesn't know what they are doing.

Eric
 
A

Andreas Leitgeb

EricF said:
I see that you figured out how to get past this but it has a bad smell to it.

I do agree on the bad smell, but natural fertilizer typically has it, too... ;-)
If the files are bad xml and have to be bad xml, then they should not be xml.

The tool, to which these files are fed, woudn't accept anything but files
with an .xml extension. That means, we would have to rename the files to
..xml during production. Specifically silencing eclipse for them really looks
like the easier (less intrusive) solution. What I didn't write so far is,
that the maintenance of the valid and the invalid xmls is some coworker's job
and he probably appreciates seeing the red flags where he actively expects
to see them. It's an indication to them that the right part is wrong ;-)
Or the bad part should be cdata.

Making the bad part cdata, however, misses the point, as the files would be
correct xml, then.

Thanks, anyway, for caring that far. I don't ask anyone to waste more
thoughts into this thread. There are too many unanswered questions (two
old ones by myself, one about sharing code between a library-project and
a plugin-project in eclipse <[email protected]>,
and one about Corba and ssliop <[email protected]>)
whose answering would be so much more appreciated...
 
J

Jason Bailey

Thanks, anyway, for caring that far. I don't ask anyone to waste more
thoughts into this thread. There are too many unanswered questions (two
old ones by myself, one about sharing code between a library-project and
a plugin-project in eclipse<[email protected]>,
and one about Corba and ssliop<[email protected]>)
whose answering would be so much more appreciated...

Another thought, would it be acceptable to change the error message to a
warning? This is done through the configuration properties > Validation

-jason
 
A

Andreas Leitgeb

Jason Bailey said:
Another thought, would it be acceptable to change the error message to a
warning? This is done through the configuration properties > Validation

I vaguely remember having tried to configure all XML-Validation errors
to warnings already before posting here.

I just retried it: removed the exclude-rule, validated manually (red
flags re-appeared, as expected), set all the "Errors/Warnings"-items
to "warning", validated manually (red flags still there, as not wanted).

Then I re-instated the exclude rule for the folder, validated manually
and the red flags are once again gone.
 
R

Roedy Green

Some project developed in Eclipse needs certain "*.xml"-files
for running/testing. Some of these files are (and really have
to be) invalid XML and eclipse flags them red.

Would changing the extension be an option?
--
Roedy Green Canadian Mind Products
http://mindprod.com
The greatest shortcoming of the human race is our inability to understand the exponential function.
~ Dr. Albert A. Bartlett (born: 1923-03-21 age: 89)
 
A

Andreas Leitgeb

Roedy Green said:
Would changing the extension be an option?

Short answer: no, wouldn't. This suggestion and a (slghtly)
longer answer already appeared on this thread.

Btw., as you apparently see my posts, I wonder if you
also saw my followup on your request for translation of
that german poem by guenther grass.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,763
Messages
2,569,562
Members
45,038
Latest member
OrderProperKetocapsules

Latest Threads

Top