Exchanger XML Editor: Difference between revisions

The educational technology and digital learning wiki
Jump to navigation Jump to search
Line 35: Line 35:
== XSLT Transformation ==
== XSLT Transformation ==


When you develop an XSLT style sheet, it is important to verify that correct HTML (or whatever other kind of output) is being produced. To do so, you can use the built-in XSLT processor that is available through the ''Transform'' menu
When you develop an XSLT style sheet, it is important to verify that correct HTML (or whatever other kind of output) is being produced. To do so, you can use the built-in XSLT processor that is available through the ''Transform'' menu.


I suggest to use "Execute Advanced ..." since it allows to use a style-sheet processing declaration of your XML file (click on "User Processing Instruction).
'''Suggested procedure'''
 
* Open your XML file ('''not''' the xslt file as many beginners do ....)
* Then use menu '''Transform->Execute Advanced XSLT...'''
 
This procedure allows to use a style-sheet processing declaration of your XML file, e.g. something like this:
<source lang="xml">
<?xml version="1.0"?>
<!DOCTYPE recipe SYSTEM "cooking.dtd">
<?xml-stylesheet href="cooking.xsl" type="text/xsl"?>
</source>


For '''output''', either choose ''new document'' or ''file''. Choose file, if you plan to validate the output
For '''output''', either choose ''new document'' or ''file''. Choose file, if you plan to validate the output


In '''addition''' (truly important !), it seems that only the Saxon 2.0 processor is working in the V3.3.1 edition. Therefore you must define the right processor. You can do this, by clicking on the ''Processor button'' as shown in the figure below, but we rather suggest to change the global preferences in Menu ''file->Preferences; XML Tab''.
In '''addition''' (truly important !), it seems that only the '''Saxon 2.0''' processor is working in the V3.3.1 edition. Therefore you '''must''' define the right processor. You can do this, by clicking on the ''Processor button'' as shown in the figure below, but we rather suggest to change the global preferences in Menu ''file->Preferences; XML Tab''. Saxon 2.0 is probably the best XSLT processor anyhow.


[[image:xml-echanger-editor-v33-xslt-execution-settings.jpg|frame|none|XSLT Processor settings ('''important''')]]
[[image:xml-echanger-editor-v33-xslt-execution-settings.jpg|frame|none|XSLT Processor settings ('''important''')]]
Of course, in other situations you may choose other options, e.g. you don't need to open the files in the editor, they don't even need to be on your computer.


== XSLT debugging ==
== XSLT debugging ==

Revision as of 17:02, 15 November 2010

Introduction

Exchanger XML editor is an XML editor. I use it in various course settings where I either teach XML or use XML - Daniel K. Schneider 16:11, 15 November 2010 (CET).

As of November 2010, Exchanger XML editor is still the best free general purpose XML code editor. It offers schema support and includes an XSLT debugger. Other free editors may better suit precise purposes such as DocBook editing.

This editor is quite well documented (press the Help item in the menu bar). Below we just will write down a few essential tricks.

XML editing

Very important: Exchanger has a little but that requires you to define a well-formed XML file with a correct header and inserted root element. Then you must close this file and re-open it again in order to make the editor DTD aware. In other words, if you don't create this skeleton, then close and open it again, the editor will not help you with XML editing as described below.

A typical skeleton looks like this, i.e. it would include xml declaration on top, follow by a schema declaration and and inserted root element.

<?xml version="1.0"?>
<!DOCTYPE recipe SYSTEM "cooking.dtd">

<recipe>

</recipe>

To insert an element or attribute:

  • Select the Helper pane to the left by clicking on (*>) . Then (in the editing window) click on the element tag you wish to edit or put your cursor in a location between child element. The helper pane will then display available elements on which you can click to insert.
  • Or, in the contents window press press Ctrl-T to insert an element.
  • Or, pressing "<" in the editing window gives more options and you can do it in any place.

To insert an attribute, position the cursor after the element name and press the space bar

To display the order of elements (works only with DTD's but not with XSD's) in the top pane to the left. Select Menu->XML->Set Document properties. Untick "Location defined in document", then Tick "Use for Tag completion". I feel that this is an important feature. Too bad that it's sort of hidden away.

Soft wrapping (important for text-centric XML)

  • Menu (View -> Editor Properties)

XSLT Transformation

When you develop an XSLT style sheet, it is important to verify that correct HTML (or whatever other kind of output) is being produced. To do so, you can use the built-in XSLT processor that is available through the Transform menu.

Suggested procedure

  • Open your XML file (not the xslt file as many beginners do ....)
  • Then use menu Transform->Execute Advanced XSLT...

This procedure allows to use a style-sheet processing declaration of your XML file, e.g. something like this:

<?xml version="1.0"?>
<!DOCTYPE recipe SYSTEM "cooking.dtd">
<?xml-stylesheet href="cooking.xsl" type="text/xsl"?>

For output, either choose new document or file. Choose file, if you plan to validate the output

In addition (truly important !), it seems that only the Saxon 2.0 processor is working in the V3.3.1 edition. Therefore you must define the right processor. You can do this, by clicking on the Processor button as shown in the figure below, but we rather suggest to change the global preferences in Menu file->Preferences; XML Tab. Saxon 2.0 is probably the best XSLT processor anyhow.

XSLT Processor settings (important)

Of course, in other situations you may choose other options, e.g. you don't need to open the files in the editor, they don't even need to be on your computer.

XSLT debugging

The included XML debugger can be used at two levels

  • Beginners just can open it and have a look at the processing traces, i.e. understand what elements are dealt with by which templates and in what order. Also, the result (e.g. HTML) is displayed.
  • Advanced users can insert breakpoints (right-click next to a number) and then inspect bindings.

To launch it:

  • Menu Transform->XSLT Debugger
Screen shot of the Exchanger XSLT Debugger

Installation tips

Installation on Ubuntu 10.0 LTS

  1. Get xngr-editor.zip xngr-editor.zip a Zip file
  2. Unzip in an install directory, then run it with:
java -jar xngr-editor.jar &

Write a shell script like this (or better) for version 3.3.01 (Summer 2010)

#! /bin/bash
cd /usr/local/xngr
java -jar xngr-editor.jar &

For the older version 3.2 you had to:

#! /bin/sh
cd /usr/local/exchanger
java -jar lib/xngr-loader.jar &

Installation on Windows Vista

  • Installer did't work for me at some point (Vista professional). Maybe V 3.3. works, but I can't tell since I moved to Win 7.
  • I had to take the zip version (see above) and then write a 2-line shell script. Contents of file xngr.cmd:
rem Change to the path where you extracted the zip
cd c:\soft\xngr 
start javaw -jar lib\xngr-loader.jar


Opinions

  • Opinion of DSchneider: Editing is fairly ergonomic, DTD-based XML editing support is ok, XSD-based XML editing support could be improved (does not display information about element structure). There are many additional tools (some useless for beginners but of interest to advanced users). So this is my best choice for a free structure editor.

Only major problem: It does not propose elements in the right order (DTD rules are displayed, but XSD no). This is a problem with almost all editors I have seen. An exception that does this better is Framemaker (an expensive word processor).

  • Addition (Feb 2007). I used this editor in a 8 weeks XML beginner's class and indeed it was a good choice. I also liked the XSLT support. There is a validator and editing support for major XSL and XSD elements. Also, I found out that one can format text (Menu Edit->XML->Format). This is crucial when confronted with ugly student productions :).
  • Xchanger was again updated on June 2010 (version 3.3). Still the best overal choice for teaching introductory XML (DTD,XSLT,XSD etc.) - Daniel K. Schneider 15:10, 20 September 2010 (CEST).