Subject: Re: [xsl] xmlns="" / XML to XHTML From: Alexander Nichau <ml@xxxxxxxxxx> Date: Tue, 13 Sep 2005 11:58:13 +0200 |
<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 doesnB4t interpret nsXX as XHTMl though it has the right XML Namespace - Strange. Why they call it "extensible html" while it isnB4t really extensible? (Or at least browsers donB4t get it)
Michael, you meant I should skip this example and modify my second example (based on pawsonB4s 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 didnB4t 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?
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] xmlns="" / XML to XHTML, Alexander Nichau | Thread | RE: [xsl] xmlns="" / XML to XHTML, Michael Kay |
Re: [xsl] First character in a word, Joris Gillis | Date | RE: [xsl] First character in a word, Michael Kay |
Month |