I am very new to XSLT..
I am trying to have identity-copy of my html, and change a few things, but the result gives me extra <html><body></body></html>
after my </html>

here's my xsl:

<xsl:stylesheet version='1.0' 

 <xsl:template match='node()|@*' >
		<xsl:apply-templates select='node()|@*' />

<xsl:template match='h2'>
	 <font color='red'><xsl:value-of select='.'/></font>

<xsl:template match="div[@class]">
		<xsl:copy-of select='@*'/>
		<xsl:apply-templates select="div/@id">

<xsl:template match="div/@id">
	<xsl:copy-of select='..'/>


how can I not have the extra nodes?
appreciate any helps..

TQ in advance! :-)

Put ur XML data here which u r using as a input.

Put ur XML data here which u r using as a input.

Hi Varun,
here's my data in php file - i'm new to PHP too :(

 echo 'test ' . $_SESSION['mytest'];
 echo <<<tst
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"

<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
   <meta http-equiv="content-type" content="text/html;        charset=utf-8" />
		<link rel="stylesheet" type="text/css" href="test.css" /> 
		<!-- <link rel="stylesheet" type="text/css" href="css/frmt.css"/> -->
		<!--script language="Javascript" type="text/javascript" src="a.js" /-->
		<div class="cnt">
			<div class="s1" id='m3'>m1</div>
			<div class="s2" id='m2'>m2</div>
			<div class="s3" id='m1'>m3</div>
		       <div class="s4" id="m4"><h2>test..</h2></div>
			<div class="s5" id="m5"><h2>another test</h2>
				<img src="test.jpg" alt="test" />

and I use this to transform:

$pg = new DOMDocument();
	$xsl = new DOMDocument();
	$proc = new XSLTProcessor();

	echo $proc->transformToXml($pg);

thanks again!


xslt is not giving any extra tag. may be ur php code is doing something wrong. i dont know about php bur there is no problem in ur xslt which u have given.

TQ.. yup, you're right.. it's my php code that gave the prob..

(sorry for the late reply.. been away..)

Thanks again!