|
|
|
<card type="simple"> <name>John Doe</name> <title>CEO, Widget Inc.</title> <email>john.doe@widget.com</email> <phone>(202) 456-1414</phone> </card> |
We define an XHTML rendering semantics for our business-card markup language using an XSLT stylesheet:
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"
xmlns="http://www.w3.org/1999/xhtml">
<xsl:template match="card[@type='simple']">
<html xmlns="http://www.w3.org/1999/xhtml">
<title>business card</title><body>
<xsl:apply-templates select="name"/>
<xsl:apply-templates select="title"/>
<xsl:apply-templates select="email"/>
<xsl:apply-templates select="phone"/>
</body></html>
</xsl:template>
<xsl:template match="card/name">
<h1><xsl:value-of select="text()"/></h1>
</xsl:template>
<xsl:template match="email">
<p>email: <a href="mailto:{text()}"><tt>
<xsl:value-of select="text()"/>
</tt></a></p>
</xsl:template>
...
</xsl:stylesheet>
|
Resulting document:
<html xmlns="http://www.w3.org/1999/xhtml"><title>business card</title> <body><h1>John Doe</h1><h3><i>CEO, Widget Inc.</i></h3> <p>email: <a href="mailto:john.doe@widget.com"><tt>john.doe@widget.com</tt></a></p> <p>phone: (202) 456-1414</p> </body></html> |
A browser might show this as:
John DoeCEO, Widget Inc.email: john.doe@widget.com phone: (202) 456-1414 |