[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] XSLT2 variables / nodesets and their namespace
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
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|