xsl-list
[Top] [All Lists]

Re: [xsl] strip-spaces

2008-02-05 00:55:29
On 05/02/2008, Steven Ericsson-Zenith <steven(_at_)semeiosis(_dot_)org> 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?

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--

<Prev in Thread] Current Thread [Next in Thread>