[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

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:24:20 -0400

At 2008-03-21 21:17 +0000, Aaron Gray wrote:
I have the following but cannot seem to get it to match head or body :-

In XSLT 1.0 unprefixed element names are *always* in no namespace, they are never in the default namespace.


<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet
     xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
     version="1.0"
     xmlns="http://www.w3.org/1999/xhtml"
     >

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

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

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

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

</xsl:stylesheet>

Try adding a prefix to every element name used in an XPath expression:


<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet
     xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
     version="1.0"
     xmlns="h:http://www.w3.org/1999/xhtml"
     >

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

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

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

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

</xsl:stylesheet>

I hope this helps.

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

--
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.          http://www.CraneSoftwrights.com/s/
Box 266, Kars, Ontario CANADA K0A-2E0    +1(613)489-0999 (F:-0995)
Male Cancer Awareness Nov'07  http://www.CraneSoftwrights.com/s/bc
Legal business disclaimers:  http://www.CraneSoftwrights.com/legal


Current Thread
Keywords