facebook

[Closed] taglib parse error re tag

  1. MyEclipse IDE
  2.  > 
  3. Java EE Development (EJB, JSP, Struts, XDoclet, etc.)
Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #250685 Reply

    svgray
    Member

    Hello,

    I have a custom tag library defined that is giving me a strange parse error. The relevant part tld file is:

    <?xml version="1.0" encoding="UTF-8"?>
    <taglib version="2.0" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-jsptaglibrary_2_0.xsd">
        <tlib-version>1.0</tlib-version>
        <short-name>ddiindex</short-name>
        <uri>http://assda.anu.edu.au/ddiindex</uri>
    
        <tag>
            <description>Gets ddi fields defined in index-conf.xml</description>
            <name>GetFields</name>
            <tag-class>org.assda.ddiindex.jsp.GetFieldsTag</tag-class>
            <body-content>JSP</body-content>
            <attribute>
                <description>The type of field to retrieve. Valid value sare 'datast' or 'variable'</description>
                <name>type</name>
                <required>true</required>
                <rtexprvalue>true</rtexprvalue>
            </attribute>
            <variable>
                <description>The field name used in the lucene index</description>
                <name-given>fieldName</name-given>
                <variable-class>java.lang.String</variable-class>
                <scope>NESTED</scope>
            </variable>
            <variable>
                <name-given>fieldLabel</name-given>
                <description>The field name used in the lucene index, plus whether the field is variable or dataset level</description>
                <variable-class>java.lang.String</variable-class>
                <scope>NESTED</scope>
            </variable>
            <variable>
                <name-given>fieldSelected</name-given>
                <description>Set to "selected" if the field should be selected in the drop-down list by default</description>
                <variable-class>java.lang.String</variable-class>
                <scope>NESTED</scope>
            </variable>
        </tag>
    
    </taglib>
    

    The error generated is:

    cvc-complex-type.2.4.a: Invalid content was found starting with element 'variable'. One of '{"http://java.sun.com/xml/ns/j2ee":attribute, "http://java.sun.com/xml/ns/j2ee":dynamic-attributes, "http://java.sun.com/xml/ns/j2ee":example, "http://java.sun.com/xml/ns/j2ee":tag-extension}' is expected.
    

    The line causing the error is the first <variable> tag.

    The tld file is in WEB-INF/conf, and I’ve added this folder to the classpath using “Add Class Folder”.

    I’ve checked the xml shema at http://java.sun.com/xml/ns/j2ee/web-jsptaglibrary_2_0.xsd and as far as I can tell there’s nothing wrong with the tld file. Can anyone help?

    Thanks very much,
    Steve

    #250765 Reply

    Riyad Kalla
    Member

    Your ordering is shot, your variable’s need to come before attribute and your desc neeed to come before your name-given:

    
    <?xml version="1.0" encoding="UTF-8"?>
    <taglib version="2.0" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-jsptaglibrary_2_0.xsd">
        <tlib-version>1.0</tlib-version>
        <short-name>ddiindex</short-name>
        <uri>http://assda.anu.edu.au/ddiindex</uri>
    
        <tag>
            <description>Gets ddi fields defined in index-conf.xml</description>
            <name>GetFields</name>
            <tag-class>org.assda.ddiindex.jsp.GetFieldsTag</tag-class>
            <body-content>JSP</body-content>
            <variable>
                <description>The field name used in the lucene index</description>
                <name-given>fieldName</name-given>
                <variable-class>java.lang.String</variable-class>
                <scope>NESTED</scope>
            </variable>
            <variable>
                <description>The field name used in the lucene index, plus whether the field is variable or dataset level</description>
                <name-given>fieldLabel</name-given>
                <variable-class>java.lang.String</variable-class>
                <scope>NESTED</scope>
            </variable>
            <variable>
                <description>Set to "selected" if the field should be selected in the drop-down list by default</description>
                <name-given>fieldSelected</name-given>
                <variable-class>java.lang.String</variable-class>
                <scope>NESTED</scope>
            </variable>
            <attribute>
               <description>The type of field to retrieve. Valid value sare 'datast' or 'variable'</description>
                <name>type</name>
                <required>true</required>
                <rtexprvalue>true</rtexprvalue>
            </attribute>
        </tag>
    
    </taglib> 
    

    A cool trick is to download the Schema you are looking at, then open it in MyEclipse, then flip to the “Graph” tab at the bottom of the editor. You can explore your schema like XML spy.

    #250794 Reply

    svgray
    Member

    Thanks very much for the help and the tip re schemas – it’s now working.
    Steve

    #250795 Reply

    Riyad Kalla
    Member

    Glad to hear it, schemas are hairy enough as it is. Hopefully that tip helps.

Viewing 4 posts - 1 through 4 (of 4 total)
Reply To: [Closed] taglib parse error re tag

You must be logged in to post in the forum log in