Inserting xml-stylesheet processing instruction not working

Questions about XML that are not covered by the other forums should go here.
csalsa
Posts: 97
Joined: Tue Apr 22, 2008 9:31 am

Inserting xml-stylesheet processing instruction not working

Post by csalsa »

I am using XSL/T and want to output a 'xml-stylesheet' processing instruction to an XML file. The test code below is not outputting the attributes correctly for the processing instruction but works for the document element.

Any ideas? Am I missing something?


XSL

Code: Select all

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0">
<xsl:output method="xml" indent="yes" encoding="utf-8" omit-xml-declaration="no"/>
<xsl:strip-space elements="*"/>
<xsl:template match="/">
<xsl:processing-instruction name="xml-stylesheet">
<xsl:attribute name="href">styles1.css</xsl:attribute>
<xsl:attribute name="type">text/css</xsl:attribute>
</xsl:processing-instruction>
<table>
<xsl:attribute name="href">styles2.css</xsl:attribute>
<xsl:attribute name="type">text/css</xsl:attribute>
<xsl:apply-templates select="*"/>
</table>
</xsl:template>
</xsl:stylesheet>
XSL/T Output

Code: Select all

<?xml version="1.0" encoding="utf-8"?>
<?xml-stylesheet styles1.css text/css?><table href="styles2.css" type="text/css"/>
I am using Oxygen 9.3 on Windows XP and Saxon-B 9.0.0.6 for the XSL/T processor.
Radu
Posts: 9439
Joined: Fri Jul 09, 2004 5:18 pm

Re: Inserting xml-stylesheet processing instruction not working

Post by Radu »

Hi,

The processing instruction should be declared in the XSL like this:

Code: Select all


<xsl:processing-instruction name="xml-stylesheet">href="styles1.css" type="text/css"</xsl:processing-instruction>
See http://www.w3schools.com/XSL/el_process ... uction.asp

Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
csalsa
Posts: 97
Joined: Tue Apr 22, 2008 9:31 am

Re: Inserting xml-stylesheet processing instruction not working

Post by csalsa »

Many thanks for the pointer. I should have found it myself.
Post Reply