Reintroducing the Structured Source Editing family of editors
Reintroducing the Structured Source Editing family of editors
Structured Source Editing in Milestone 2

The Structured Source Editing (SSE) family of editors are now available as part of WTP 1.0M2. They support editing XML, DTD, HTML, CSS, JavaScript, and JSP files. The SSE editors make significant usage of Eclipse frameworks as well as each other. For end users it means that they behave consistently with each other as well as with other Eclipse editors. Users of the JDT's Java editor will recognize many of the features they're used to seeing there available in many of the SSE editors:

  • Configurable syntax highlighting
  • Editing of external files
  • Quick Diff
  • Delimiter matching
  • Content Assist Templates
  • Outline view with functional context menu
  • Properties view
  • Comment toggling and block commenting and uncommenting
  • Line shifting
  • Next/Previous Annotation navigation
  • Finding All Occurrences in the file
  • Highlighting for remote files (ex.: files opened from the CVS Explorer)
  • Source menu actions in the Navigator
  • Navigate|Show In menu in the editors
Settings for one language are reflected when editing other languages. For example, the CSS highlighting preferences are obeyed in the HTML editor while the CSS, HTML, and Java highlighting preferences are obeyed in the JSP editor. Refactoring changes made to Java files affect references in JSP files (and vice versa) and JSP files are included in Java search results.

And there's much more. See the feature summary for an overview of what editing feature is supported by which editor. Also see the XML Catalog Tutorial and the New XML File Tutorial for related information.

Content Assist

Content Assist provides a list of proposals, basically "text available to insert into the document", at the current cursor location. You can invoke Content Assist from the menu, or by pressing Ctrl+Space . Content Assist will always try to leave the document in a well-formed state after a proposal is inserted.


Content Assist is very sensitive to context. You will get different proposals depending where the caret is in the document.


In a JSP file you have many different content types. In the HTML regions, you will get appropriate HTML tag proposals when you invoke content assist. In server-side scripting regions,( <%...%> ), you will get proposals for the scripting language of the JSP file. If the language is Java, you will get appropriate Java proposals for that cursor position.


In a XML file, proposals may come from a referenced content model if a DTD or Schema is specified for the file, and then possibly through the XML Catalog . This will give you "smarter" proposals, such as specific child element proposals within a given element, or required attribute proposals.


In a HTML file, if you invoke Content Assist within a style tag or attribute you will get CSS Content Assist proposals:
<p style="|"> text </p>

here you will get JavaScript proposals:
<button onclick="|"> text </button>

XML Catalog

Web Tools allows you to store DTDs or Schemas locally in the XML Catalog and have the documents map to PUBLIC ids. These ids are usually specified in XML documents via the
<!DOCTYPE> declaration. Users have the option of specifying a DTD/Schema via a SYSTEM id (local file system) or PUBLIC id (for pure catalog-based lookup).


Examples of instructions placed at the top of an XML file defining grammar constraints :


<!DOCTYPE JobPosting SYSTEM "JobPosting.dtd">
(looked up locally in the same folder as the XML file)


<!DOCTYPE JobPosting PUBLIC "">
(looked up in the catalog with "" as a key)


<po:purchaseOrder xmlns:po="" xmlns:xsi="" xsi:schemaLocation=" PurchaseOrder.xsd ">
(looked up in catalog with " PurchaseOrder.xsd " as a key)


What are catalog entries used for?
The DTD/Schema entries are used for a number of things. They can give you context sensitive Content Assist proposals in a XML document. They give rules for what to mark as errors in as-you-type validation.


The Structured source editors support editing XHTML files. When users use any of the XHTML DOCTYPE (XHTML 1.0 Strict, XHTML 1.0 Transitional, XHTML 1.0 Frameset) the content model for that particular DOCTYPE is followed. When users perform Content Assist within the document, they get the correct list of tags and attributes. Other editor functions will also respect the new well-formedness and validity constraints.


When should you use catalog entries? Typically, DTDs and Schemas in a document are specified so they are availble via URL download as well as identified by ID. So if you are connected to the internet there would be no reason you would be required to use a catalog entry. However, if you ever work disconnected, you can download your own copy of the DTD to your local file system, and create a catalog entry for it, so it can be found whether connected or not. And, since the priority order of "lookup" is that it looks for catalog entries first, and then the network URL's, there is sometimes some performance advantage to having a local copy.

Editor-relevant preferences

All Structured source editors have a "Preferences.." action in the editor context menu. When this action is performed, the preferences relative to this editor are displayed in a dialog to the user.

  In editor preferences menu

This allows users to change editor preferences easily and immediately without having to navigate the entire preference page tree.


In editor preferences

Hover Help

Hover help is displayed when users mouse over text in Structured source editors.

  Hover help

There are several different types of hover help that can appear for the user.

Text Hover Name Description
Annotation Description Displays description of the current annotation shown in text. For example, if a task is highlighted in the editor and the user mouses over the task text, hover help displays the name of the task.
Documentation Description Displays documentation of the text. For XML elements and attributes, the content model of the current element/attribute is displayed. If additional documentation information is included in the associated schema, that information is also displayed. For HTML elements, a description of the current tag is displayed. For HTML attributes and JSP tags/attributes, the content model of the currently selected tag/element is displayed. For JSP Java content, the JavaDoc for the currently selected object/method is displayed.
Problem Description Displays description of the current problem shown in text. For example, if the user has an error in a XML file and the user mouse overs the text with the error indication, hover help displays the error description.
Combined Hover Displays the description from the previously mentioned hover help types that best fits the currently selected text.

The hover help displayed depends on the modifier keys users press when hovering over text. Users can control the type of hover help displayed in the Structured Text Editors Hovers preference page.


Hover help preferences

Open Selection [with hyper-link support]

Users are able to open on/navigate to the source/declaration/referred to file of certain tag attributes by using the Open Selection menu item (shortcut key F3 by default). They are also able to perform the same action by using a combination of pressing a modifier key (the Ctrl key by default) and their mouse to hover over the tag users want to open selection on. A hyperlink will then appear for users to click on to Open Selection.


Open on hyperlink


The file opened depends on the type of tag the user Open Selections on.

Tag File opened
any HTML tag that contains a URI attribute (as defined by the HTML 4.01 DTD) such as the Anchor tag the file located in the URI attribute value
any JSP tag that contains a URI attribute (as defined by the JSP 1.2 Specification) such as the jsp:forward tag the file located in the URI attribute value
jsp:useBean the class referenced by the useBean action
JSP scriptlets selected Java element's declaration
DOCTYPE Declaration the file referenced by the public/system ID
Schema location attribute the file referenced by the schema location attribute

Users can control behaviour of the hyperlink navigation in the Structured Text Editors Navigation preference page.


Open on navigation preferences

As-you-type validation

Errors are found and displayed in the editor while editing the document.


General XML syntax:
General syntax for XML will be marked as you type. This includes errors such as missing quotes, missing brackets, missing end tags... Quick fix will be provided for many of these syntax errors.


DTD/Schema backed validation:
If a DTD/Schema is specified in the XML file, as-you-type validation will enforce these constraints (eg. number of elements, children, names...), and mark errors in the file accordingly.


JSP-Java validation:
Server-side script regions (for the Java language) in JSP files will be marked with Java as-you-type errors (eg. missing imports, bad Java symbol references).


XML Catalog:
The DTD/Schema specified in the XML can be available locally in the XML Catalog. An Internet connection need not be available.

Expand Selection To menu

You can quickly select XML elements using the Structured Selection feature. Highlight a XML element and press Alt+Shift+Arrow Up or select Edit > Expand Selection To > Enclosing Element from the menu bar - the selection will be expanded to the smallest XML element that contains the selection. You can then further expand the selection to the enclosing element, the next element, the previous element, or restore the last selection by selecting Enclosing Element, Next Element, Previous Element, or Restore Last Selection from the Edit > Expands Selection To menu bar respectively.

Smart Insert

The XML Editor has a Smart Insert mode which can be toggled via Edit > Smart Insert Mode or Ctrl+Shift+Insert (by default). In Smart Insert mode, the editor provides language-specific extras. For example, when you start typing an end tag, "</", in a XML file after a start tag with its end tag missing, Smart Insert completes the end tag automatically. When you start typing the opening of a XML comment, "<!—", Smart Insert ends the comment for you by inserting the closing "-->", leaving the caret in the middle of the comment tag so you can continue typing the comment text.

Linked Editing

In Linked Edit mode, you may change multiple occurrences of a string in the file simultaneously. This is most easily seen through Quick Fix and Quick Assist , such as the Quick Assist shown below for renaming an element:


XML tag name linked editing

Formatting and Cleanup

XML Formatting lets you reformat the indentations and line delimiters, and reflow long lines of the selected XML element or the whole XML document. XML Formatting makes the document easier to read and better for printing. The XML formatting options are configured on the XML Source preference page ( Window > Preferences > Web and XML > XML Files > XML Source ).


preference page block for XML formatting


Highlight a XML element and press Ctrl+I or select Source > Format > Active Elements from the menu bar to format the selected XML element. Press Ctrl+Shift+F or select Source > Format > Document from the menu bar to format the whole XML document.


XML Cleanup lets you correct simple errors in the XML document such as adding required attributes that are missing, inserting missing begin or end tags, and quoting unquoted attribute values. Some convenient options, such as compressing empty element tags, formating the source, and converting line delimiters, are provided to make documents more consistent.


popup Cleanup dialog

JavaScript Editor with Preview

With the help of the Outline view, the JavaScript Editor gives you a clear hierarchy view of the JavaScript variables and functions you have in the JavaScript file. JavaScript keywords are highlighted in different colors and Content Assist provides you with a list of suggested completions for partially entered strings along with visual indicators for the web browsers that support the method.


JavaScript Editor


SSE provides two JavaScript editors differing only by the presence of a Preview page. The Preview Page in the JavaScript Editor lets you test your code by wrapping the file in a simple HTML file using a script tag. You may also preview the JavaScript file with any HTML file in the project that includes the JavaScript file.


JavaScript Editor's Preview page

Quick Fix and Quick Assist

In the XML editor, if you see an error underlined with a squiggly line, position the caret inside the underlined range and press Ctrl+1 or select Edit > Quick Fix to see a list of suggested corrections.


XML Quick Fix example


Quick Assist proposals are available even if there is no problem or warning.


XML Quick Assist example


Depending on the Quick Assist proposal, you may enter the Linked Edit mode where you may change multiple occurrences of a string in the file simultaneously.


XML Quick Assist example with Rename Element chosen


Quick Fix and Quick Assist proposals for Java code embedded in JSP files are also available.


Quick Fix example of Java in the JSP editor

JSP semantic highlighting

The JSP editor allows you to highlight JSP and custom action tags differently from HTML and XML to help distinguish the JSP content from the its template content.


JSP Style preference page; the Java source is not itself highlighted in this preference page
Did you know that clicking in the sample text area automatically shows the style settings for that text's content type?

JSP Debugging

The JSP editor can set breakpoints compatible with JSR-045 compliant servers such as Apache Tomcat 5.0 and newer. As in the JDT Java editor, breakpoints are set using the ruler's context menu.


the JSP editor ruler context menu


When stepping, local variables are visible as well as the JSP source itself.


a JSP being debugged


The Debug perspective's Run menu and its accelerators are also made available.


The Debug perspective's Run menu