xsl-list
[Top] [All Lists]

RE: [xsl] initial template parameters

2010-03-18 09:55:13
Or you would have to keep a package folder structure  like most programming 
languages do and even in javascript it is an adopted approach to create 
namespace like structures to have no clashes in variable names.


Com.mycompany.xslt.pdf
  - content2pdf.xslt
  
      <xsl:param name="com_mycompany_xslt_pdf_content2pdf_param1" 
select="'defaultvalue'"/>
    

Com.mycompany.xslt.html
  -content2html.xslt
      <xsl:param name="com_mycompany_xslt_html_content2html_param1" 
select="'anotherdefaultvalue'"/>

So if you would include both xslt's in another main.xslt you would at least 
have no confusion about parameters.

I have to say I don't follow this approach myself because I can oversee and am 
the only maintainer of the stylesheets.  But if you were to write xslt's which 
would be used by 3rd parties this might not be such a bad approach.

What do you all think?

Kind regards,
Robby

-----Original Message-----
From: Max Toro [mailto:maxtoroq(_at_)gmail(_dot_)com] 
Sent: Thursday, March 18, 2010 3:40 PM
To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
Subject: Re: [xsl] initial template parameters

more portable you can have a simple stylesheet with just a named template
that initialises its parameters from global parameters and then xsl:imports
the original stylesheet. this means you need a wrapper stylesheet for any
top level named template that you want to use, but most stylesheets don't
have _so_ many choices for initial named template.

Yes, I though of this solution too, but seems like too much trouble.

About stylesheets not having many entry point choices, I think this
limitation helps to enforce that stylesheets have a single purpose,
while they could have many purposes based on related functionality.
Like object-oriented languages, you can call a class constructor
passing parameters (global parameters in XSLT) and then call a method
passing other parameters (initial template parameters).
--
Max

2010/3/18 David Carlisle <davidc(_at_)nag(_dot_)co(_dot_)uk>:
On 18/03/2010 14:13, Max Toro wrote:
more portable you can have a simple stylesheet with just a named template
that initialises its parameters from global parameters and then xsl:imports
the original stylesheet. this means you need a wrapper stylesheet for any
top level named template that you want to use, but most stylesheets don't
have _so_ many choices for initial named template.
The only solution I can think of is using extension methods to pull
the parameters from the environment, something like this:

<xsl:param name="color" value="(ext:get-parameter('color'), 'red')[1]"
as="xs:string"/>



David

________________________________________________________________________
The Numerical Algorithms Group Ltd is a company registered in England
and Wales with company number 1249803. The registered office is:
Wilkinson House, Jordan Hill Road, Oxford OX2 8DR, United Kingdom.

This e-mail has been scanned for all viruses by Star. The service is
powered by MessageLabs.
________________________________________________________________________

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: 
<mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--



--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--


--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--