摘自MyEclipse 6.0帮助文件)
| ||||||||
Outline | ||||||||
1. PrefaceThis document was written using Sun JDK 1.4.2, Eclipse 3.2.2 and MyEclipse 5.5. All screenshots are based upon the default user interface settings for Eclipse, MyEclipse Enterprise Workbench, and Windows XP. 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. IntroductionThis document will cover some of the functionalities available in the MyEclipse XML Editor. The MyEclipse XML editor includes advanced XML editing functionalities like:
| ||||||||
3. XML EditingEditing XML using the MyEclipse XML Editor can be done in two different modes: Design Mode and Source Mode. You switch between the two modes using the tabs at the bottom of the editor:
Switching between the two modes can be done any time as they are both kept in sync with each other automatically. First we will take a look at the Design Mode. | ||||||||
3.1 XML Design ModeWhen you first open an XML document and switch to the Design Mode, it will look something like this:
In this mode the contents of your XML document are shown to you in something of a glorified outline-view. Along the left column you have the tags that make up your document and in the second column you have the values for those tags. You can double-click on any of the values in the second column and edit them directly in this view, making it very easy to visually understand and edit an XML file without worrying about syntax problems. Another nice feature of using the Design Mode is that you can add, remove and edit tags visually and the designer will make sure to only provide you with options that properly adhere to the DTD or Schema referenced by the document. More specifically, the design won't allow you to insert an invalid tag somewhere. As an example, let's say we wanted to add a description to the first context-param argument in our XML document:
You will notice at this point in the document, according to the Schema referenced by our document, the only valid tags that can be inserted here is a child description tag, a comment tag or a generic processing instruction tag. If we click on the description tag, it is added and we can quickly edit the description to something we want:
Editing any of the tag values or adding/removing child tags can be done in this fashion without ever needing to switch to the Source Mode for editing. Although editing the source directly can be faster sometimes and some developers prefer it, so let's take a look at that next. | ||||||||
3.2 XML Source ModeWhile editing XML documents in design mode can certainly be easier at times and save you from making errors, it's also necessary (or preferred) to work directly with the source code. If that is the case MyEclipse's XML Editor provides extensive source-editing features that we will take a look at below. When you first open your XML document to edit it, it will look something like this:
You'll notice a collection of views available to help you edit your document. The source view on the left will look familiar to many, then you have a simplified Outline view on the top right, and Properties view on the bottom right (NOTE: Due to the flexible nature of laying out MyEclipse's views, you can move them anywhere you like and may not look identical to the screenshot above). All these views will stay in sync with the file you are editing as you work. As you click inside of tags the Properties view will show you the values for that tag, if you decide to remove or add nodes using the Outline view as shown here:
The Outline view actually provides very similar visual-editing functionality that the Design Mode does if you'd prefer to use it. If you decide to edit the XML source from the editor you will notice some very nice assistance as you work. For example, mistyping a tag or attribute name will get marked immediately for you as an error (checked against the DTD or Schema referenced by the doc):
And to help make editing easier, content-assist is available for tags and attributes. The content-assist is also context-away, so it will not suggest illegal completion options to you based on the position of your cursor:
Alot of the functionality provided by the MyEclipse XML Editor is dependent on your document correctly referencing a DTD or Schema such that the editing tools can verify your work and provide content-assist against a specification. If you are editing a plain XML file that provides no DTD or Schema, the editor will still provide syntax highlighting and basic best-guess content-assist for you as well as basic validation (like unclosed tags) but some of the more advanced features for your editing won't be available. | ||||||||
4. PreferencesThe 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:
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:
| ||||||||
5. ResourcesThis section provides some links to resources used during this guide.
| ||||||||
6. User FeedbackIf you have comments or suggestions regarding this document please submit them to the MyEclipse Documentation Forum. |