Home > Online Product Documentation > Table of Contents > Stylesheets That Generate HTML - Getting Started
You can use the WYSIWYG tab of the XSLT Editor to create stylesheets that generate HTML. Stylus Studio automatically generates the XSLT instructions that output the HTML you define on the WYSIWYG tab.
This section helps you get started working with stylesheets that generate HTML. To get started with the features common to all stylesheets, see Working with Stylesheets - Getting Started. To focus on stylesheets that map XML to XML, see Using the XSLT Mapper - Getting Started.
This section is organized as follows:
To get started, you'll need to start Stylus Studio if you haven't already. See Starting Stylus Studio.
Stylus Studio provides several video demonstrations that show you how to use the XSLT WYSIWYG editor. You can watch these videos instead of (or in addition to) performing the tutorial procedures in this section.
Video demonstrations for using the XSLT WYSIWYG editor include the following:
xsl:apply-templates instruction with the XSLT WYSIWYG editor, how to create new templates, how to edit templates, how to reuse them.
The videos are available here: http://www.StylusStudio.com/xml_videos.html
The system on which you play Stylus Studio video demonstrations must meet the following requirements:
In addition, for best results set your Media Player options as follows:
This section provides instructions for getting started with the XSLT WYSIWYG editor. It introduces the basic WYSIWYG editor features, and provides background information needed to edit simple stylesheets.
You should perform the steps in each topic before you move on to the next topic. After the first topic, some steps in subsequent topics depend on actions you performed in a previous topic.
This section is organized as follows:
examples\query\books.xml in the Stylus Studio installation directory, and click
Open.
Stylus Studio displays the XSLT Editor open to the
WYSIWYG tab. The HTML canvas, the center pane on the
WYSIWYG tab, is empty. A tree that represents the XML source document,
books.xml, appears to the right of the HTML canvas. The
Properties window is displayed by default.
<xsl:output method="html"/>).
My Favorite Books.
The Save As dialog box appears.
myBooks.xsl in the
URL field and click the
Save button.
|
Tip
|
|
Resize the Preview window by dragging the splitter that separates the Preview window from the XSLT Editor. |
This topic is part of a sequence that starts with Creating Static HTML.
books and press the asterisk key (*) in the numeric keypad to expand all the elements.
This is a list of :.
name attribute to just before the colon (
:). Stylus Studio displays a pop-up menu.
/books/@name.
Stylus Studio displays the instruction that generates the contents for the placeholder.
In this example, it is
xsl:value-of. Stylus Studio also displays the context for the placeholder. In this example, the context is
books/@name.
This topic is part of a sequence that starts with Creating Static HTML.
book and
author.
book element from the XML source tree and drop it onto the HTML canvas.
Stylus Studio displays the pop-up menu with an additional option, Add Table.
Stylus Studio inserts a two-column table with a marker to the left of the table. This marker indicates a looping element.
books/book.
title element from the XML source tree and drop it into the first column of the table in the HTML canvas.
Stylus Studio displays a pop-up menu.
Stylus Studio displays the «title» placeholder in the first column. When you apply the stylesheet, the title of each book will appear in a row of the first column of the table.
author element from the XML source tree and drop it into the second column of the table in the HTML canvas.
Stylus Studio displays the pop-up menu.
Stylus Studio displays a subtable in the second column of the table.
author element from the XML source tree and drop it into the subtable again.
xsl:value-of.
Stylus Studio displays the «author» placeholder in the second column.
books.xml.
This topic is part of a sequence that starts with Creating Static HTML.
xsl:value-of instruction.
Starting with the
xsl:value-of element itself, these are the elements that enclose the
xsl:value-of element in the XSLT, from the innermost to the outermost. You can specify properties for any of these elements, and what you specify can affect the display represented by the placeholder you clicked.
td element to specify properties for the table data. (If you click the first
td element, you specify properties for the subtable that is in the second column of the main table.)
Stylus Studio displays only the properties that can be specified for the element you clicked. For the
td element, there are many such properties, or attributes, and you can click the tabs at the bottom of the
Properties window to view a particular subset (
Color,
Layout,
Position, and so on).
The result document now displays the table rows with the background color you selected.
Stylus Studio has inserted the XSLT instructions that display the table in the color you specified.
In Making a Static Web Page Dynamic by Editing XSLT, you learned how to use the XSLT Editor's XSLT Source tab to build a Web page that displays dynamic content.
This section provides step-by-step instructions for using the Stylus Studio XSLT WYSIWYG editor to convert a static Web page that displays information about one video into a dynamic Web page that displays information about many videos.
Before starting this part of the tutorial, you must import an HTML file as described in Importing a Sample HTML File, with the following changes:
When you are done, your copy of Stylus Studio should look something like this:
After you perform step 11 in that topic, return here, and start with Making Repeating Table Rows in the WYSIWYG Editor.
This topic is part of a sequence that starts with Importing a Sample HTML File.
In the Preview window, you can see that the information for one video appears in a row of a table. You want to make this a repeating row and have each row contain information for a different video.
video repeating element to the
Title table cell, which contains
Enemy of the State.
Stylus Studio displays a looping marker to the left of the table row to indicate that it is a repeating row. If you move the cursor over the marker, Stylus Studio displays the information that the marker represents an
xsl:for-each instruction that executes in the context of
/result/videos/video.
Now that the XSLT describes a table with repeating rows, our next task is to make each of the rows' columns dynamic, that is, to ensure that each row displays information for a different movie.
This topic is part of a sequence that starts with Importing a Sample HTML File.
Stylus Studio removes the text for Enemy of the State and replaces it with the <<title>> placeholder.
Stylus Studio displays the information that the marker represents an
xsl:value-of instruction and that it executes in the context of
/result/videos/video/title.
The result document now displays a different video title in each row. If you want, you can select the title placeholder, apply some formatting and preview the results. Every title in the result document will have the formatting you specified.
This topic is part of a sequence that starts with Importing a Sample HTML File.
The image for each movie is still the same. For this part of the XSLT, you will use the XSLT Source tab:
Stylus Studio displays the XSLT Source tab, and flags the line that contains the instruction. As you can see, the stylesheet uses an image ID.
"images/video/id1244100.gif", select
id1244100.
{@id} to replace the selected text. This specifies an attribute value template.
Each row now contains the correct image for the video described in that row.
As you can see, there is now a placeholder where the original image was.
In the Properties window, Stylus Studio displays the properties for the image. If you scroll down to the src property, you can see that the value is images/video/{@id}.gif.
Stylus Studio backmaps to
<xsl:value-of select="vhs"/> in the
XSLT Source tab.
"vhs" with
"format-number(vhs, '##.00')". This ensures that every VHS price is formatted with two decimal places.
select= "dvd" with
select="format-number(dvd, '##.00')".
This topic is part of a sequence that starts with Importing a Sample HTML File.
In the current videos result document, there are small circles when no VHS tapes or DVDs are available.
These circles appear when the XSLT processor tries to process an empty string with
select=format-number.
vhs in the
Test Condition field. This tests whether there are any
vhs elements.
dvd as the test condition.