tags:

views:

48

answers:

5

I am using an XSL transformation on an xml file to create an xml document. The problem i am running into is that when i go to view the generated source (the transformed source) i can't see the DOCTYPE attribute of the html so i don't know if its being emitted properly.

Is there any way to view the doctype in this way?

A: 

I haven't tried it recently but I believe xsl:output can be used for this, see this tutorial and the options under the various attributes there.

Dan
A: 

Read about the doctype-system and doctype-public attributes of <xsl:output>.

Dimitre Novatchev
I found this over and over, but it's not emitting it to the html page and its not making the necessary tweaks to the rendering. So i really at a loss.
wcpro
A: 

This often happens when you serialize the result of the transformation (document tree) yourself. How do you run the transformation and obtain its result?

newtover
A: 

If you have transitional xhtml, you should include the following xsl:output tag:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
  <xsl:output method="html" 
    doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd" 
    doctype-public="-//W3C//DTD XHTML 1.0 Transitional//EN" />

  <xsl:template match="/">
    <html>
       <head><title>Test</title></head>
       <body></body>
    </html>
  </xsl:template>
</xsl:stylesheet>

This example produces the following output (with an arbitrary input XML):

<!DOCTYPE html
  PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;
<html>
   <head>
      <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
      <title>Test</title>
   </head>
   <body></body>
</html>
Jan Willem B
A: 

I must have a weird system, in my case i actually had to just use the doctype as an include file. I tried the suggestions but for some reason it wasnt rendering the html properly. Its kind of a weird system they have here at work and im not sure how it works.

wcpro