[xslt] Overriding default behavior of XHTML compatibility guidelines



Hi All,

I've recently come across a situation where I'd like to create an XSLT 1.0 stylesheet that outputs XHTML that conforms to the XHTML compatibility guidelines for HTML browser parsers (Appendix C of the XHTML 1 specification). Usually, this happens automatically when the XML serializer within libxml detects an XHTML doctype. Unfortunately, in my case, I'm using the XHTML + RDFa doctype, which isn't in the hard coded list of doctypes which trigger Appendix C conformant output. Looking at the libxml code, the serialization API does provide an option to override this default behaviour regardless of the doctype (see xmlSaveOption enum). Unfortunately, it seems libxslt doesn't make use of this functionaility at all and simply uses the serialization methods which just sniff the doctype against the hard coded list of known XHTML doctypes.

My knowledge of this subject is very limited and my conclusions from my investigations could well be flawed, so I'd appreciate any input from those who know much more than I on this subject.

To be more precise, my <xsl:output> element looks like this...

<xsl:output method="xml"
    doctype-public="-//W3C//DTD XHTML+RDFa 1.0//EN"
    doctype-system="http://www.w3.org/MarkUp/DTD/xhtml-rdfa-1.dtd";
    omit-xml-declaration="yes"
    encoding="UTF-8"
    indent="yes"/>

But looking at xmlsave.c in libxml2, the hard coded list of doctypes which trigger Appendix C conformant output looks like this:

#define XHTML_STRICT_PUBLIC_ID BAD_CAST \
   "-//W3C//DTD XHTML 1.0 Strict//EN"
#define XHTML_STRICT_SYSTEM_ID BAD_CAST \
   "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd";
#define XHTML_FRAME_PUBLIC_ID BAD_CAST \
   "-//W3C//DTD XHTML 1.0 Frameset//EN"
#define XHTML_FRAME_SYSTEM_ID BAD_CAST \
   "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd";
#define XHTML_TRANS_PUBLIC_ID BAD_CAST \
   "-//W3C//DTD XHTML 1.0 Transitional//EN"
#define XHTML_TRANS_SYSTEM_ID BAD_CAST \
   "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd";

Any help greatly appreciated.


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]