xsl-list
[Top] [All Lists]

Re: [xsl] default or no namespace

2010-12-28 09:37:16
On 28 December 2010 14:59, ac <ac(_at_)hyperbase(_dot_)com> wrote:
Hi Andrew, All,

Interesting.  I think that I need a little more though.

Does it mean that I should do something like:

<xsl:variable name="page">
<html>
       ...
</html>
</xsl:variable>
<xsl:choose>
<xsl:when test="$cond">
<xsl:apply-templates mode="put-in-xhtml-ns" select="$page"/>
</xsl:when>
<xsl:otherwise>
<xsl:copy-of select=$page"/>
</xsl:otherwise>
</xsl:choose>
...
<xsl:template mode="put-in-xhtml-ns" match="*">
<xsl:element name="{QName('http://www.w3.org/1999/xhtml', local-name(.))}">
<xsl:copy-of select="@*"/>
<xsl:apply-templates mode="#current"/>
</xsl:copy>
</xsl:template>

Yes that's pretty much it.  Instead of the QName constructor, you
could've used the namespace attribute on xsl:element. (also im
assuming the missing closing </xsl:element> is a typo)


Why not something simpler as just
<xsl:element name="
 {QName(if ($cond) then 'http://www.w3.org/1999/xhtml' else '', 'html')}">
 ...
</xsl:element>

It's up to you, I prefer the moded approach.


-- 
Andrew Welch
http://andrewjwelch.com

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