C
chris
Hi,
After going back through the XSL tutorials and the help here I have
largely solved the problem of merging two XHTML files, but one small
detail remains...
The parser outputs
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:xhtml="http://www.w3.org/1999/xhtml">
I would like it to output
<html xmlns="http://www.w3.org/1999/xhtml">
or simply
<html>
How can this be done? This is the stylesheet (I think it's
syntactically correct, but I thought the last one was so...). It takes
two well formed XHTML documents (one given as input to parser and
another as a parameter) and outputs the head of the first and combines
their bodies.
<?xml version="1.0" encoding="UTF-8"?>
<xsl:transform version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xhtml="http://www.w3.org/1999/xhtml"
xmlns="http://www.w3.org/1999/xhtml">
<xslutput method = "xml"
version = "1.0"
omit-xml-declaration = "no"
encoding = "UTF-8"
indent = "yes"
doctype-public = "-//W3C//DTD XHTML 1.0 Strict//EN"
doctype-system =
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"/>
<xslaram name="leftDocument">menu.xml</xslaram>
<xsl:template match="/">
<xsl:apply-templates/>
</xsl:template>
<xsl:template match="xhtml:html">
<html>
<xsl:copy-of select="xhtml:head"/>
<body>
<xsl:apply-templates select="xhtml:body"/>
</body>
</html>
</xsl:template>
<xsl:template match="xhtml:body">
<xslaram name="main">yes</xslaram>
<xsl:choose>
<xsl:when test="$main='yes'">
<xsl:apply-templates
select="document($leftDocument)/xhtml:html/xhtml:body">
<xsl:with-param name="main">no</xsl:with-param>
</xsl:apply-templates>
<div id="rightcontent">
<xsl:apply-templates />
</div>
</xsl:when>
<xsltherwise>
<div id="leftcontent">
<xsl:apply-templates />
</div>
</xsltherwise>
</xsl:choose>
</xsl:template>
<xsl:template match="node()|@*">
<xsl:copy-of select="."/>
</xsl:template>
</xsl:transform>
Thanks,
Chris
After going back through the XSL tutorials and the help here I have
largely solved the problem of merging two XHTML files, but one small
detail remains...
The parser outputs
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:xhtml="http://www.w3.org/1999/xhtml">
I would like it to output
<html xmlns="http://www.w3.org/1999/xhtml">
or simply
<html>
How can this be done? This is the stylesheet (I think it's
syntactically correct, but I thought the last one was so...). It takes
two well formed XHTML documents (one given as input to parser and
another as a parameter) and outputs the head of the first and combines
their bodies.
<?xml version="1.0" encoding="UTF-8"?>
<xsl:transform version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xhtml="http://www.w3.org/1999/xhtml"
xmlns="http://www.w3.org/1999/xhtml">
<xslutput method = "xml"
version = "1.0"
omit-xml-declaration = "no"
encoding = "UTF-8"
indent = "yes"
doctype-public = "-//W3C//DTD XHTML 1.0 Strict//EN"
doctype-system =
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"/>
<xslaram name="leftDocument">menu.xml</xslaram>
<xsl:template match="/">
<xsl:apply-templates/>
</xsl:template>
<xsl:template match="xhtml:html">
<html>
<xsl:copy-of select="xhtml:head"/>
<body>
<xsl:apply-templates select="xhtml:body"/>
</body>
</html>
</xsl:template>
<xsl:template match="xhtml:body">
<xslaram name="main">yes</xslaram>
<xsl:choose>
<xsl:when test="$main='yes'">
<xsl:apply-templates
select="document($leftDocument)/xhtml:html/xhtml:body">
<xsl:with-param name="main">no</xsl:with-param>
</xsl:apply-templates>
<div id="rightcontent">
<xsl:apply-templates />
</div>
</xsl:when>
<xsltherwise>
<div id="leftcontent">
<xsl:apply-templates />
</div>
</xsltherwise>
</xsl:choose>
</xsl:template>
<xsl:template match="node()|@*">
<xsl:copy-of select="."/>
</xsl:template>
</xsl:transform>
Thanks,
Chris