Creating a Simple HTML Page
It is traditional in many introductory programming texts to create a program that provides a “Hello World!” greeting.
Listing 10.1 shows a very short XML document that stores the message.
Listing 10.1. XSLTMessage.xml: A Simple Message in XML
<?xml version='1.0'?> <XSLTMessage> Hello World! </XSLTMessage> |
You can use the XSLT stylesheet shown in Listing 10.2 to create an HTML Web page that extracts the message from Listing 10.1 and places it in the HTML page.
Listing 10.2. XSLTMessage.xsl: A Stylesheet to Extract the Message from Listing 10.1
<?xml version='1.0'?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0" > <xsl:template match="/"> <html> <head> <title><xsl:value-of select="name(/XSLTMessage)" ... |
Get Sams Teach Yourself XML in 10 Minutes now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.