Add an XSD file to Eclipse and Eliminate Those Pesky XML Warnings
If you work with Eclipse and JSF 2, you too may be annoyed at the little
that shows up next
to all your faces-config.xml files (even those that are blessedly
empty).
Here is how you can get rid of them, and add autocompletion to faces-config editing as well, in case they aren't empty after all. (Most of mine contain a single element, to specify a resource bundle. Eliminating that would be a nice item for convention-over-configuration in JSF 2.1).
- Download the source code for JSF 2 from http://javaserverfaces.dev.java.net
- Make a directory such as
~/xsdand copy all files with extension.xsdfrommojarra-version-sources/jsf-api/docinto that directory (so you can remove the source later) - In Eclipse, locate a
faces-config.xmland copy the entryhttp://java.sun.com/xml/ns/javaee/web-facesconfig_2_0.xsdfrom thexsi:schemaLocationattribute. You'll need it in the clipboard for step 5. - Select Window → Preferences →
XML → XML Catalog.

- Select Add and fill in the dialog as shown below. Pick
the
.xsdfile by clicking on File System and navigating to the directory in which you saved the files. Change the Key Type to Schema Location. Paste in the key.
- Rebuild your project. The
should be gone.
This also works for other XML schemas (such as the one for facelet tag library descriptors).
- Login or register to post comments
- Printer-friendly version
- cayhorstmann's blog
- 3706 reads






Comments
Good one
by jaikiran - 2009-12-18 04:34
Useful tip! Thanks. Now i can get auto complete working for xml which refer to my local xsd in the workspaceEclipse bug?
by ludo - 2009-09-22 17:14
Hi, I need to know if this is me or Eclipse itself having a bug... I registered this new schema as you describe and I am playing with a simple web app that has a faces-config.xml using the 2.0 schema and 1 managed-bean defined...On the name of the managed-bean, Eclipse is emitting this validation error:
Description Resource Path Location Type cvc-id.3: A field of identity constraint 'faces-config-managed-bean-name-uniqueness' matched element 'faces-config', but this element does not have a simple type. faces-config.xml HelloFacelet/WebContent/WEB-INF line 7 XML Problem
The same faces-config using the 1.2 schema does not expose this error...
It's hard to tell without
by cayhorstmann - 2009-09-23 09:29
It's hard to tell without seeing your faces-config.xml. I no longer have managed beans in my faces-config files :-) I just put in a bogus one. Autocompletion worked, and I didn't get an error.new Java EE 6 schemas now in the GlassFish Plugin
by ludo - 2009-09-18 12:14
Hi Cay, When we push our GlassFish plugin 1.0.34 for Eclipse soon (next week?) all the new EE 6 schemas (including the new faceconfig and many others) will be automatically declared to Eclipse so that you do not need to do this manual step anymore... Thanks, Ludoby pshiwakoti - 2009-07-22 08:15
hi Dr. Horstmann, I am your student from Software Engineering, CS160, SJSU fall. I was trying to be involved in open source projects to keep up the learning process and may perhaps develop something a new. Will you suggest where I should start with since learning Blackberry Application Development was challenging but quite interesting. sincerely, Prakash Shiwakoti SJSU