B
Bob Yuan
Hi, I am working on a asp.net project that takes a xml
source and use XslTransform.transform to generate a xhtml
output.
The problem with using XslTransform is that it
automatically reformats the output as HTML instead of
xhtml. For example, if the xslt file contains <img
src="..." />, the result html file is <img src="..." > and
this is not well formed xhtml.
Is there a way to prevent this aut-reformatting from
happening? I have been testing with the simplest examples:
say the xslt is:
<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">
<xsl:template match="/">
<html><body>image<img src="#" /></body></html>
</xsl:template>
</xsl:stylesheet>
The resulting html is:
<html>
<body>image<img src="#"></body>
</html>
It is perfectly fine xml, but not xhtml since the "/" is
removed.
However, if I remove "<html><body>" etc from the xslt file:
<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">
<xsl:template match="/">
image<img src="#" />
</xsl:template>
</xsl:stylesheet>
I do get what I want:
<?xml version="1.0" encoding="utf-8"?>
image<img src="#" />
So, something is reformatting the html output when there
is <html> tag existing. How to turn it off?
Thanks.
source and use XslTransform.transform to generate a xhtml
output.
The problem with using XslTransform is that it
automatically reformats the output as HTML instead of
xhtml. For example, if the xslt file contains <img
src="..." />, the result html file is <img src="..." > and
this is not well formed xhtml.
Is there a way to prevent this aut-reformatting from
happening? I have been testing with the simplest examples:
say the xslt is:
<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">
<xsl:template match="/">
<html><body>image<img src="#" /></body></html>
</xsl:template>
</xsl:stylesheet>
The resulting html is:
<html>
<body>image<img src="#"></body>
</html>
It is perfectly fine xml, but not xhtml since the "/" is
removed.
However, if I remove "<html><body>" etc from the xslt file:
<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">
<xsl:template match="/">
image<img src="#" />
</xsl:template>
</xsl:stylesheet>
I do get what I want:
<?xml version="1.0" encoding="utf-8"?>
image<img src="#" />
So, something is reformatting the html output when there
is <html> tag existing. How to turn it off?
Thanks.