[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: default or no namespace

Subject: Re: default or no namespace
From: Andrew Welch <andrew.j.welch@xxxxxxxxx>
Date: Tue, 28 Dec 2010 10:56:13 +0000
Re:  default or no namespace
On 28 December 2010 07:02, ac <ac@xxxxxxxxxxxxx> wrote:
> 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
...
> 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:otherwise>
> <html>

You can't do either because the namespace is applied at the xml level,
not at the xslt level.  In other words, the default namespace would
only be changed for the children of <html> in the xml that is your
stylesheet, not in the constructed result.

The usual technique is to have an identity transform as the last step
to put the elements into the xhtml namespace (use modes if you want to
keep it all in a single transform).


--
Andrew Welch
http://andrewjwelch.com

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2011 All Rights Reserved.