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

XSLT2 variables / nodesets and their namespace

Subject: XSLT2 variables / nodesets and their namespace
From: Tom Schutzer-Weissmann <trmsw@xxxxxxxxxxx>
Date: Fri, 21 Jan 2005 11:51:33 +0000
css xmlns
Hi,

In XSLT 2, if you create a nodeset as a variable, is there any way to
make it inherit the stylesheet's default namespace?

My stylesheet creates a lot of these variables, which it either copies
straight to output, or processes. This is fine unless the stylesheet has
a default namespace - which is needed for the xhtml output to have a
namespace declaration.

ie:

<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  version="2.0"
  xmlns="http://www.w3.org/1999/xhtml"      <----- default breaks it
  >

If the default is set, the variables copies to output are decorated with
empty namespace declarations (xmlns=""), and the templates that process
the variables no longer do so. 

Putting a declaration in the variables worked, but I got errors in cases
that mixed the input and another variable and a hardcoded default, eg:

 <xsl:variable name="head">
      <xsl:copy-of select="$head/*"/>
      <xsl:copy-of select="head/*"/>
      <script src="product.js" xmlns="http://www.w3.org/1999/xhtml"/>
      <style href="product.css" xmlns="http://www.w3.org/1999/xhtml"/>
 </xsl:variable>

The only way that worked was to prefix all the tags in the variables:

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  xmlns:f="http://www.w3.org/1999/xhtml"
  xmlns="http://www.w3.org/1999/xhtml"
  version="2.0"
  exclude-result-prefixes="f"
  >
[...]
 <xsl:variable name="head">
      <xsl:copy-of select="$head/*"/>
      <xsl:copy-of select="f:head/*"/>
      <f:script src="product.js" xmlns="http://www.w3.org/1999/xhtml"/>
      <f:style href="product.css" xmlns="http://www.w3.org/1999/xhtml"/>
 </xsl:variable>

Which I don't like doing because I'm lazy and because it seems
unnecessary. Am I missing something?

Cheers,
Tom SW

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-2013 All Rights Reserved.