Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


Re: XSLT removes HTML tags

From: Martin Honnen <mahotrash@-----.-->
To: NULL
Date: 3/6/2009 12:58:00 PM
Majid wrote:
> Hi,
> I use the following XSLT file to transfer a xml document into XHTML format 
> and everything goes fine except the fact that XSLT removes all my html tags 
> such as <br /> tags or <b></b> and only uses the text content.
> This is the XSLT file : 
> 
> 
> <?xml version="1.0" encoding="utf-8"?>
> <xsl:stylesheet version="1.0" 
> xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
>   <xsl:output method="html" indent="yes"/>
>   <xsl:output omit-xml-declaration="yes"/>
>   <xsl:template match="/">
>     <html xmlns="http:////www.w3.org/1999/xhtml">
>       <head>
>         <title>Test title</title>
>       </head>
>       <body>
> 
>         <xsl:apply-templates select="/emaillist/email_content"/>
> 
>       </body>
>     </html>
>   </xsl:template>
>   <xsl:template match="item">
>   </xsl:template>

You need at least to add a template for email_content that copies the 
child nodes to the result tree
   <xsl:template match="email_content">
     <xsl:copy-of select="node()"/>
   </xsl:template>

However as your XML below has elements in no namespace while you want to 
output elements in the XHTML
namespace you will not get the result you want.
Consider to have the stylesheet generate HTML 4 not XHTML, then the 
above works. Otherwise you would need to write templates that transform 
e.g. br or b elements in no namespace to the XHTML namespace.


> <emaillist>
>   <email_content>
>      <b>Test Text</b>,<br />
> 
>     Test Text,<br />
> 
> 
>   </email_content>
> </emaillist>




-- 

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


transparent
Print
Mail
Like It
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