Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


Re: [xsl] passing several external arguments to the spreadsheet

From: Wendell Piez <wapiez@------------.--->
To: xsl-list@-----.------------.---
Date: 9/2/2009 2:36:00 PM
Hi,

Another alternative is to use an external configuration file to store 
the list of languages as an XML document, and call that in from your 
main stylesheet using the document() function.

This is probably easier if your list of languages becomes long and/or 
you need to control it in some way (for example, validating it 
against a list of known languages).

Using a runtime parameter may be easier if you need control 
dynamically at runtime, you don't need the list to persist between 
runs, and your list is short.

The two approaches can also be combined. For example, your external 
list can control what languages are allowed, while the runtime 
parameter gives those that will actually be used (values in the 
parameter that don't appear in the external list can be ignored).

Finally, note that tokenize() is not available in unextended XSLT 
1.0. If you can't use XSLT 2.0 or a 1.0 extension function you'll 
need to work around this limitation.

Cheers,
Wendell

At 10:21 AM 9/2/2009, you wrote:
>Manuel Souto Pico wrote:
>
>>Is it possible to run something like that using the param option 
>>(or, even better, to do it in the editor)? (in capitals for clarity)
>>$ java -jar path/to/saxon9.jar LANG=en,fr,pt input.xml 
>>spreadsheet.xsl > output.xml
>>I guess it must be something like that, but then, how do I get 
>>those 3 or n parameters into the spreadsheet? If it was only one 
>>parameter i would get it with
>><xsl:param name="lang"/>
>>but as there are more than one, I guess I should put them in a kind 
>>of array and then do a for-each?
>
>I think you should be able to pass in a string value as the 
>parameter and then use the tokenize function to split it up into a 
>sequence of lang values e.g.
>   <xsl:param name="lang"/>
>   <xsl:variable name="languages" select="tokenize($lang, ',')"/>
>
>   <xsl:template match="xliff">
>     <xsl:copy>
>       <xsl:variable name="file" select="file"/>
>       <xsl:for-each select="$languages">
>         <xsl:apply-templates select="$file">
>           <xsl:with-param name="lang" select="."/>
>         </xsl:apply-templates>
>       </xsl:for-each>
>     </xsl:copy>
>   </xsl:template>
>
>   <xsl:template match="file">
>     <xsl:param name="lang"/>
>     <xsl:copy>
>       <xsl:attribute name="lang" select="$lang"/>
>       <xsl:copy-of select="node()"/>
>     </xsl:copy>
>   </xsl:template>


======================================================================
Wendell Piez                            mailto:wapiez@m...
Mulberry Technologies, Inc.                http://www.mulberrytech.com
17 West Jefferson Street                    Direct Phone: 301/315-9635
Suite 207                                          Phone: 301/315-9631
Rockville, MD  20850                                 Fax: 301/315-8285
----------------------------------------------------------------------
   Mulberry Technologies: A Consultancy Specializing in SGML and XML
======================================================================


--~------------------------------------------------------------------
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@l...>
--~--



transparent
Print
Mail
Like It
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent