Subject: Re: [xsl] strip-spaces From: "Colin Adams" <colinpauladams@xxxxxxxxxxxxxx> Date: Tue, 5 Feb 2008 07:54:59 +0000 |
On 05/02/2008, Steven Ericsson-Zenith <steven@xxxxxxxxxxxxx> wrote: > validate as XHTML strict requiring only that I remove the xmlns="" > that is generated on nodes by the XSL serializer. Are you saying you removed xmlns="" by hand? In that case, you should go back and fix the stylesheet. > understand why the serializers put in the erroneous empty namespace > assignments. If the serializer put them in, they they are not erroneous. The error is in your template - you have to ensure that the elements you output are in the xhtml namespace. This issue occurs locally, rather than at the level of the stylesheet as a whole. It usually arises because you code a literal result element as a child of an XSLT element. If the literal result element is intended to be in the xhtml namespace, then you must code it there and then. To illustrate in brief: <xsl:transform xmlns:xsl="..." ... > <xsl:template match="/"> <html xmlns="<xhtml namespace definition>"> <xsl:apply-templates ... /> </html> </xsl:template> <xsl:template match="something or other"> <body> <xsl:apply-templates ... /> </body> </xsl:template> </xsl:transform> Here, body is in no namespace. The confusion arises because if you are writing the xhtml by hand, rather than in xslt, you write: <html xmlns="<xhtml namespace definition>"> <body> </body> </html> Here body IS in the xhtml namespace, because it inherits the default namespace from its parent element. But in the first example (the transformation) the parent (xsl:template) has no default namespace. Instead, you could write it as: > assignments. If the serializer put them in, they they are not erroneous. The error is in your template - you have to ensure that the elements you output are in the xhtml namespace. This issue occurs locally, rather than at the level of the stylesheet as a whole. It usually arises because you code a literal result element as a child of an XSLT element. If the literal result element is intended to be in the xhtml namespace, then you must code it there and then. To illustrate in brief: <xsl:transform xmlns:xsl="..." ... > <xsl:template match="/"> <html xmlns="<xhtml namespace definition>"> <xsl:apply-templates ... /> </html> </xsl:template> <xsl:template match="something or other" > <body> <xsl:apply-templates ... /> </body> </xsl:template> </xsl:transform> Here, body is in no namespace. Instead you could write: <xsl:template match="something or other" xmlns="<xhtml namespace definition>"> <body> <xsl:apply-templates ... /> </body> </xsl:template> Now body IS in the xhtml namespace, and all is well. > I thought I understood XML namespaces but obviously not when it comes > to the intertwining with XHTML. Especially when given that an xhtml > document "is not xml," why there should be an xmlns issue at all. An xhtml document certainly IS xml. > If you are generating xhtml output and you create a result node - > should it not simply be the case that it is in the xhtml name space. No. The result node is in whatever namespace you put it (or not). Suppose you want to include SVG and/or MathML elements in your xhmtl?
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] strip-spaces, Steven Ericsson-Zeni | Thread | Re: [xsl] strip-spaces, David Carlisle |
[xsl] Count Ancestors Up To But Not, Eliot Kimber | Date | Re: [xsl] Browser support for X-lin, Colin Adams |
Month |