netbeansnetbeans-8netbeans-10

What is wrong with my layer.xml from netbeans?


I try to create a new palette in netbeans 10, but the following 2 errors don't allow me to compile the project:

Document root element "folder", must match DOCTYPE root "JavaPalette". [3]

The markup in the document following the root element must be well-formed. [11]

My XML looks like this:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE filesystem PUBLIC "-//NetBeans//DTD Filesystem 1.2//EN"     "http://www.netbeans.org/dtds/filesystem-1_2.dtd">
<folder name="JavaPalette">
<folder name="Items">
    <attr name="SystemFileSystem.localizingBundle" stringvalue="org.netbeans.modules.javasourcefilepalette.Bundle"/>
    <file name="Item.xml" url="resources/Item.xml">
        <attr name="SystemFileSystem.localizingBundle" stringvalue="org.netbeans.modules.javasourcefilepalette.Bundle"/>
    </file>
</folder>
</folder>
<filesystem/>

I have no clue what both error messages mean, but i did exactly what is said in the tutorial. Online validation of the xml file also shows that error.

https://platform.netbeans.org/tutorials/nbm-palette-api2.html


Solution

  • I didn´t followed the tutorial, but as far as i can tell, your filesystem tag is not valid. If you take a look at the DTD you can see that the element filesystem isn´t declared as EMPTY (for more information you can read more about it here). So you have to provide a start and end tag. In your posted example you are only using <filesystem/> which isn´t allowed.

    You have to change the xml as follows:

    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE filesystem PUBLIC "-//NetBeans//DTD Filesystem 1.2//EN"     "http://www.netbeans.org/dtds/filesystem-1_2.dtd">
    <filesystem>
        <folder name="JavaPalette">
            <folder name="Items">
                <attr name="SystemFileSystem.localizingBundle" stringvalue="org.netbeans.modules.javasourcefilepalette.Bundle"/>
                <file name="Item.xml" url="resources/Item.xml">
                    <attr name="SystemFileSystem.localizingBundle" stringvalue="org.netbeans.modules.javasourcefilepalette.Bundle"/>
                </file>
            </folder>
        </folder>
    </filesystem>