simple identity transform - what am I missing?
Posted: Fri Feb 13, 2009 7:36 am
I must be missing something simple. Using this input:
and this stylesheet:
I am not seeing what I expect, which is that the div gets a description added before it. Am I missing something? Seems like the second template never matches.
Code: Select all
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Simple</title>
<link rel="stylesheet" type="text/css" media="screen,print" href="style.css" />
</head>
<body>
<div style="text-align: center; ">
<p>
<a href="Next.html">
Next >
</a>
</p>
</div>
</body>
</html>
Code: Select all
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:preserve-space elements="*"/>
<xsl:output omit-xml-declaration="no" encoding="UTF-8"
doctype-public="http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"/>
<xsl:template match="@*|node()">
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:template>
<xsl:template match="div">
<description>n/a</description>
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>