|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Stop making mediocre tutorials.The best tutorials are video! Camtasia Studio makes it easy to create engaging, buzz-building screen videos at any size, in any popular format. Download the free trial!
|
|
#1
|
|||
|
|||
|
XSLT outputing <?xml> and <!DOCTYPE>
I'm using XSLT to transform XML data into XHTML, but I need to output the xml declaration and the doctype before the <html> tag...
<xsl:template match="/"> <?xml version="1.0"?> <!DOCTYPE html PUBLIC "-//OPENWAVE//DTD XHTML Mobile 1.0//EN" "http://www.openwave.com/DTD/xhtml-mobile10.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> ... </xsl:template> How can I have these included in my code? Currently they cause errors. |
|
#2
|
||||
|
||||
|
i believe it has to go in the xsl:output element which must appear as the child node of the xsl:stylesheet element. I hope this helps.
Code:
<xsl:output method="xml" encoding="iso-8859-1" doctype-system="http://www.w3.org/TR/2000/REC-xhtml1-20000126/DTD/xhtml1-strict.dtd"; doctype-pubilc="-//W3C//DTD XHTML 1.0 Strict//EN"/> |
|
#3
|
|||
|
|||
|
So it is not possible to have the following outputted by my XSL? The above example would probably take care of the doctype, but what about the <?xml version="1.0"?>
<?xml version="1.0"?> <!DOCTYPE html PUBLIC "-//OPENWAVE//DTD XHTML Mobile 1.0//EN" "http://www.openwave.com/DTD/xhtml-mobile10.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> ... </html> |
|
#4
|
||||
|
||||
|
you could out put it but i am not sure that it will not give unexpected results. typically the "processor directive" is the first line in your xsl page. something like what you have. It is basically a statement that says "hello I ma a xml file... process me!" Then the stylesheets requires everything to be placed inside the <xsl:stylesheet> element for transformation.
Code:
<?xml version="1.0" encoding="UTF-8"?> |
|
#5
|
|||
|
|||
|
This is controlled by the "omit-xml-declaration" attribute, which is generally set by "no" by default. If your output method is "xml" then it should automatically output the declaration. If it doesn't, try adding omit-xml-declaration="no" to the <xsl:output> element.
|
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > XML Programming > XSLT outputing <?xml> and <!DOCTYPE> |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|