Skip to main content

Notice: This Wiki is now read only and edits are no longer possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.

Jump to: navigation, search

New Eclipse Plugin for XQuery

Abstract

XML is an undying technique designed for data representation and data exchange. One great feature of XML is its ability to handle XML related matters using XML itself. XQuery is such a technique that is created in order to query XML documents using XML itself.

The purpose of this project proposal is to implement a XQuery editor plug-in for Eclipse that will be very helpful for web developers; specially for people that are dealing with querying XML data. Even with current somewhat limited capabilities of XQuery, it is largely used to query XMLDBs such as eXist or Qexo. But with the next suggested version of XQuery which is 1.1, XQuery could be the favourite for querying not only XMLDBs but also other XML based office documents and relational DBs.

Because of the importance of XQuery, I'm expecting to implement a XQuery plug-in that will be managed under Eclipse web tools project and under EPL.Therefore at the end of this project, we will have a fully functional editor (as-you-type syntax validating, error tips, syntax highlighting, outlining, content assistance, Ctrl+Space assistance & preference page) for XQuery.

Here is the complete proposal. [1]

Participants

Planned Features

  1. Syntax colouring
  2. Content outlining
  3. Syntax Validation and highlighting errors
  4. Error tips (Reason for errors and may be some guide to undo it)
  5. Content assistance
    1. Ctrl + Space to show the content support
    2. Code snippets
  6. Preference page to control the overall behaviour of the plug-in including syntax highlighting and defining the output

Legend

Glass.gif Needs some investigation/research

Progress.gif Work in progress

Ok green.gif Bug fixed / Feature added

Must Have

  • Ok green.gif Editor Partitioning
  • Ok green.gif XPath 2 Content Parser
  • Ok green.gif XQuery Content Parser
  • Ok green.gif Syntax colouring
    • Glass.gifSyntax Validation
    • Glass.gif error highlighting
  • Progress.gif Content assistance
    • Progress.gif Ctrl + Space to show the content support
  • Ok green.gif Preference Page

Should Have

  • Glass.gif Content outlining
  • Glass.gif Content assistance
    • Glass.gif Code snippets

Nice to have

  • Glass.gif Error tips

Milestones

M1 - Basic SSE structure

First goal was to produce a basic code base matching to that of a standard SSE (Structure Source Editing) plugin. First few weeks were given to this purpose and I was able to implement a suitable structure after reviewing other SSE plugins there such as HTML, CSS, XML, XSL and DTD.

M2 - Partitioning

Since XQuery is a XML syntax, it was only prudent to use a normal XML partition that will be parsed as XML Content by the standard XML plugin and another new partition for XQuery which will be parsed by this new plugin. Mainly StructuredTextPartitionerForXQuery class was used to implement partitioning and the result was an editor that identified usual XML syntax from the new syntax(XQuery).

 
 
    public String getPartitionType(ITextRegion region, int offset) {
 
        String result = null;
	if (region.getType() == DOMRegionContext.XML_CONTENT) {
	        result = IXQueryPartitions.XQL_XPATH2;
	} else {
		result = super.getPartitionType(region, offset);
	}
 
        return result;
    }

Xquery.jpg

Figure 1 - XQuery and XML Partitioning

M3 - XPath and XQuery parsing

Even though at the first it was suggested to implement a new XQuery parser using ANTLR, I was able to find an existing XQuery and XPath parsing library named xqpretty that matched to the job description (including license).

M4 - Syntax Colouring

Using xqpretty code I was able to implement syntax colouring for XQuery content and can be considered a major achievement in the project which identifies this plugin as a XQuery editor.

Xquery1.jpg

Figure 2 - Syntax colouring for XQuery

M5 - Update Site

For easy usage and testing for users of the plugin, a feature project and then an update project was created out of the plugin and is hosted at SourceForge currently.

Download URL: http://eclipse-incub.cvs.sourceforge.net/eclipse-incub/xquery_update

M6 - Content Assistance and additional

Currently only basic foundation is laid for content assistance and preference pages and required to be filled out.

Xquery-preference.JPG

Figure 3 - XQuery Basic Preference

Testing Examples

Here are few codes that have been used to test the plugin. More examples can be found at http://www.w3.org/TR/xquery-use-cases.

let $doc := .
for $v in $doc//video,
    $va in $v/actorRef,
    $a in $doc//actors/actor
where ends-with($a, 'Lisa')
    and $va eq $a/@id
return $v/title
<results>
  {
    let $a := doc("http://bstore1.example.com/bib/bib.xml")//author
    for $last in distinct-values($a/last),
        $first in distinct-values($a[last=$last]/first)
    order by $last, $first
    return
        <result>
            <author>
               <last>{ $last }</last>
               <first>{ $first }</first>
            </author>
            {
                for $b in doc("http://bstore1.example.com/bib.xml")/bib/book
                where some $ba in $b/author 
                      satisfies ($ba/last = $last and $ba/first=$first)
                return $b/title
            }
        </result>
  }
</results>

Community proposals

Feel free to add your comments and ideas.


Getting the source

Download the plugin from XQuery download site http://eclipse-incub.cvs.sourceforge.net/eclipse-incub/xquery_update

Download the source from SourceForge Eclipse Incubator.

ViewCVS: http://eclipse-incub.cvs.sourceforge.net/eclipse-incub/org.eclipse.wst.xquery

CVS: eclipse-incub.cvs.sourceforge.net/cvsroot/eclipse-incub/org.eclipse.wst.xquery

References

XQuery References

Other Help Materials

Back to the top