As you know, I have been running a blog series on “Playing with XML Layer”. I have written 3 parts till now, that were tips and Tricks…
Its time for Part 4, though this isn’t any tips and Tricks, as its an abstract tutorial to hyperlink XML Layer, which conforms to any Document-Type-Definition.
Already there exists a tutorial to hyperlink the value contained within the HREF attribute (HTML files) in Platform Tutorials.
At the bottom of that Tutorial, they have mentioned what could be the Next Steps to follow, basically Work Ahead!
Working with JSP and XML documents. (Same principle as above.)
As you can see they have mentioned in one of the points, that XML documents can follow the same principle. So, as part of my internship project, I worked to hyperlink the ELEMENT names and their ATTLIST attributes.
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE filesystem PUBLIC "-//NetBeans//DTD Filesystem 1.1//EN" "http://www.netbeans.org/dtds/filesystem-1_1.dtd"> <filesystem> <folder name="Actions"> <folder name="Tools"> <file name="org-nvarun-tat-SayCheez.instance"/> </folder> </folder> <!--Remember SayCheez in earlier parts, this is just a snippet of that XML Layer--> </filesystem>
Now, I made use of XMLTokenId, as the reference tutorial made use of HTMLTokenId, and did the implementation based on XMLTokenId constants.
The required HyperlinkProvider instance will be registered under text/xml, so any XML file with that MIME Type will hyperlink as suggested.
- When you click on filesystem/folder/file, a Dialog Box prompts the user with a message that you have clicked right hyperlink, IDE opens the DTD file represented by PUBLIC_ID.
- For that to happen, click on PUBLIC_ID first to let the IDE know which DTD, does the XML is specified by, then PUBLIC_ID -> URI mapping takes place (redesigning, refer to XML Code Completion support).
- Also, it extracts the DTD file clicking the SYSTEM_ID (if present is hyperlinked) conforms to and hyperlinks it, clicking it will launch the Browser with the identified URL.
When you click on filesystem/folder/file, locate the DTD file and open in NetBeans IDE, with specific caret position. As you know, Angad has already created a module for DTD-intra-hyperlinking! So, you would be able to enjoy both functionalities, similar to the one existing in IntelliJ IDEA!
Updated on July 14, 2008
sTay Tuned for More…