[XSL-LIST Mailing List Archive Home]
[By Thread]
[By Date]
Hi everyone,
IB4m having a real confusing problem and I hope anyone can help me;
IB4m using a system which takes valid XHTML input done by the user and puts it out together with meta information and other stuff in a XML set.
One example could be this one:
Now I convert this xml set using XSLT1.0 to XHTML (XSL shortened):
<xsl:stylesheet version="1.0" xmlns="http://www.w3.org/1999/xhtml" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="http://www.w3.org/1999/XSL/Format">
<xsl:output method="xml" encoding="utf-8" standalone="yes"
doctype-public="-//W3C//DTD XHTML 1.0 Strict//EN"
doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd" indent="yes" omit-xml-declaration="yes" />
...
So the xsl processors has added the attribute xmlns="" to the outer elements (h2,p), which results in an invalid XHTML page according to the w3c validator. This attribute isnB4t added to the inner HTML-elements e.g. <br /> or <strong>
IB4ve been searching the web since about a week and I found an example which gets me rid of this attribute:
<xsl:template mode="import" match="*">
<xsl:element name="{local-name()}" namespace="http://www.w3.org/1999/xhtml" >
<xsl:apply-templates />
</xsl:element>
</xsl:template>
Unlikely, following the second example, ends up in an XHTML-Output where inner elements got this xmlns="".
So my question is, how should I modify my XSL-Transformation in order to get valid XSL-Output?
E.g. how can I modify the second example to iterate through every inner element? Or am I on the wrong way and should solve this problem completely different?
Finally one word about the software that produces this output:
I hope someone can help me-
Big thanks in advance,
Alex
[xsl] xmlns="" / XML to XHTML
Subject: [xsl] xmlns="" / XML to XHTML From: Alexander Nichau <ml@xxxxxxxxxx> Date: Mon, 12 Sep 2005 20:39:29 +0200 |
Hi everyone,
IB4m having a real confusing problem and I hope anyone can help me;
IB4m using a system which takes valid XHTML input done by the user and puts it out together with meta information and other stuff in a XML set.
One example could be this one:
<?xml version="1.0" ?> <page> <content> <topic module="content_xhtml" no="4" author="Alexander"> <text> <h2>Heading</h2> <p> .... </p> </text> </topic> </content> <meta>...</meta> ... </page>
Now I convert this xml set using XSLT1.0 to XHTML (XSL shortened):
<xsl:stylesheet version="1.0" xmlns="http://www.w3.org/1999/xhtml" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="http://www.w3.org/1999/XSL/Format">
<xsl:output method="xml" encoding="utf-8" standalone="yes"
doctype-public="-//W3C//DTD XHTML 1.0 Strict//EN"
doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd" indent="yes" omit-xml-declaration="yes" />
...
<xsl:param name="content" select="/page/content/topic"/> ...
<xsl:when test="$module = 'content_xhtml'"> <xsl:call-template name="content_xhtml"/> </xsl:when>
<xsl:template name="content_xhtml"> <xsl:param name="content" select="/page/content/topic"/> <xsl:copy-of select="$content/text/child::*" /> </xsl:template>
This results in a html page snippet: <h2 xmlns="">Heading</h2> <p xmlns="">.... <br /> .... </p>
So the xsl processors has added the attribute xmlns="" to the outer elements (h2,p), which results in an invalid XHTML page according to the w3c validator. This attribute isnB4t added to the inner HTML-elements e.g. <br /> or <strong>
IB4ve been searching the web since about a week and I found an example which gets me rid of this attribute:
<xsl:template match="text"> <xsl:apply-templates mode="import" /> </xsl:template>
<xsl:template mode="import" match="*">
<xsl:element name="{local-name()}" namespace="http://www.w3.org/1999/xhtml" >
<xsl:apply-templates />
</xsl:element>
</xsl:template>
Unlikely, following the second example, ends up in an XHTML-Output where inner elements got this xmlns="".
So my question is, how should I modify my XSL-Transformation in order to get valid XSL-Output?
E.g. how can I modify the second example to iterate through every inner element? Or am I on the wrong way and should solve this problem completely different?
Finally one word about the software that produces this output:
System: PHP Version 5.0.3 with libxml 2.6.9 and libxslt 1.1.12: dom DOM/XML enabled DOM/XML API Version 20031129 libxml Version 2.6.9 HTML Support enabled XPath Support enabled XPointer Support enabled Schema Support enabled RelaxNG Support enabled
xsl XSL enabled libxslt Version 1.1.12 libxslt compiled against libxml Version 2.6.17 EXSLT enabled libexslt Version 1.1.12
I hope someone can help me-
Big thanks in advance,
Alex
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
RE: [xsl] Using a template to trans, Emerson, Matt | Thread | Re: [xsl] xmlns="" / XML to XHTML, Joris Gillis |
RE: [xsl] Create two xml files from, Michael Kay | Date | Re: [xsl] Create two xml files from, ADAM PATRICK |
Month |