xsl-list
[Top] [All Lists]

Re: xmlns="" / XML to XHTML

2005-09-13 02:58:13
Joris Gillis schrieb:
<xsl:template name="content_xhtml">
  <xsl:param name="content" select="/page/content/topic"/>
<xsl:apply-templates select="$content/text/*" mode="put_in_new_namespace"> <xsl:with-param name="new_namespace">http://www.w3.org/1999/xhtml</xsl:with-param>
  </xsl:apply-templates>
</xsl:template>

<xsl:template match="*" mode="put_in_new_namespace" priority="1">
<xsl:param name="new_namespace"/>
<xsl:element name="{local-name()}" namespace="{$new_namespace}">
    <xsl:copy-of select="@*"/>
    <xsl:apply-templates select="node()" mode="put_in_new_namespace">
        <xsl:with-param name="new_namespace" select="$new_namespace"/>
    </xsl:apply-templates>
</xsl:element>
</xsl:template>

<xsl:template match="node()" mode="put_in_new_namespace">
    <xsl:copy-of select="."/>
</xsl:template>

With the help of Joris Gillis we tried to modify my examples. The above
code from Joris gives the following output:

 <ns1:h2 xmlns:ns1="http://www.w3.org/1999/xhtml";>...
</ns1:h2>
            <ns2:p xmlns:ns2="http://www.w3.org/1999/xhtml";>...
              <ns2:br></ns2:br>
...
</ns2:p>
            <ns3:p xmlns:ns3="http://www.w3.org/1999/xhtml";>...
              <ns3:br></ns3:br>
...
</ns3:p>
et cetera

So I think, his code does create the right elements but instead of
putting the namespace to XHTML according to the rest of the output (I
mean put an empty prefix there) the processor numerates each namespace.

So how can I skip the namespace numeration to get browser legible XHTML?
(The browser doesn´t interpret nsXX as XHTMl though it has the right XML
Namespace - Strange. Why they call it "extensible html" while it isn´t
really extensible? (Or at least browsers don´t get it)


Michael, you meant I should skip this example and modify my second
example (based on pawson´s FAQ)?:

<xsl:template match="*">
   <xsl:element name="{local-name()}"
 namespace="http://www.w3.org/1999/xhtml"; >
    <xsl:apply-templates />
   </xsl:element>
</xsl:template>

So the problem there was, that my inner elements didn´t get the ns
although the outer elements were created correct in the xhtml namespace.
So I ask why does it not apply the namespace to the inner elements or
what should I modify?

Thanks in advance, Alexander



--~------------------------------------------------------------------
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>