Subject: [xsl] XHTML and xml:space From: "Fredrik Geers" <fredrik@xxxxxxxxxx> Date: Thu, 31 Jul 2008 16:51:19 +0200 |
Hi, When transforming xhtml documents, I found out that sometimes an xml:space="preserve" attribute is added. If the xhtml document has doctype XHTML Basic 1.0, the attribute is added. If the doctype is XHTML 1.0 Strict, it isn't. Why this difference, and how do I prevent it? (without changing the doctype in the original document) I don't want these attributes, because they keep xsl:strip-space from working. I'm using Saxon B 9.1.0.1N, with xslt 2. Thanks, Fredrik Example input: <?xml version="1.0" encoding="utf-8"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML Basic 1.0//EN" "http://www.w3.org/TR/xhtml-basic/xhtml-basic10.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head><title>Test</title></head> <body> <div> <span id="test">Test</span> <span id="test2">Test2</span> </div> </body> </html> Example XSLT (simple identity transform): <?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xs="http://www.w3.org/2001/XMLSchema" xpath-default-namespace="http://www.w3.org/1999/xhtml"> <xsl:output method="xhtml" encoding="UTF-8"/> <xsl:template match="@*|node()"> <xsl:copy> <xsl:apply-templates select="@*|node()"/> </xsl:copy> </xsl:template> </xsl:stylesheet> Current result (wanted result is same, but without xml:space attributes): <?xml version="1.0" encoding="UTF-8"?><html xmlns="http://www.w3.org/1999/xhtml" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="-//W3C//DTD XHTML Basic 1.0//EN"> <head profile=""> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <title>Test</title> </head> <body xml:space="preserve"> <div xml:space="preserve"> <span id="test" xml:space="preserve">Test</span> <span id="test2" xml:space="preserve">Test2</span> </div> </body> </html>
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] How to allow element to a, CyberSpace Industrie | Thread | Re: [xsl] XHTML and xml:space, Andrew Welch |
Re: [xsl] How to allow element to a, CyberSpace Industrie | Date | [xsl] custom page sequence in xslfo, Sarkup Sarkup |
Month |