stivlo stivlo - 1 year ago 111
Java Question

JSP custom tags: missing DTD/XML Schema

I've written my JSP custom tag with the following TLD:

<?xml version="1.0" encoding="UTF-8"?>
xsi:schemaLocation=" web-jsptaglibrary_2_1.xsd"
xmlns="" xmlns:xsi=""

Now Eclipse Helios complains that "No grammar constraints (DTD or XML schema) detected for the document."

I know how to disable the warning, I was instead wondering how to solve the problem by providing DTD or schema information.

By the way in the above piece of XML I have:

xsi:schemaLocation=" web-jsptaglibrary_2_1.xsd"

but it doesn't seem to help.

UPDATE on Peter's suggestion I went to check in my Window > Preferences > XML > XML Catalog and I found the following that may fit:

Entry element: Public
Location: dtdsAndSchemas/web-jsptaglibrary_1_2.dtd in jar file
URI: jar:file:/usr/local/eclipse/plugins/org
Key type: Public ID
Key: -//Sun Microsystems, Inc.//DTD JSP Tag Library 1.2//EN

So I tried to add the following to my tld:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE taglib PUBLIC "-//Sun Microsystems, Inc.//DTD JSP Tag Library 1.2//EN"

Now I've the following errors:

Multiple annotations found at this line:

  • Attribute "xsi:schemaLocation" must be declared for element type "taglib".

  • Attribute "version" must be declared for element type "taglib".

  • Attribute "xmlns" with value "" must have a value of " TagLibraryDescriptor".

  • schema_reference.4: Failed to read schema document 'web-jsptaglibrary_2_1.xsd', because

    1) could not find the document;
    2) the document could not be read;
    3) the root element of the document is not .

  • The content of element type "taglib" must match "(tlib-version,jsp-version,short-name,uri?,display-name?,small-icon?,large-icon?,description?,validator?,listener*,tag+)".

  • Attribute "xmlns:xsi" must be declared for element type "taglib".

Answer Source

If Eclipse doesn't automatically pick up the XSD from the library, you can always add it manually: Window > Preferences > XML > XML Catalog

In my case it was already present in the plugin section. It probably came with one of the Eclipse Java EE plugins.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download