XML - Managing Data Exchange/Exchanger XML Lite

Exchanger XML Lite
Cladonia offers an xml editor at http://www.exchangerxml.com/ for free noncommercial use, and can be downloaded without registration.

This is a Java-based product that runs on all platforms including Windows, Linux, Mac OSX and UNIX.

(NOTE: If you need an XML editor for commercial use, you can get a free 30-day trial of Exchanger XML Professional at http://www.exchangerxml.com)

Single Entity in Exchanger XML Lite
The following directions will lead you step-by-step through doing the same project that is found in the ../A single entity chapter.

Part One: Creating the Project Folder
1) Open Exchanger XML Lite

2) Click on:      -Project       -New Project : a "New Project" folder will appear                  in the project folder window 3) Type "TourGuide" over the "New Project" title to change the name of the new project to TourGuide.



Part Two: Creating the Schema File
1) Click on:      -File       -New        -For Type        -Scroll to "XML Schema Definition" and highlight it        -OK 2)Exchanger automatically puts the beginning and ending tags in the file for you, however, for our example, delete those automatic tags, and copy and paste the following code into the file:

                <xsd:element name="elevation" type="xsd:integer"/> <xsd:element name="longitude" type="xsd:decimal"/> <xsd:element name="latitude" type="xsd:decimal"/> <xsd:element name="description" type="xsd:string"/> <xsd:element name="history" type="xsd:string"/> </xsd:sequence> </xsd:complexType> </xsd:schema>

3) Click on the GREEN CHECK to Validate, and the BROWN CHECK to check for Well-Formedness. These can be found on the toolbar:

(NOTE: Be sure to eliminate any "white space" before the text that you paste, or you may have an error when validating.)

4)Click on:  -File   -Save    -"city.xsd" 5)Right Click on: -"TourGuide" project folder -Add File -click on "city.xsd" -open (Note: Now the project "TourGuide" should contain one file,    "city.xsd".)

Part Three: Creating the Style Sheet
1)Click on:  -File   -New    -For Type    -Scroll to "XML StyleSheet Language" and highlight it     -OK 2)Delete any automatic tags that appear, and cut and paste the following code into the file: <?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output method="html"/> <xsl:template match="/"> Tour Guide Cities <xsl:apply-templates select="tourGuide"/> </xsl:template> <xsl:template match="tourGuide"> <xsl:for-each select="city"> <xsl:text>City: </xsl:text> <xsl:value-of select="cityName"/> <xsl:text>Population: </xsl:text> <xsl:value-of select="population"/> <xsl:text>Country: </xsl:text> <xsl:value-of select="country"/> </xsl:for-each> </xsl:template> </xsl:stylesheet>

3) Click on the GREEN CHECK to Validate, and the BROWN CHECK to check for Well-Formedness. (NOTE: Be sure to eliminate any "white space" before the text that you paste, or you may have an error when validating.)

4)Click on:  -File    -Save As    -"city.xsl" 5)Right Click on: -"TourGuide" project folder -Add File -"city.xsl" -open

(Note: Now the project "TourGuide" contains two files,    "city.xsd", and "city.xsl".)



Part Four: Creating the XML File
1) Click on: -File   -New   -Default XML Document    -OK 2) Delete any automatic tags that appear and copy and paste the following code: <?xml version="1.0" encoding="UTF-8"?> <?xml-stylesheet href="city.xsl" type="text/xsl"?>

<tourGuide> xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xsi:noNamespaceSchemaLocation='city.xsd'> <cityName>Belmopan</cityName> <adminUnit>Cayo</adminUnit> Belize 11100    5     130     88.44     17.27     Belmopan is the capital of Belize Belmopan was established following the devastation of the former capitol, Belize City, by Hurricane Hattie in 1965. High ground and open space influenced the choice and ground-breaking began in 1966. By 1970 most government offices and operations had already moved to the new location. <cityName>Kuala Lumpur</cityName> <adminUnit>Selangor</adminUnit> Malaysia 1448600    243     111     101.71     3.16     Kuala Lumpur is the capital of Malaysia and the largest city in the nation The city was founded in 1857 by Chinese tin miners and perseded Klang. In 1880 the British government transferred their headquarters from Klang to Kuala Lumpur, and in 1896 it became the capital of Malaysia. </tourGuide>

3) Click on the GREEN CHECK to Validate, and the BROWN CHECK to check for Well-Formedness. (NOTE: Be sure to eliminate any "white space" before the text that you paste, or you may have an error when validating.) (Also NOTE: You may need to select -Schema -Infer XML Schema -then choose city.xsd in order to validate the xml file.)

4)Click on: -File  -Save As   -city.xml 5) Right click on: -TourGuide -Add File -"city.xml" -open (Note: Now project "TourGuide" should contain three files, "city.xsd","city.xsl", and "city.xml".)

Part Five: Executing your code
1) Open the city.xml file.

2) Click on: -Transform  -Execute Simple XSLT   -Current Document   -OK

-XSL input -From URl -pick city.xsl -open -OK

-Use Default Processor -OK Note: the window should say "Transformation Complete"

Now you may close this window and follow step 3 to get the results.

3)Click on: -Tools  -Start Browser Note: Results should look like this: