[XSL-LIST Mailing List Archive Home]
[By Thread]
[By Date]
Hi,
With XSLT2, I have an element that can be either in no namespace or in the default namespace, based on some condition, as in
<html>
...
</html>
Without success, I tried things like:
<html>
<if test="$cond">
<xsl:namespace name="">http://www.w3.org/1999/xhtml</xsl:namespace>, but cannot output a namespace node for the default namespace when the element is in no namespace
<!-- or <xsl:namespace name="xmlns">http://www.w3.org/1999/xhtml</xsl:namespace>, but then xmlns name is not acceptable,
or even <xsl:namespace>http://www.w3.org/1999/xhtml</xsl:namespace>, but the name attribute is required -->
</if>
...
</html>
The following may also have been nice, if it created a namespace node rather than an xmlns attribute:
<html xmlns="if ($cond) then 'http://www.w3.org/1999/xhtml' else '' ">
...
</html>
I understand that I could probably put the body of the html element in a template (e.g. html-body), define all the (tons of) required parameters, and do something like:
But, especially as this would seem like a common case, I am sincerely hoping that there is a better way.
How should this be better handled?
[xsl] default or no namespace
Subject: [xsl] default or no namespace From: ac <ac@xxxxxxxxxxxxx> Date: Tue, 28 Dec 2010 02:02:09 -0500 |
Hi,
With XSLT2, I have an element that can be either in no namespace or in the default namespace, based on some condition, as in
<html>
...
</html>
or <html xmlns="http://www.w3.org/1999/xhtml"> ... </html>
Without success, I tried things like:
<html>
<if test="$cond">
<xsl:namespace name="">http://www.w3.org/1999/xhtml</xsl:namespace>, but cannot output a namespace node for the default namespace when the element is in no namespace
<!-- or <xsl:namespace name="xmlns">http://www.w3.org/1999/xhtml</xsl:namespace>, but then xmlns name is not acceptable,
or even <xsl:namespace>http://www.w3.org/1999/xhtml</xsl:namespace>, but the name attribute is required -->
</if>
...
</html>
The following may also have been nice, if it created a namespace node rather than an xmlns attribute:
<html xmlns="if ($cond) then 'http://www.w3.org/1999/xhtml' else '' ">
...
</html>
I understand that I could probably put the body of the html element in a template (e.g. html-body), define all the (tons of) required parameters, and do something like:
<xsl:choose> <xsl:when test="$cond"> <html xmlns="http://www.w3.org/1999/xhtml"> <xsl:call-template name="html-body"> <xsl:with-param name="xxx" select="abc"/> ... </xsl:call-template> </html> </xsl:when> <xsl:otherwise> <html> <xsl:call-template name="html-body"> <xsl:with-param name="xxx" select="abc"/> ... </xsl:call-template> </html> </xsl:otherwise> </xsl:choose>
But, especially as this would seem like a common case, I am sincerely hoping that there is a better way.
How should this be better handled?
Regards, ac
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] xsltproc [Error Log], pankaj . c | Thread | Re: [xsl] default or no namespace, Andrew Welch |
Re: [xsl] xsltproc [Error Log], pankaj . c | Date | Re: [xsl] default or no namespace, Andrew Welch |
Month |