Exotic Ideas..
Angad's Blog
About this blog
I am Angad Singh. I have served as the Sun Campus Ambassador of JIIT University, Noida (India) from August 2007 to July 2008 and as a Campus Ambassador Tech Lead from July 2008 to July 2009. This was my sun blog. Here I jotted down all my random scribblings, reports on all activities I conducted as CA at my university, my little projects, hacks, geeky stuff and new technology I came across, all the way to things I learnt in my exciting journey with Sun..
About Me
View Angad Singh's profile on LinkedIn
Technorati Authority
View blog authority
Subscribe
Search

10 Recent Entries
Archives
« July 2009
SunMonTueWedThuFriSat
   
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
 
       
Today
Links
My..
Blogs that interest me
 

Today's Page Hits: 474

Best Viewed in..

Mozilla Firefox

Locations of visitors to this page
« Yay! Made it to the... | Main | Regular Expressions... »
Thursday Jun 12, 2008
Houston, we have lift off!
After hours of tinkering around, reading API documentation and learning Netbeaning, I have put the Netbeans XML hyperlinking project into orbit with the absolute ab-initio implementation of the first phase "Hyperlinking of a sub-element declaration to it's corresponding definition within the same DTD document", which comes under Use Case 2 in DTD use cases as described in our project's Dzone article.

Take a sneak peak at it in the NBXMLHyperlinking Screencast #1:



For example, in the following element definition:
<!--ELEMENT web-app (icon?, display-name?, description?, distributable?, context-param*, filter*, filter-mapping*, listener*, servlet*, servlet-mapping*, session-config?, mime-mapping*, welcome-file-list?, error-page*, taglib*, resource-env-ref*, resource-ref*, security-constraint*, login-config?, security-role*, env-entry*, ejb-ref*,  ejb-local-ref*)-->
Clicking on "icon" takes the user to it's corresponding definition:
<!--ELEMENT icon (small-icon?, large-icon?)-->
I had written a complete explanation of the implementation, with references to the places which proved useful, though that blog post just got cursed due to a system crash and I am in no mood of typing all that again. Anyway, FWIW, the folks over at the XML-DEV mailing lists were very helpful in providing me the official specification for DTD, and thanks to Rohan and the Netbeans OpenIDE mailing list for heading me in the right direction to get syntax support for DTD's in Netbeans and other problems that keep cropping up. After a lot of tinkering, in the middle of the night, yesterday, I figured out that the DTD lexer implementation in Netbeans uses Java CC. Take a look at the sources under o.n.m.xml.text.syntax and o.n.m.xml.text.syntax.javacc. If you want to learn how to implement custom hyperlinking in the editor, go through this nice tutorial.

I've basically implemented the HyperlinkProvider class. The first step is to determine whether the language element under the mouse cursor should be hyperlinked (isHyperlinkPoint) which is done by simple rule-based inferencing to check if the token in context is a sub-element or not. The biggest hurdle here was to get a token stream from the editor, since DTD support is kind of non-standard in Netbeans (the older ExtSyntaxSupport). The second step is to perform the actual "jump" action, to take the user to the source element definition, which I've done with regular expression patter matching. RegExPlugin came in handy again ;)

During the exploration part, when I was going through the DTD specs, XML tutorials, et al, and I've identified a few more use cases for hyperlinking within DTD files. Those will be furnished along with a detailed design document at wiki.netbeans.org soon. This is just a kick-off of the project and the brushed up well documented source code with unit tests will be pushed to the Netbeans HG repository under the /main/contrib folder once the initial phase completes.

Technorati Tags: ,,,,

Posted at 05:41PM Jun 12, 2008 by Angad Singh in Netbeans  |  Comments[1]  |  del.icio.us digg slashdot technorati Stumble It! Share on Facebook furl reddit Share on Twitter    

Comments:

nice work!

Posted by Aditya on June 13, 2008 at 07:18 PM IST #

Post a Comment:
  • HTML Syntax: NOT allowed
Creative Commons License

This work by Angad Singh is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 Unported License.