XslTransform.transform does not generate xhtml

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.
 
M

Michal A. Valasek

| So, something is reformatting the html output when there
| is <html> tag existing. How to turn it off?

<xsl:eek:utput method="xml" />

if you don't specify output method, it would guess. And if you have <html>
there, sets <xsl:eek:utput method="html" />

-- Altair
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,022
Latest member
MaybelleMa

Latest Threads

Top