facebook

MyEclipse XML Schema (XSD) Editor


1. XSD Editing in MyEclipse

This document covers some of the functions available in the MyEclipse XML Schema (XSD) editor. XML Schema (XSD) editor includes advanced XSD editing such as:

  • Visual overview representation of schema element and types
  • Visual editing of schema
  • Syntax highlighting
  • Tag and attribute content assist
  • Real-time validation (as you type)
  • Source, Design and Outline views of the document’s contents
  • Document formatting
  • Content-assist templates


2. Editing Modes

Editing XML schema files can be a bit different than editing standard XML files because schemas are used to define the structure of an XML document. Because of this, XML schemas not only have an XML-like structure to them, but also include grammatical notations like “1 or more occurrences of tag X”. XML schemas can also define many types of nodes, and then ultimately a document structure that indicates how those nodes are related to each other.


2.1 Design Mode

When opening an XML schema in Design mode, you see the visual layout of your file as something similar to this:


XSD Design mode

Looking at the layout above, you can see the XML schema laid out in a visual overview. Across the top, you see the namespace in which your schema is defined. The Directives are like Java imports; they are external references the XML schema is using. Below that, you see the Types that make up the XML schema, and to the left of the Types are the Elements. These items define the structur of the document, laying out the Types into a tree along with rules stating multiplicity, ordering, and so on.

On the right-hand side of the screen are the Outline and Properties views for the file as well.


Outline and Properties views

The Outline view displays the same information you saw in the schema overview, but as you navigate through the overview, the Outline view gives you a reference point. You can also edit the XSD from the Outline view in a similar way to how it was done during the XML editing section above.

As you select elements and types in the Outline view, the Properties view updates, showing you the properties for the selected node. You can change the values directly from the Properties view, overview, or using right-click context menus, giving you plenty of ways to work with your XML Schemas.

Double-clicking an element opens a view specific to that element.


Double-click an element 

After double-clicking the element is displayed by itself with its definition.


Web-app element overview

From this view, you can see that the web-app element was defined as type web-appType. So, you see here a structural overview of the web-app element. Given the first grouping multiplicity on the far left, you see we can have 0 or more of the sequence starting with distributable and ending with security-role.

Of course, each of those allowable children can have their own multiplicity specified as well. That way, the top level group specifies an ordering for the child elements, but the individual multiplicity on the children allows authors to specify 0 or more of the same tag, one after the other (e.g. like multiple servlet tags in a web.xml file).

You can also edit the content of the schema from this view by right-clicking any portion of the overview.


Right-clicking the overview allows you to edit

Editing in this fashion can also be done from the Outline view. The following example demonstrates how to edit the grouping of a type using the Outline view (you can do the same from the overview if you prefer).


Editing using the Outline view

Lastly, as you begin using the XML schema editor, you might notice that the overview for Types looks different than the overview for Elements.


Type overview

The difference is that the Type overview shows a break-out of the types for each field. Each of the types that define the fields of the type you are viewing are other types defined in the XSD. As an example, an XSD might define three types:

      • id, integer
      • name, string
      • dob, datetime

Now, say the XSD also defines the type Person that uses all these sub-types:

      • Person
      • social-security (type: id)
      • full-name (type: name)
      • birth-date (type: dob)

That is similar to what you are seeing in the layout above. You are seeing a breakout of the sub-types that make up the type you are viewing. You can drill further down into the sub-types if you want to determine more information about the XML Schema.


2.2 Source Mode

Editing XML schema is identical to editing XML documents. Please see the XML Editor overview.


3. Preferences

The XML editor preferences can control everything from how the syntax highlighting looks (e.g. color of tags and attributes), to how the page formats when the formatter is run.

Access these preferences by selecting Window>Preferences from the menu, expanding MyEclipse>Files and Editors, and selecting XML.


XML editor preferences

Another feature of the XML editor that many developers might want to use is template support. Templates are a way to assign a short keyword to a body of text that can be inserted directly into a file that is being edited along with some basic variable replacement (like timestamps, usernames, etc.). Templates can be accessed from the XML Templates sub-preference.


XML templates preferences


4. Resources