Re: [xsl] Transforming augmented XHTML to XHTML using XSLT

Subject: Re: [xsl] Transforming augmented XHTML to XHTML using XSLT
From: "G. Ken Holman" <gkholman@xxxxxxxxxxxxxxxxxxxx>
Date: Fri, 21 Mar 2008 17:44:26 -0400
At 2008-03-21 17:31 -0400, Robert Koberg wrote:

>     <xsl:template match="/">
>       <html>
>         <xsl:apply-templates select="." mode="html"/>
>       </html>
>     </xsl:template>

You are trying to apply on the document node in the html mode. It is
looking to be matched by:

<xsl:template match="/" mode="html"/>

The built-in template rule will satisfy the above, and since built-in template rules preserve the current mode, there should be no problems.

Except for my very sloppy writing where I mistyped the namespace declaration, the code works fine (see below). Note that the unused namespace declarations in the result are innocuous ... if you want to get rid of them it will take some code to reconstitute each element that you are matching.

I hope this helps.

. . . . . . . . . . . . . Ken

t:\ftemp>type aaron.xml
<?xml version="1.0" encoding="UTF-8"?>
<html xmlns="";>
    <title>Here is a head</title>
    <p>Here is a body.</p>

t:\ftemp>type aaron.xsl
<?xml version="1.0" encoding="UTF-8"?>

<xsl:output method="xml" encoding="UTF-8" indent="yes"/>

   <xsl:template match="/">
       <xsl:apply-templates select="." mode="html"/>

   <xsl:template match="h:head" mode="html">
       <xsl:copy-of select="*"/>

   <xsl:template match="h:body" mode="html">
       <xsl:copy-of select="*"/>


t:\ftemp>xslt aaron.xml aaron.xsl con
<?xml version="1.0" encoding="UTF-8"?>

       <title xmlns="";>Here is a head</title>

       <p xmlns="";>Here is a body.</p>


-- Upcoming: UBL Apr.22,24; genericode code lists Apr.23; Rome,Italy World-wide corporate, govt. & user group XML, XSL and UBL training RSS feeds: publicly-available developer resources and training G. Ken Holman mailto:gkholman@xxxxxxxxxxxxxxxxxxxx Crane Softwrights Ltd. Box 266, Kars, Ontario CANADA K0A-2E0 +1(613)489-0999 (F:-0995) Male Cancer Awareness Nov'07 Legal business disclaimers:

Current Thread