Subject: Re: [xsl] xsl -> xhtml and xlmns-namespace From: Jeni Tennison <jeni@xxxxxxxxxxxxxxxx> Date: Thu, 19 Feb 2004 15:03:30 +0000 |
Hi Peter, > 1) What do I have to add to my .xsl-file to have '<!DOCTYPE html > PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" > "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> !-->' added as > the first line of my output? Typing the above doctype doesn't work, > because then my xml isn't valid anymore Use the doctype-system and doctype-public attributes on the <xsl:output> declaration: <xsl:output doctype-public="-//W3C//DTD XHTML 1.0 Strict//EN" doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd" /> > 2) Why is xmlns="..." added in <a href="..">-tags? That's not > XHTML-valid! XSLT (1.0) doesn't know anything about XHTML -- as far as it's concerned, it's just another XML-based markup language, and it should obey the same rules as any other XML-based markup language. XSLT never checks the output it generates to make sure that it's valid against a particular DTD, so it's up to you to make sure you create valid output. If you're getting namespace declarations that you don't want, it's probably because the elements that you're generating are in a different namespace from the one that you expect. Typically this happens when you put namespace declarations on a literal result element, within a template, such that the scope is only within that literal result element, rather than on the <xsl:stylesheet> document element, such that the scope is the entire stylesheet. For example, rather than: <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:template match="/"> <html xmlns="http://www.w3.org/1999/xhtml"> ... </html> </xsl:template> ... </xsl:stylesheet> do: <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns="http://www.w3.org/1999/xhtml"> <xsl:template match="/"> <html> ... </html> </xsl:template> ... </xsl:stylesheet> The latter ensures that all the literal result elements that don't have a prefix are generated in the XHTML namespace. Typically, an XSLT processor will output the resulting document with the default namespace declaration only appearing on the document element of the result. (I say "typically" because an XSLT processor is allowed to add any namespace declarations it wants, provided the resulting document is the same to a namespace-aware processor.) If that doesn't solve the namespace declaration problem, show us the code and we should be able to work out where the additional declaration is coming from. Cheers, Jeni --- Jeni Tennison http://www.jenitennison.com/ XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] xsl -> xhtml and xlmns-namesp, Peter Billen | Thread | Re: [xsl] xsl -> xhtml and xlmns-na, David Carlisle |
RE: [xsl] Counting nodes efficientl, Dimitre Novatchev | Date | Re: [xsl] xsl -> xhtml and xlmns-na, David Carlisle |
Month |