user182944
user182944

Reputation: 8067

Custom Taglib Compilation error

I am trying to create a taglib for my custom tag. But I am getting a compilation error in Eclipse IDE. Here is my TagLib description:

<?xml version="1.0" encoding="UTF-8"?>
<taglib version="2.1" xmlns="http://java.sun.com/xml/ns/javaee" 
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
        xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-jsptaglibrary_2_1.xsd">
  <tlib-version>1.0</tlib-version>  
  <uri>MyFunction</uri>
  <function>
      <name>myFunc</name>
      <function-class>com.tldcls.MyClass</function-class>
      <function-signature>int age()</function-signature>
  </function> 
</taglib>

I am getting a compilation error on the tag. The error tells:

cvc-complex-type.2.4.a: Invalid content was found starting with element 'uri'.

I am not able to figure out where is the problem.

Upvotes: 0

Views: 2203

Answers (3)

eel ghEEz
eel ghEEz

Reputation: 1235

The schema's definition for uri points to an "anyURI" type,

https://www.w3.org/TR/xmlschema-2/#anyURI

This refers to the XLink href attribute which in turn refers to RFC 2396 which in turn says that URIs look as follows,

<scheme>:<scheme-specific-part>

Upvotes: 0

Suraj Prakash
Suraj Prakash

Reputation: 9

There is a XSD version error.

You can use xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-jsptaglibrary_2_0.xsd".

Upvotes: 0

JB Nizet
JB Nizet

Reputation: 692201

The XSD mentioned in the file (http://java.sun.com/xml/ns/javaee/web-jsptaglibrary_2_1.xsd) reveals that the taglib element has the following child elements, in this order

  • tlib-version
  • short-name
  • uri
  • ...

The short-name is not optional, and it's supposed to be the suggested prefix to use for this taglib.

Upvotes: 5

Related Questions