How to Use ItRunning XMLtype Basic Editing Commands Advanced Commands
Running XMLtype
To edit a file, simply invoke
xmltype foo.xml
Note that only single file might be edited at once.
If the file doesn't exist, XMLtype creates it and put a XML header (based on XML_HEADER variable in the config) in prolog.
For convenient creating new files, XMLtype introduces two options to specify DTD file and root tag. So launching
xmltype midnight_children.xml --dtd /dtd/book.dtd --root document
will produce following content (provided that the file midnight_children.xml doesn't exist):
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE document SYSTEM "/dtd/book.dtd">
<document></document>
You can use also shortened form of the parameters:
xmltype midnight_children.xml -d /dtd/book.dtd -r document
You can also omit --root option. XMLtype will then try to estimate which element is likely to be root by searching DTD. If single element not mentioned in the contentent declaration of any other element is found, it is considered root. Otherwise, similar code will be produced:
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE {root-tag} SYSTEM "/dtd/book.dtd">
You can disable this feature in config file (see AUTO_GUESS_ROOT ). Command-line flag --guess overrides the setting and forces XMLtype to process the estimation.
Note that --dtd option can be also used to override the DTD system name of an existing document used by parser. If you open file with, for instance,
<!DOCTYPE document SYSTEM "/dtd/book.dtd">
in prolog, but set --dtd /dtd/diary.dtd in command line, all parser-related features (word completing) will use the latter DTD.
Basic Editing Commands
CTRL+Q | Exit xmltype. |
CTRL+C | -"- |
CTRL+S | Save current document. |
Insert | Insert tag brackets. <> |
F9 | Turn syntax highlight on/off. |
F10 | Display/hide tabs and newlines. |
F1-F6 | Switch to keymap 1 to 6. |
CTRL+U | Undo last operation. |
CTRL+B | Redo. |
Advanced Commands
XMLtype includes some commands which make typing of XML documents more comfortable.
DTD-based word-completing
On startup, XMLtypes looks for DTD name related to the document, specified either in the prolog of existing document at hand, or through --dtd option. You can then apply word-completing (similar to Bash filename completing) on the names of entities, tags, attributes and even enumerated attribute values by pressing Tab key. While completing, XMLtype takes in account current context, whether the attribute is declared as #REQUIRED or #FIXED , etc. In case of multiple possibilities, you can see all the choices on the bottom bar.
Note, that XMLtype is unable to process directly entities expanding. If you replace some part of markup by an entity, it is ignored by word-completing mechanism. For simple workaround, see config doc.
Contextual blocks
Contextual blocks are portions of the text which have specific meaning in XMLs (e.g. element bodies, attributes, entities). Pressing ENTER inside such a block places the cursor behind it. This enables you to move easily through the markup. In plain text, the key behaves normally putting newline into the text.
You can also delete current contextual block (including plain text) by pressing CTRL-D. Note, that until introducing undo feature, this is somewhat dangerous.
Closing tags
You can close the previously open tag by pressing Insert inside the tag. So, if the last open tag is, for instance, <book> , pressing Insert twice will put </book> inside the text. The command will replace previous tag content, if any.
Commenting tools
Writing the remarks in XMLs by typing <!-- --> is often annoying. In XMLtype, just hit CTRL-R inside the tag. The command will replace previous tag content, if any.
Press CTRL-R in plain text contextual block, if you want to comment it out. Another pressing the key will extend current comment to the whole paragraph. Press CTRL-R again to uncomment the paragraph.
|