Chapter 3: Making XML Work
Below is a screen shot of the application in its full glory.
Notice that for the most part, this is a text editor specialized for XML.
- The majority of this application is Text, XML Text. Notice that multiple documents are opened via new tabs above the Text.
- The menu buttons, all "features" of xmlHack are optional via mouse clicks (except the highlighting), so no time is lost in loading different bloating features. If you need a feature, it comes into play later.
- The Message window, used for different special features such as XML Validation.
XML Text Editor at Heart
As can be seen from the screenshot above, xmlHack is nothing more than a
glorified text editor. It's power is first and foremost in it's ability
to quickly load text and give the XML Developer easy means of viewing and
editing that text. Following the great tradition of Borland editors,
xmlHack's editor has some wonderful behavior that is lacking in other
development environments:
- Home key actually takes you to the beginning of the Line instead of the first word of that line.
- Ctrl+Up and Ctrl+Down scroll the edit window up and down (rather than jumping somewhere).
- SmartTabs and TabsAsSpaces options exists.
- The Caret can go past the end of the line (i.e. anywhere on the edit screen)
- Undo that is rather large (and can undo past a Save).
- Margin and Gutter features.
- Auto Indent on hitting Enter.
- Standard Info in the StatusBar (i.e. Text Position, Insert vs. Overwrite, CAPS, etc).
- User defined Font to use for the editor (defaults to a fixed-width font).
Features that don't Bloat
The glorification of xmlHack comes with the features that are
XML specific. All of these features are meant to be 'afterthoughts',
things that some XML Developers would like to have happen to
their documents at some time or another, but not necessarily
all developers all the time. As such, the main goal with these
features is to stay out of the developer's way but be there when needed.
All of these features are optional, they can be enabled or disabled
to the preference of the XML Developer.
Syntax Highlighting
One of the first features that is important to an XML text editor
is the ability to highlight the syntax of XML code. xmlHack does
this and even gives the ability to have this highlighting customizable.
Don't like the default colors for comments, change it. Want to
see less bold, no problem.
As always with xmlHack, a fully customizable feature.
Tag Completion
Another great convenience that a good XML editor offers is the
ability to complete the tag as the user types them in. xmlHack
will not only complete your tag, but also has the ability to but
the tag on a new line, as show in the screen shot here.
Please note that again, this feature is completely definable by
the user. If you don't want the Tag Completion to enter a new
line, then uncheck the option in the Options window. If you don't
want Tag Completion at all, uncheck another checkbox in the Options window.
Tag Insight
Tag Insight is the ability that as the user types in elements or
'tags', the application can suggest a tag to use and if selected
then complete the tag for them. In the XML world, this list of
tags should be Namespace-Aware, meaning that the available elements
that are suggested should be prefixed with the Namespace alias and
should only suggest elements for Namespaces that are used within
the current XML Document.
xmlHack does just this. When a document is loaded xmlHack examines
all occurrences of xmlns, the XML reserved word for namespaces.
Finding any an all xmlns sections, it then parses out the alias
(if any) and the namespace.
With these values, it looks up the list built into the application
found on the Options window (shown here) for any matching Namespaces
(not aliases). For all Namespaces that match the ones within the
document, the list of Elements for that Namespace are then prepended
with the namespace alias (if any) and then added to the Tag Insight
list for that document.
Notice that you can have one list applicable to varying Namespaces
(as shown above, the XSL list will apply to both XSL 1.0 and XSL 1.1),
and xmlHack will figure out which one it needs.
With this newly created Namespace list in hand, whenever either a open
tag character is entered (the < character) or if Ctrl+Space is pressed,
then after an optional amount of time (default to 1 second) a dropdown
list of available elements appears, as shown here. This dropdown list
locates to the element as typed, and hitting Enter will complete the
typing to what is listed in the dropdown.
In our example shown here, xsl:element is what's being selected for an XSL document.
Note as well, that note only is this feature enabled by the user
(i.e. can be turned off if found annoying), but the list of elements
and namespaces is completely configurable as well.
Code Completion
Code Completion is another wonderful feature found in many development
editors that has a nice fit in the XML world. The idea is that a
pre-defined list of Code Templates exists and are associated with a
Key word. When this Key Word is entered in the editor, and a HotKey
is pressed, the Key Word is replaced by the Code Template. If a Pipe
character is found within this template, then that character is removed
and the cursor is placed at its location.
In the example shown here, the list of Code Completions is shown, with
the Code Template below. The "Name" field is the Key Word and xslchoose
is currently selected to show it's code. Whenever xslchoose is entered
in the text editor and Ctrl+Shift+J is pressed, that word will be replaced
by the code found here.
And again, this feature is fully customizable. If you find you are typing
the same pieces of data over and over, enter that as a Code Completion and
ease your life immensely.
Following the example shown in the Options window above, the Editor shown
here has the before and after shots of what happens when xslchoose is typed
in and then Ctrl+Shift+J is pressed.
"Pretty" Formatting
Formatting the XML is also a very nice feature, one of which xmlHack
will gladly do when called upon, however it does not do it by default
(unlike some editors who insist on messing with your text). This
formatting also has a plethora of options, trying its best to put some
sense behind the formatting.
Once again, this is a optional feature that doesn't "get in your way",
that is, unless you want it to.
Validations
What sort of an XML editor would xmlHack be if it couldn't properly
validate your XML documents, and tell you where any problems existed.
Validation is built into the editor, and the Message window indicates
which line/nodes have the problem. Dbl-clicking on the Message window
will also synch the text to the problem.
And following the xmlHack methodology, this feature is enabled by clicking
on the Validate button, so only happens when and if you want it to.
Previews
XML Developers often get used to viewing their applications in various
programs, though not necessarily developing their applications in said
environments, so xmlHack offers a great way of allowing the current
document to be 'previewed' by any external source. A list exists in the
Options window that users can enter any program they want, then OnClick
of the Preview button and after selection of which application to preview
the XML document with, this application is shelled out with the File as
the CommandLine parameter. Thus, xmlHack not only allows a handy way of
previewing, but also a completely flexible and configurable way as well.
New Document Templates
Often times when new XML files are created, there are specific document
element information that is needed. For example, Stylesheets need to have
the XSL Namespace declared, as more often than not various other basic XSL
tags, such as Output and Template for default.
xmlHack offers the ability to define any number of 'New' templates, that
when creating a new file, the developer can select one of these templates
to pull in to start the file with. This is very convenient when one has
to remember how XML Schemas need to be declared, or how the Namespace of
Stylesheets that use Microsoft Extensions should be written.
And, as usual, this list is completely configurable by the end developer.
Add and remove any template you see fit.
|