[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: Transforming augmented XHTML to XHTML using XSLT

Subject: Re: Transforming augmented XHTML to XHTML using XSLT
From: "Aaron Gray" <angray@xxxxxxxx>
Date: Fri, 21 Mar 2008 22:51:36 -0000
Re:  Transforming augmented XHTML to XHTML using XSLT
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="http://www.w3.org/1999/xhtml">
  <head>
    <title>Here is a head</title>
  </head>
  <body>
    <p>Here is a body.</p>
  </body>
</html>

t:\ftemp>type aaron.xsl
<?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"
     exclude-result-prefixes="h"
     >

<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>

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

       head
       <title xmlns="http://www.w3.org/1999/xhtml">Here is a head</title>

       body
       <p xmlns="http://www.w3.org/1999/xhtml">Here is a body.</p>

</html>
t:\ftemp>

Thanks, but there are still problems, I added a <head> and <body> elements, but xmlns'es seem to be propergating them selfs.


Aaron

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.