Altova Mailing List Archives>Archive Index >microsoft.public.xsl Archive Home >Recent entries [Thread Prev] >Thread Next - Re: XSLT and well-formed XHTML XSLT and well-formed XHTMLTo: NULL Date: 5/10/2008 10:40:00 AM I have an XML doc that represents a web page. I use an XSLT to transform the XML in to XHTML. However, there are a number of problems with the resulting XHTML and consequently, it doesn't validate against the w3c validator. I've been searching the web for solutions and found some half-baked answers to some of these issues, but no real solutions that made sense to me. Here are my issues: 1. The character encoding specified in the HTTP header (utf-8) is different from the value in the <meta> element (utf-16). I will use the value from the HTTP header (utf-8) for this validation. This problem is created by this line: <META http-equiv="Content-Type" content="text/html; charset=utf-16">, which is automatically generated by the transformation???? I'm not sure why. 2. The meta tags are not well formed. They show up without the closing "/>." I tried to resolve this by changing my XSLT output from "html" to "xml" but that results in no page at all. 3. I get blank namespace attributes, such as: <body xmlns="">. I have absolutely no idea why this is happening, but it's invalid. Following is my XSLT. It is neither sophisticated nor complex. Is there anyone who can help me resolve these issues? <?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" doctype-public="-//W3C//DTD XHTML 1.0 Transitional//EN" doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1- transitional.dtd" omit-xml-declaration="yes" encoding="UTF-8" indent="yes" /> <xsl:param name="includeVelocityComment">true</xsl:param> <xsl:param name="previewMode">false</xsl:param> <xsl:template match="Velocity/Page"> <xsl:text> </xsl:text> <html xmlns="http://www.w3.org/1999/xhtml"> <xsl:if test="($includeVelocityComment) and ($includeVelocityComment='true')"> <xsl:text> </xsl:text> <xsl:comment>Generated by Velocity.</xsl:comment> </xsl:if> <xsl:apply-templates /> </html> </xsl:template> <xsl:template match="Velocity/Page/ViewDate"> <xsl:comment> Viewed as of <xsl:value-of select="."></xsl:value-of> </xsl:comment> </xsl:template> <!-- <head> templates --> <xsl:template match="Velocity/Page/Head"> <xsl:text> </xsl:text> <head> <xsl:apply-templates/> </head> </xsl:template> <xsl:template match="Velocity/Page/Head/SEO/Tags"> <xsl:element name="meta"> <xsl:attribute name="name">keywords</xsl:attribute> <xsl:attribute name="content"> <xsl:value-of select="."/> </xsl:attribute> <xsl:text> </xsl:text> </xsl:element> </xsl:template> <xsl:template match="Velocity/Page/Head/SEO/Description"> <xsl:element name="meta"> <xsl:attribute name="name">description</xsl:attribute> <xsl:attribute name="content"> <xsl:value-of select="."/> </xsl:attribute> <xsl:text> </xsl:text> </xsl:element> </xsl:template> <xsl:template match="Velocity/Page/Head/SEO/Robots"> <xsl:element name="meta"> <xsl:attribute name="name">robots</xsl:attribute> <xsl:attribute name="content"> <xsl:value-of select="."/> </xsl:attribute> <xsl:text> </xsl:text> </xsl:element> </xsl:template> <xsl:template match="Velocity/Page/Head/CSS/CSSRef"> <xsl:element name="link"> <xsl:attribute name="rel">stylesheet</xsl:attribute> <xsl:attribute name="type">text/css</xsl:attribute> <xsl:attribute name="href"> <xsl:value-of select="."/> <!--<xsl:choose> <xsl:when test="@title"><xsl:value-of select="@title"/>.css</ xsl:when> <xsl:otherwise>css.ashx?id=<xsl:value-of select="."/></ xsl:otherwise> </xsl:choose>--> </xsl:attribute> </xsl:element> <xsl:text> </xsl:text> </xsl:template> <!--<xsl:template match="Velocity/Page/Head/CSS/Html"> <xsl:if test=".!=''"> <style type="text/css"> <xsl:value-of select="." disable-output-escaping="yes"/> </style> </xsl:if> </xsl:template>--> <xsl:template match="Velocity/Page/Head/JavaScript/JavaScriptFile"> <xsl:element name="script"> <xsl:attribute name="type">text/javascript</xsl:attribute> <xsl:attribute name="src"> <xsl:value-of select="."/> <!--<xsl:choose> <xsl:when test="@title"><xsl:value-of select="@title"/>.js</ xsl:when> <xsl:otherwise><xsl:value-of select="."/></xsl:otherwise> </xsl:choose>--> </xsl:attribute> </xsl:element> <xsl:text> </xsl:text> </xsl:template> <!--<xsl:template match="Velocity/Page/Head/JavaScript/Html"> <xsl:if test=".!=''"> <script type="text/javascript"> <xsl:value-of select="." disable-output-escaping="yes"/> </script> </xsl:if> </xsl:template>--> <!-- <body> templates --> <xsl:template match="Velocity/Page/Body"> <xsl:element name="body"> <!--<xsl:if test="($previewMode) and ($previewMode='true')"> <xsl:attribute name="onload">parent.setIframeHeight()</ xsl:attribute> </xsl:if>--> <xsl:value-of select="." disable-output-escaping="yes"/> </xsl:element> </xsl:template> </xsl:stylesheet> | ||||||
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | Mobile | Full Site | |||
|
