xml spy
Previous  Top  Next
Transforming XML to HTML

To assign an XSL file to the CompanyLast XML file:
1.Click the CompanyLast.xml tab on the main window, to make it the active document.  
2.Select the menu option XSL | Assign XSL.  
3.Click the Browse button, select the Company.xsl file, and confirm with Open.  

tut_57a  

4.Click the OK button to assign the XSL file to the XML document.  

tut_57b  

A XML-stylesheet reference is placed in the XML document.  
 
To transform the XML document into HTML:
1.Select the menu option XSL | XSL Transformation or click the ic_xsl_transf icon (Hotkey: F10)  
This creates a new document in the Browser view with the name XSL Output.html. It shows the Company data in one block down the left, and the Person data in tabular form below.  

tut_58a  

Changing the output of the HTML file:
You can change the appearance/output of the HTML file by editing the underlying XSL file. In this case, we want to change the table background color from lime to yellow.

1.Click the CompanyLast.xml tab to make it the active document.  
2.Select the menu option XSL | Go to XSL.  

tut_58b  

The command opens the Company.XSL file referenced in the XML document.  
3.Find the line <table border="1" bgcolor="lime">, and change the entry bgcolor="lime" to bgcolor="yellow".  

tut_59a  

4.Select the menu option File | Save to retain the changes made to the XSL file.  
5.Click the CompanyLast.xml tab to make the XML file active, and select XSL | XSL Transformation, or hit the F10 key.  

tut_59b  

A new XSL Output.html file appears in the Browser view. The table background now appears in yellow.  
6.Select the menu option File | Save, and save the document as Company.html.  

XML Spy Suite and XSLT Designer
The XML Spy product family includes XSLT Designer which automates the generation of XSLT stylesheets for XML to HTML transformation. Please see the XSLT Designer documentation for more information on XSLT Designer. The documentation also includes a tutorial on how to generate a XSLT stylesheet.


Previous  Top  Next

© 2002 Altova