javajsp-tags

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"?>
<taglib
  xsi:schemaLocation="http://java.sun.com/xml/ns/javaee web-jsptaglibrary_2_1.xsd"
  xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  version="2.1">
  <tlibversion>1.0</tlibversion> 
  <jspversion>2.1</jspversion>
  ...

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="http://java.sun.com/xml/ns/javaee 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 
usr/local/eclipse/plugins/org.eclipse.jst.standard.schemas_1.1.0.v201003031644.jar
URI:       jar:file:/usr/local/eclipse/plugins/org
  .eclipse.jst.standard.schemas_1.1.0.v201003031644.jar!/dtdsAndSchemas
  /web-jsptaglibrary_1_2.dtd
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" 
"http://java.sun.com/j2ee/dtds/web-jsptaglibrary_1_2.dtd">

Now I've the following errors:

Multiple annotations found at this line:


Solution

  • 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.