Code and problem are from PHP5:
When I execute the following piece of code, the DomException is thrown with
a message: Not Found Exception.
I assume this means that the node I extracted from the DomDocument using
getElementsByTagName() isn't found when I use insertBefore(). I blame the
namespace :-)
When I replace the getElementsByTagName( 'xsl:template' ), I get the "no
template tag found message" in the else.
What is the NS-safe way to insert a xsl:param tag before the xsl:template
tags?
<?php
$xsl = <<<XSL
<?xml version="1.0" ?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:import href="xhtml/basic.xhtml.xsl" />
<xsl:import href="xhtml/search.xhtml.xsl" />
<xsl:import href="xhtml/news.xhtml.xsl" />
<xsl:output
method="xml"
omit-xml-declaration="no"
doctype-public="-//W3C//DTD XHTML 1.0 Strict//EN"
indent="yes"
media-type="text/html"
/>
<xsl:param name="updatetime" />
<xsl:template match="/">
<xsl:apply-imports />
</xsl:template>
</xsl:stylesheet>
XSL;
$stylesheet = DomDocument::loadXML( $xsl );
$temp_list = $stylesheet->getElementsByTagName( 'template' );
if( $temp_list && $temp_list->item(0) ) {
$template = $temp_list->item(0);
$param = $stylesheet->createElement( 'xsl:param' );
try {
$stylesheet->insertBefore( $param, $template );
} catch( DomException $e ) {
print "Exception ".$e->getMessage();
print "\n";
print $template->tagName;
}
}
else {
die( "No template tag found" );
}
?>
Thanks in advance.
Rutger Claes
--
Rutger Claes rg*@rgc.tld
Replace tld with top level domain of belgium to contact me pgp:0x3B7D6BD6
Overflow on /dev/null, please empty the bit bucket.