MyEclipse Logo
 

MyEclipse XML Schema (XSD) Editor Tutorial

Outline

download the latest MyEclipse version

help and support
 

1. Preface

This document was written using MyEclipse and all screenshots are based upon the default user interface settings for MyEclipse and Windows XP. However, if you experience difficulty with the instruction of this document, please see the User Feedback section for how to provide feedback to the MyEclipse documentation team.


 

2. Introduction

This document will cover some of the functionalities available in the MyEclipse XML Schema (XSD) Editor. The MyEclipse XML Schema (XSD) editor includes advanced XSD editing functionalities like:

  • 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

3. XML Schema Editing

Editing XML Schema files can be a bit different than editing standard XML files because Schemas are used to define a structure of an XML Document; like a grammar. Because of this XML Schemas not only have an XML-like structure to them but include grammatical notations like "1 or more occurances of tag X". XML Schemas can also define many different types of nodes and then ultimately a document structure that says how those nodes are related to each other.

Let's take a look at the Design Mode for XML Schema editing first.


3.1 XML Schema Design Mode

When opening an XML Schema in Design Mode you will likely see the visual layout of your file something similar to this:

Figure 9. XSD Design Mode

Looking at the layout above you can see your XML Schema laid out for you in a visual overview. Across the top you have the namespace that your schema is defined in. Your Directives are like Java Imports, they are external references that the XML Schema is making use of. Below that you have the Types that make up your XML Schema and to the left of the Types are the Elements. These are the structural definition 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 you should see the Outline and Properties views for the file as well, that look something like this:

Figure 10. Outline and Properties views

The Outline view shows you the same information you saw in the overview, but as you navigate through the overview, in and out of types and elements the Outline view will always give you a reference point of where you are. You can also edit the XSD from the Outline view, very similar to how it was done during the XML Editing section above.

As you make selections of Elements and Types in the Outline view the Properties view will update, showing you the properties for the node you have selected. You can change the values directly from the Properties view, overview or context menus. Giving you plenty of ways to work with your XML Schemas.

Double-clicking on an Element can jump you immediately into a view that is specific to that element like below:

Figure 11. Double-click an element 

After double clicking you will be shown that element displayed by itself and how it is defined:

Figure 12. web-app element overview

From this view we can see that the web-app element was defined as type web-appType. So we see here a structural overview of the web-app element. Given the first grouping multiplicity on the far left, we 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 on any portion of the overview and being presented with a context menu:

Figure 13. Right-clicking in the overview allows you to edit

Editing in this fashion can also be done from the Outline view, very similar to the XML Editor above. In the following example screenshot we are showing how to edit the grouping of a type directly from the Outline view (you can do the same from the overview if you prefer):

Figure 14. Outline view editing

Lastly, as you begin using the XML Schema editor you may notice that the overview for Types looks different than the overview for Elements, something like this:

Figure 15. Type overview

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

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

Now let's 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 simply seeing a breakout of the sub-types that make up the type you are looking at. You can drill further down into the sub-types if you want to determine more information about the XML Schema.


3.2 XML Schema Source Mode

Editing XML Schema is identical to editing XML documents, please see the XML Editing Tutorial.


4. 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.

All of these preferences can be accessed from Window > Preferences > MyEclipse > Files and Editors > XML:

Figure 16. XML editor preferences

Another feature of the XML editor that many developers may be interested in making use of is the 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.). That functionality can be accessed from the XML Templates sub-preference here:

Figure 17. XML templates preferences

5. Resources

This section provides some links to resources used during this guide.

  • web-app_2_4.xsd - Example XSD file used for the XML Schema editing portion of this document.

6. User Feedback

If you have comments or suggestions regarding this document please submit them to the MyEclipse Documentation Forum.