![]() |
![]() | ![]() | ![]() | Altova Mailing List Archives>Archive Index >microsoft.public.xsl Archive Home >Recent entries >Thread Prev - How to display HTML inside XML file as real HTML using XLST [Thread Next] Re: How to display HTML inside XML file as real HTML using XLSTTo: NULL Date: 1/28/2008 1:05:00 PM
guoqi zheng wrote:
> I have below XML file, inside the body tag, those are real html code, when I
> display them using XLST, I lost all the attribute defined inside the HTML
> code. For example <b> tag did not display text in bold format any more. How
> can I display them as real HTML?
>
> ----------------------------------------------------------
> <Content xmlns="uuid:F5940E5C-0D24-4460-821C-8ACA4DFD6FFA">
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
This default namespace declaration applies to all descendants too so the
elements like p or b or br are in that namespace too while for HTML they
need to be in no namespace, for XHTML they need to be in the XHTML
namespace http://www.w3.org/1999/xhtml.
> <Title>Equal Project</Title>
> <Intro>no intro here.</Intro>
> <Body>
> <p>
> this is some text here <b>this is bold</b>
> <br/>
> <br/>
> <a href="something.asp">test link</a>
> </p>
> </Body>
> </Content>
To fix that strip the namespace of those elements e.g.
<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0"
xmlns:df="uuid:F5940E5C-0D24-4460-821C-8ACA4DFD6FFA"
exclude-result-prefixes="df">
<xsl:template match="df:p | df:b | df:a | df:br">
<xsl:element name="{local-name()}">
<xsl:apply-templates select="@* | node()"/>
</xsl:element>
</xsl:template>
<xsl:template match="/">
<html>
<head>
<title><xsl:value-of select="df:Content/df:Title"/></title>
</head>
<body>
<xsl:apply-templates select="df:Content/df:Body/*"/>
</body>
</html>
</xsl:template>
<xsl:template match="@*">
<xsl:copy/>
</xsl:template>
</xsl:stylesheet>
--
Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/
| ![]() | ![]() | ![]() |
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | |||||
|
