Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


Re: Parsing Augmented XHTML to XHTML using XSL

From: Martin Honnen <mahotrash@-----.-->
To: NULL
Date: 3/21/2008 1:11:00 PM

Aaron Gray wrote:

> <xsl:stylesheet version="1.0"
>                xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
>                xmlns="http://www.w3.org/TR/xhtml1/strict">
                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
That is not an XHTML namespace, the namespace for XHTML 1 is 
http://www.w3.org/1999/xhtml.

> <xsl:output method="html" encoding="UTF-8"/>
> <xsl:template match="/">
> <html>
>  <head>
>    <xsl:copy-of select="/html/head"/>
>  </head>
>  <body>
>    <xsl:copy-of select="/html/body"/>
>  </body>
> </html>
> </xsl:template>
> </xsl:stylesheet>
> 
> But reading from the input XHTML does not seem to work now :(
> 
> I tried adding an xmlns:xhtml namespace but that did not want to work 
> either.

You will have to decide what the output of the stylesheet should be, 
whether you want HTML 4 with elements being in no namespace or whether 
you want XHTML with elements being in the namespace 
http://www.w3.org/1999/xhtml.
If the input is really XHTML (meaning elements in the XHTML namespace) 
and you want HTML 4 output then you can't use xsl:copy or xsl:copy-of as 
you then copy the elements including their namespace. Instead you need 
to strip the namespace e.g.
   <xsl:stylesheet
      xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
      version="1.0"
      xmlns:xhtml="http://www.w3.org/1999/xhtml"
      exclude-result-prefixes="xhtml">

      <xsl:template match="xhtml:*">
        <xsl:element name="{local-name()}">
          <xsl:apply-templates select="@* | node()"/>
        </xsl:element>
      </xsl:template>




-- 

	Martin Honnen --- MVP XML
	http://JavaScript.FAQTs.com/


transparent
Print
Mail
Digg
delicious
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent