« Return to Thread: simple xml editor

Re: simple xml editor

by Vivek Jain-2 :: Rate this Message:

Reply to Author | View in Thread

Hi Roberto,

I hope you are creating a new file type for an xml document which ends with +xml. MIME types like  text/???+xml are used in the IDE to represent an XML document. Creating a filetype like this, IDE will treat your files as an XML document. Netbeans Editor will provide all functionality like code highlighting, indent, code folding, code completion and any other to your xml document.

To get the schema based code completion for your xml files, you have to install enterprise pack. Once you install NB enterprise pack, run your module project, and create new file (that is your xml document). In your xml document, provide the value for schemaLocation attribute which will be the relative or absolute location of your schema file. Just doing this will give you the schema support for your xml files.

Please note that Currently schema-based code completion for xml files works only if we provide value for 'schemaLocation' attribute and the value should be relative or absolute path of xsd file on the filesystem. Schema based Code Completion is not available through XML catalog. I have filed an issue (fix in progress) on Netbeans XML component to provide Schema based Code Completion through XML catalog.

To get validate, checkXml, Transformable support, you have to add the following code to your DataObject. Refer this link for the same http://wiki.netbeans.org/wiki/view/DevFaqNewXMLFileType
        CookieSet cookies = getCookieSet();
        cookieManager = new DataObjectCookieManager(this, cookies);
        cookies.add((Node.Cookie) DataEditorSupport.create(this, getPrimaryEntry(), cookies));
       
        InputSource is = DataObjectAdapters.inputSource(this);
        Source source = DataObjectAdapters.source(this);
       
        cookies.add(new CheckXMLSupport(is));
        cookies.add(new ValidateXMLSupport(is));
        cookies.add(new TransformableSupport(source));
To get the Navigator support for your xml files Add following code in your layer.xml file (with your xml MIME type)
    <folder name="Navigator">
        <folder name="Panels">
            <folder name="text">
                <folder name="MIME_TYPE">
                    <file name="org-netbeans-modules-xml-text-navigator-XMLNavigatorPanel.instance"/>
                </folder>
            </folder>
        </folder>
    </folder>

Thanks & Regards,
Vivek
------------------------------------
http://www.netbeans.org/
http://www.sun.com/
------------------------------------


Roberto Nunnari wrote:
Hello.

I'd like to develop a simple xml editor based on netbeans platform for a particular xml schema, something like the ide has for the web.xml file.
Just the explorer, the navigator, the editor and the output window.

I have to say that even though I've been using netbeans since early 2001 for java development, I'm a beginner with module development.

I just started working on the module with netbeans ide 5.0 (but tomorrow I'll upgrade to 5.5) and using the wizard, have already made a new file type for my xml namespace.

Launching the new application, I see that my xml files are recognized, as the icon I set for this file type is shown.

The first problem is that the new fileType seams to not have inherited all the functionalities used for xml files.

1) the well formed and validate buttons in the editor are disabled.
2) the navigator doesn't show anything

But the editor still uses highlighting and colors..

Of course, when editing an xml file that doesn't use an xml schema the well formed and validate buttons are again enabled and the
navigator again shows its content.

How can I add all features present for plain xml files to my file type?

I also would appreciate any hints and directions you could give me on how to implement the editor (wizards, apis, files to edit, etc..)

Best regards.

--
Roberto

 « Return to Thread: simple xml editor