XML mode for Alpha.
Name:Xml Mode
Version:1.1
Last update:2019-11-27 14:13:03





Introduction

The XML mode provides basic editing capacities for XML files, keyword coloring and completion, where keywords are automatically parsed from your xml files.
The XML menu provides commands to check the well-formedness of a document, to validate against the three usual schemas (DTD, Relax NG and Schema), to apply XSL transformations, etc.
The Xml mode in Alpha is automatically loaded when a file with a .xml or .plist extension is opened. Have a look at the mode specific preferences: when a .xml file is opened, choose Alpha ↣ Preferences ↣ Xml Mode Setup.
Click on one of the following links to see sample syntax:

XML menu

When a document is in XML mode, a menu named XML is inserted in the menu bar. The following sections describe the menu items.

New Document submenu

This submenu lets you create a new XML document. The menu items Xml…, Xslt…, or Dtd… specify the kind of document to create. Alpha prompts you for a name and then creates a new window containing a minimal template for this kind of document.

Editing submenu

Balance Tags
Select the innermost pair of tags enclosing the current position.
Escape Entities
Replace, in the current selection, the basic symbols (ampersand, lower, greater, apostroph, double quote) by the corresponding XML entity.
Unescape Entities
Replace, in the current selection, the basic XML entities by the corresponding symbol.
Pretty Print Document
Reformat and reindent the entire document. This feature relies on an external tool such as xmllint which must be present on your machine. The first time you invoke this command, you are asked to localize the command line tool.
Canonicalize Document
Canonicalize the document, that is to say insert the canonic W3C declarations. This feature relies on an external canonicalization tool such as xmlstarlet or xmllint which must be present on your machine. The first time you invoke this command, you are asked to localize the command line tool.

Parsing submenu

All the features provided by this menu are implemented as an external service: this service relies either on the tDom or tnc extensions (which are included in Alpha), or on a command line tool such as xmlstarlet, xmllint or sablotron (which must be present on your machine). The first time you invoke any of these menu items, you are asked to localize the command line tool.
Check Well Formedness
Check that the document is well formed.
Check DTD Syntax…
Check the syntax of an external DTD.
Validate With Doctype
Validate the current document using the DTD specified in its DOCTYPE declaration.
Validate With External DTD…
Validate the current document against an external DTD.
Validate With Relax NG…
Validate the current document against a Relax format.
Validate With Schema…
Validate the current document against a Schema format.

Transforming submenu

Select Xslt File…
Select an XSL file in order to apply a transformation (performed with one of the following items). The name of the selected XSL file is displayed at the bottom of this submenu.
Apply Transformation To Window
Apply the selected XSL file to the current document.
Apply Transformation To File…
Apply the selected XSL file to a file located on disk.

Clever closing angle bracket

By default, the XML mode installs a nice editing feature, known as the electric closing angle bracket. When you finish typing an opening tag, then as soon a you type the closing angle bracket of this opening tag, a corresponding closing tag is automatically inserted with the correct indentation. Say you just typed <foobar>, then when the last > has been entered, the mode opens a new line and inserts the corresponding closing tag, that is to say </foobar> and positions the cursor between this pair of tags.
If you really mean to type a > symbol without triggering the electric behaviour, press the control key simultaneously, that is enter it a Ctrl->.
If you do not want this electric behaviour, you can disable it in the preferences: choose Alpha ↣ Preferences ↣ Xml Mode Setup and uncheck the Electric Closing Angle Bracket checkbox in the Editing panel.

Xml Mode Preferences

If the current document is in XML mode, you can display the preferences dialog with the following command: Alpha ↣ Preferences ↣ Xml Mode Setup.
The Colors panel lets you set the color of various elements.
The Editing panel contains standard editing preferences and some XML specific flags:
Check Syntax On Opening
If this checkbox is selected, the syntax of any newly opened XML file is checked. If a syntax error is found, a separate error window is opened indicating where the error was found in the document. The document itself is opened anyway.
Electric Closing Angle Bracket
This preference has been explained in the Clever closing angle bracket section.

Known problems

Please report any problem or bug you encounter to Alpha's Bug Tracker.

License and Disclaimer

Copyright (c) 2003-2019, the Alpha Community.
All rights reserved.
The Xml Mode package is free software and distributed under the terms of the new BSD license:
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE ALPHA COMMUNITY BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.