Morphon's Xml-editor

THDL Toolbox > Developers' Zone > Web-Development > XML Editors > Morphon's XML-Editor

Morphon's XML-Editor Manual

Contributor(s):

Note: Morphon Technologies (external link: www.morphon.com) is no longer distributing their XML editor. This was one of the first editors we used and was good for what it was, but it has been surpassed by other more recent and more powerful editors.

Specifications

Morphon is free, WYSIWYG XML editor that allows one to create and edit XML documents in an almost word-processor like style. It is Java based and has a plugin-API for future developments, as well as being available for different platforms. It supports both DTDs and XML Schemes, as well as namespaces. It uses CSS styles for creating its WYSIWYG view.

Setting up Morphon

The program is installed by double-clicking the .exe file (Morphon-XMLEditor-Windows-novm-3_1_2.exe). It will be installed in the Program Files directory. We will distribute a separate .zip file that contains the DTD, CSS style sheets, templates, and other data that THDL editors will need. (If you need this file contact, David Germano or Nathaniel Grove.) This file will contain a single folder (“xml”) that should be place at the root level of the C: drive of your computer, i.e., C:xml.

  1. Start up the Morphon XMLEditor.
  2. Under the Edit menu choose “Preferences”.
  3. On the left side TOC of the resulting window, choose “General”.
  4. Click on the button to the right of “Associate xml files with the editor (Windows only)”.
  5. Then on the left side TOC, choose “Catalogs”.
  6. Click the Add button.
  7. Locate the file: C:xmlcatalog.xml and click Open.
  8. On the left side TOC, choose "Editor Pane".
  9. Set the font to Arial Unicode MS, size 14.
  10. Change "Start edition mode with view mode" to "Inline Tags".
  11. On the left side TOC, choose "Attributes Panel".
  12. Check the box labeled "Auto-commit".
  13. Click the "OK" button on the preferences window to close it.
  14. Under the "Tools" menu, choose "Spell Checking", and from the drop down menu choose "Auto Spellcheck". This will cause misspelled words to be underlined in red dashes.

This will allow the Editor to open, parse, and validate against the DTD all compliant THDL xml document. To be compliant, a document must use the “xtib2.dtd” or the “xtibbibl2.dtd”. (Other dtds may be added at a later date.) The document must have an XML declaration and a doctype definition at the beginning, as below:

<?xml version="1.0" encoding="UTF-8"?> <?xml-stylesheet href="file://localhost/C:/xml/css/essay.css" type="text/css"?> <!DOCTYPE TEI.2 PUBLIC "-//THDL//DTD TibetanText//EN" "xtib2.dtd" > <TEI.2> … </TEI.2>

The root element for all THDL marked up texts is TEI.2, both the metadata and the text itself reside within this root level element.

Using Morphon

Document Views

If the preferences for Morphon have been set as described in the previous section, the initial view of a document will be of the nested tags: <TEI.2><body>. One will not that the metadata sections, <teiHeader>, which is before the <body> element is missing. This is because the basic stylesheet for editing texts makes this metadata section invisible, though if one were to look at the document in a plain text editor, one would see it is all there. Because of the setting in the preferences, the initial view of a document is with "Inline Tags", which includes the text of the document within arrow-like images of the mark-up elements. There are however several different views within Morphon. These are accessible from the View menu. In all the views, the styles from the CSS style sheet associated with the document are visible. These different views can be described as follows:

  • No Tags: This gives one a styled-text view where the XML elements are invisible. This is the WYSIWYG view of Morphon, though there are some differences from the actual web display. One has to be careful when editing in this mode, as it is not readily apparent in which element the cursor resides. Thus, text typed in may be inside the wrong tag. In the "status" bar at the bottom of the Morphon screen, there is the XPATH location of the cursor within the XML document. 4 This can help one make sure the cursor is in the right place.
  • Boxed Tags: This is a somewhat counterintuitive view. It represents the XML element hierarchy through a series of nested boxes with the name of the element in the bottom right corner, while descriptive tags, such as <hi> or <note> are represented by labeled underlining of the corresponding phrases. Since the hierarchy often gets rather deep and there are often many descriptive tags, the resultant view can be somewhat cluttered. However, the boxes do clearly delimit tag boundaries and simplify the entry of new text , preventing the kind of confusion that could arise with the No Tags view.
  • Inline Tags: This view presents the XML document with the tags represented as iconic arrow shapes with the name of the tag inside. This view is preferable because it is the clearest. The element tags also include a "-" (minus) sign. By clicking on the minus sign, one can collapse the content of that element into a single line. The "-" turns into a "+", and by clicking on that one can re-expand the element and its text.
  • Print Preview: This allows one to view the XML document, page by page, as it would look in print if it were styled according to the CSS stylesheet that has been chose. As will be explained below, the CSS stylesheets for THDL's XML texts have been developed to facilitate the use Morphon to edit XML documents and do not strictly represent what will be displayed on the web. For instance, in Morphon the CSS stylesheet shows notes included in brackets and colored teal. They appear inline at the place where the note element is included. However, in the web display of the document <note> tags are converted to footnote numbers that link to footnotes at the bottom of the page. The display difference in this case is quite different.
  • Source: The source view displays the XML document exactly as it would be seen in a simple text editor. This view is useful, when changing the mark-up in a way that requires one to temporarily disable validation. In all other views, Morphon is continually validating the document and will not let the use do anything that is invalid according to the DTD. However, there are some situations where turning off validation makes it easier to effect the change. Such changes can be done in Source mode. When one is in source mode, the check-mark icon in the task bar, below the menus, becomes active and turns green. By clicking on this green check-mark, one can check the validity of one's document at any time in source view. It is recommended that one do this often when using the source view.

Another aspect of the view is the layout of the Morphon window in general. At the initial start of the program after installation, the screen shows only the XML document and its tags. This is the main window pane of the program in which most of the editing will occur. There are three other panes that provide useful functionality. If one chooses the bottom option from the Layout menu, all these panels will appear:

  • To the left of the main panel will appear a tree hierarchy of the document that is useful for navigating from one section to another or for highlighting whole sections of the document.
  • In the top right corner, a panel will appear that shows all the available attributes and their values for the element in which the cursor is placed. The attribute values for any element can be set by placing the cursor within that element (but not within any of its children elements) or highlighting the whole element and entering the value in the value column next to the attributes name.
  • Below the attributes panel, in the lower right, is an element entry panel. This panel shows the user which elements are available for insertion at the cursor, depending on the mode. "In" means within the selected element. "Before" means before the selected element. "After" means after the selected element. "Replace" means to replace the selected element, keeping its contents intact. "Convert" is not used. The "Positions" pane in the panel refers to where the element to be inserted is to be placed in relation to the selected element. The "Elements" pane lists the available elements that can be inserted given the other specifications and still maintain the validity of the document.

CSS Stylesheets

Morphon uses CSS stylesheets to give a WYSIWYG display of an XML document. It also provides a means to modify the stylesheets in order to create a customized view. Stylesheets are assigned to each XML document through an embedded processing instruction that is ignored by XSLT transformers and other XML-processing software. If one is conversant with the CSS language, one can modify the stylesheet by going to the "Tools" menu and choosing "Edit CSS…". (5) The use of the resultant window will not be described here. (To learn more about CSS see the W3Schools CSS Tutorial.) The C:xmlcss provided with the setup .zip for Morhpon contains two CSS style sheets that allow different views of the document. These are:

  1. essay.css: – this stylesheet shows the marked up text, but does not show the metadata.
  2. tei_head.css: – this stylesheet shows only the metadata but not the text itself.

The xml declaration associates the first stylesheet automatically with the text but to view the metadata, one must do the following:

  1. Under the Tools menu choose “Change CSS”
  2. Click the “Browse” button.
  3. Locate the “C:xmlcsstei_head.css” file. Click “Open”
  4. Then it should appear on the right, highlighted.
  5. Click the “Load” button.

The same principle applies for reverting to the regular styles but instead choosing the “essay.css”. If an editor finds an error or a deficiency in one of these stylesheets, please contact us as thdltools@virginia.edu.

Editing with Morphon

For the most part, editing an XML document in Morphon is intuitive and follows the de facto standards for most text editors. For example, Ctrl ← or Ctrl → move the cursor one word back and one word forward respectively. On the other hand, commands such as Ctrl B for bold or Ctrl I for italics do not work in Morphon because such rendering is effected through markup. The most useful hidden feature of Morphon's editing capacity is the "right-click" drop down menu. By clicking the right mouse button at the point of insertion, a menu appears that has the following options: (6)

  • Cut: For cutting text or elements
  • Copy: For copying text or elements
  • Paste Text: For pasting text only. If an element has been copied, it will paste in a text version of that element with the opening and closing angle brackets converted to text, such as <hi rend="weak">…</hi>.
  • Paste After: This is for pasting in whole elements along with their content. It will insert them after the selected element upon which one right-clicked. This option is only available when it is valid according to the DTD.
  • Paste In: This is for pasting in whole elements along with their content. It will insert them within the selected element upon which one right-clicked. This option is only available when it is valid according to the DTD.
  • Paste After (Structure only): This is for pasting in whole elements without their textual content but only the empty tags. Attribute values are also deleted. It will insert the structure after the selected element upon which one right-clicked. This option is only available when it is valid according to the DTD.
  • Paste In (Structure only): This is for pasting in whole elements without their textual content but only the empty tags. Attribute values are also deleted. It will insert the structure within the selected element upon which one right-clicked. This option is only available when it is valid according to the DTD.
  • Delete: This will delete the element or text node and its content.
  • Flatten: When the cursor is placed within an element that contains both text and other elements, this option will "flatten" that element's content by removing all the mark-up within that element, leaving solely plain text.
  • Split: This option provides a series of choices in the form of a secondary menu. The options are "1 level up", "2 levels up", "3 levels up", etc. They are only active when available. If an element is highlighted and "Split > 1 level up" is chosen, that element is split off from its siblings into a new copy of its parent element. For instance, if this is done with the last item of a list, that item is split off into a new list element that contains only that item and the previous list no longer contains that item. "2 levels up" does the same thing but with the element's grandparent, two levels up in the hierarchy, and so forth. If the cursor is placed within some text and one chooses "Split > 2 levels up", it will divide the text's parent element in half at the cursor so that everything following the cursor is in the new version of the parent element.
  • Comment: This is only active when a whole element is highlighted. It will place the whole element within a comment, thus effectively removing it from the document without deleting it.
  • Add Empty Copy of Current Element: This does just what it says.
  • Show Attributes Window: Displays a free floating version of the attribute panel described above.

Morphon is by far the best free XML editor in terms of ease of use. It does, however, have some problems. As with most freely available software, the documentation is not comprehensive. In such cases, it is often best to learn through experience. In the case of the THDL, such experiences can be shared among the users to create a knowledge base that can serve in lieu of good documentation. The following list contains some tips and pitfalls we have discovered in our brief experience with Morphon's XML editor. It will continue to be expanded as we gain more experience with the product through its use:

  • The search and replace function is helpful. It has four modes you can search on: Text (for element content), Attribute Value (for the content or value of an attribute), Attribute Name (the name of an attribute, not very useful), and Element name (the name of an element, useful only when that element is relatively unique within the document). Only the text mode is available when in Source View.
  • Sometimes when entering text in a <note> element, the text will get "scrunched" up and some of it will disappear. In such cases, go to Tool > Edit CSS. In the resultant window, click on the blue cartoon letter A. This reapplies the CSS style to the document and usually fixes this kind of problem.
  • If you have a series of <p> elements that you want to turn into a list. Go to Source View. Place the cursor just before the string of <p> elements. Search & Replace on "p>" replacing it with "item>". (This gets both the opening and closing tags.) Press Replace Next until you reach the end of the series of <p> elements. Finally, enclose all the <item>…</item> elements within a <list>…</list> element.
  • To select multiple elements with the mouse, hold the shift button down before using the mouse. The mouse will then trace out a box and anything within the box will be selected.
  • To select multiple elements, select one element and press Alt-Shift ↑ to select the next element above it as well or press Alt-Shift ↓ to select the element below.
  • With certain elements, such as <item>, pressing "Enter" will split the element at the cursor or create a new one after it if the cursor is at the end of the element.

Rating

Morphon is presently the XML editor preferred by THDL and for which the most has been done to provide support in terms of creating and editing XML documents for our various projects. It receives this high recommendation because (1) it is freeware and (2) it is the easiest to use. It does have some drawbacks, however. Most notably, the entering of necessary diacritic characters is difficult and, being a Java-based application, the Windows 2000 keyboard created by THDL for entering diacritics does not work. Morphon does have a robust scripting and plug-in API that should make it possible to mimic the functionality of that keyboard within Morphon. However, the necessary time and skill to make this happen has not yet coalesced.

Pros

  1. Freeware
  2. Easiest to Use
  3. Best WYSIWYG - allows for multiple views that are easily interchangeable
  4. Robust scripting and plug-in API

Cons

  1. Diacritics not easily inserted
  2. Sometimes slow to respond

Provided for unrestricted use by the external link: Tibetan and Himalayan Digital Library