Subject: Re: [xsl] default or no namespace From: Andrew Welch <andrew.j.welch@xxxxxxxxx> Date: Tue, 28 Dec 2010 15:37:03 +0000 |
On 28 December 2010 14:59, ac <ac@xxxxxxxxxxxxx> 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
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] default or no namespace, ac | Thread | Re: [xsl] default or no namespace, ac |
Re: [xsl] default or no namespace, ac | Date | [xsl] Avoiding boneheaded mistakes , David Sewell |
Month |