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

Re: Problem copying xhtml elements from xml source

Subject: Re: Problem copying xhtml elements from xml source
From: Josh Canfield <joshcanfield@xxxxxxxxx>
Date: Mon, 12 Jul 2004 19:23:00 -0700
copy of xsl
They are correct, this is a problem with your stylesheet.

IE must be much more forgiving when it comes th xhtml compliance. When
you look at the output you are actually taking the copied elements out
of the xhtml namespace with an empty xmlns attribute.

It looks like the way to fix this is to do a variation of the identity
transform, but creating the elements with xsl:element, and using
local-name() to get the name of the element. see
http://www.dpawson.co.uk/xsl/sect2/N5536.html#d6223e1750

*** Updated XSL ****

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

 <xsl:output
   method="xml"
   encoding="iso-8859-1"
   indent="yes"
   doctype-public="-//W3C//DTD XHTML 1.0 Strict//EN"
   doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"
   />

 <xsl:template match="/test-copy-of">
   <html lang="en" xml:lang="en">
     <head>
       <title>test-copy-of</title>
       <meta http-equiv="content-type" content="text/html;charset=iso-8859-1"/>
     </head>
     <body>
       <div>
         <xsl:apply-templates select="*"/>
       </div>
     </body>
   </html>
 </xsl:template>

 <xsl:template match="*">
    <xsl:element name="{local-name()}">
      <!-- go process attributes and children -->
      <xsl:apply-templates select="@*|node()"/>
    </xsl:element>
  </xsl:template>

  <xsl:template match="@*">
    <xsl:attribute name="{local-name()}">
      <xsl:value-of select="."/>
    </xsl:attribute>
  </xsl:template>

</xsl:stylesheet>

On Tue, 13 Jul 2004 00:39:12 +0200, cking <cking@xxxxxxxxxx> wrote:
> Hello,
> 
> I didn't get many replies, maybe because I didn't include the code,
> only the link to my testcase. So here's my question again:
> is this a correct way to copy xhtml elements from an xml source file?
> 
> ** source xml:
> 
> <?xml version="1.0" encoding="iso-8859-1"?>
> <?xml-stylesheet type="text/xsl" href="test-copy-of.xsl"?>
> <test-copy-of>
>  <p style="color:red;">a paragraph in <b>red</b></p>
>  <p><img src="wood102.jpg" width="149" height="177" alt="wood"/></p>
> </test-copy-of>
> 
> ** test-copy-of.xsl:
> 
> <xsl:stylesheet
>  version="1.0"
>  xmlns="http://www.w3.org/1999/xhtml"
>  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
>  >
> 
>  <xsl:output
>    method="xml"
>    encoding="iso-8859-1"
>    indent="yes"
>    doctype-public="-//W3C//DTD XHTML 1.0 Strict//EN"
>    doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"
>    />
> 
>  <xsl:template match="/test-copy-of">
>    <html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
>      <head>
>        <title>test-copy-of</title>
>        <meta http-equiv="content-type" content="text/html;charset=iso-8859-1"/>
>      </head>
>      <body>
>        <div>
>          <xsl:copy-of select="*"/>
>        </div>
>      </body>
>    </html>
>  </xsl:template>
> 
> </xsl:stylesheet>
> 
> This works as expected in IE6 and Saxon, but in Mozilla/Firefox,
> all formatting is lost (as if only text nodes come through).
> 
> The Mozilla folks say that the error is in the stylesheet. The reason
> would be, that the elements from the source file are not in the
> xhtml namespace. Is that true? And if yes, how can I make this work?
> 
> Full testcase at http://users.telenet.be/cking/webstuff/test/copy-of/info.html
> Bugreport: http://bugzilla.mozilla.org/show_bug.cgi?id=250921
> 
> Thanks for any help!
> Anton Triest

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.