Connecting Tech Pros Worldwide Help | Site Map

XSL output option and <xsl:import>

Dormilich's Avatar
Moderator
 
Join Date: Aug 2008
Location: Leipzig, Germany
Posts: 3,629
#1: Jan 20 '09
Hi,

my goal is to have a stylesheet, where I can change the encoding attribute of the <xsl:output> element (one shall have utf-8 and the other latin-1). is there any way to set this via a parameter (or something) or do I have to call a separate file for every different output? I know I can change the original xsl file with a stylesheet, but that's more effort than making two files. I thought that I can maybe overwrite the original <xsl:output> element when using <xsl:import>, but I didn't find any notes on that in the net.

thanks
Moderator
 
Join Date: Mar 2006
Posts: 1,103
#2: Jan 20 '09

re: XSL output option and <xsl:import>


Depends on how you're running the transformation. If you're loading up the xsl in a document object before running it, the document can be changed before running. Similar to how people used to set parameters in javascript with xsl:
Expand|Select|Wrap|Line Numbers
  1. oNode = doc.SelectSingleNode("//xsl:output");
  2. oNode.setAttribute('encoding',value);
  3.  
Not aware of any easier way to do it.
Dormilich's Avatar
Moderator
 
Join Date: Aug 2008
Location: Leipzig, Germany
Posts: 3,629
#3: Jan 20 '09

re: XSL output option and <xsl:import>


I'm doing quite straight-of-the-book xsl transformation with PHP (ok, I made a class for the ease of handling). right now it is probably easier to use different files rather than making DOM change the attribute..... (it's an effort-gain thing)
Reply