Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


XSLT and well-formed XHTML

From: Vic <vfees@---------------.--->
To: 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>&#10;</xsl:text>
		<html xmlns="http://www.w3.org/1999/xhtml">
			<xsl:if test="($includeVelocityComment) and
($includeVelocityComment='true')">
				<xsl:text>&#10;</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>&#10;</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>&#10;</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>&#10;</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>&#10;</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>&#10;</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>&#10;</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>



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