Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XSLT
| Search | Today's Posts | Mark Forums Read
XSLT General questions and answers about XSLT. For issues strictly specific to the book XSLT 1.1 Programmers Reference, please post to that forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XSLT section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old December 10th, 2010, 04:36 PM
Authorized User
 
Join Date: Dec 2010
Posts: 16
Thanks: 5
Thanked 0 Times in 0 Posts
Default Can I pass parameter from command line to use inside transform?

I am using Saxon to do XML-to-XML conversion from command line. Is there any way of passing a parameter from the command line to be used by the transform? For instance, suppose I have the following segment:

Code:
<xsl:param name="index" select="1000"/>

<xsl:template match="/">
    <xsl:for-each select=...
	<container><xsl:value-of select="position() + $index"/></container>
...
So this would be generating XML like

Code:
<container>1001</container>
<container>1002</container>
<container>1003</container>
...
Now suppose I want to pass the starting value for index as a parameter so that, for instance, for the 1st file it starts from 1000, for the second from 1500 etc. Can I do it using Saxon? What would be the proper XSLT syntax to use the passed value?

Thanks much
 
Old December 10th, 2010, 05:17 PM
samjudson's Avatar
Friend of Wrox
Points: 8,687, Level: 40
Points: 8,687, Level: 40 Points: 8,687, Level: 40 Points: 8,687, Level: 40
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Aug 2007
Location: Newcastle, , United Kingdom.
Posts: 2,128
Thanks: 1
Thanked 189 Times in 188 Posts
Default

You don't need to change your XSLT - using <xsl:param> is how you create parameters you pass in to stylesheets.

Simply follow the instructions here: http://www.saxonica.com/documentatio...ommandline.xml

java net.sf.saxon.Transform -s:source -xsl:stylesheet -o:output index=1000
__________________
/- Sam Judson : Wrox Technical Editor -/

Think before you post: What have you tried?
The Following User Says Thank You to samjudson For This Useful Post:
ilyaz (December 10th, 2010)




Similar Threads
Thread Thread Starter Forum Replies Last Post
Chapter 5 - Command Line Error. Invalid parameter dbaechtel BOOK: Professional SharePoint 2007 Development ISBN: 978-0-470-11756-9 0 August 11th, 2009 11:00 AM
how to pass a control parameter and process a return parameter in sqldatasource jayshankar ASP.NET 2.0 Basics 1 January 1st, 2009 10:18 AM
Referencing the line before in a transform lemon XSLT 2 September 13th, 2007 06:02 AM
How to pass parameter value to CR SQL Command vijaykumartaduri BOOK: Professional Crystal Reports for VS.NET 3 July 31st, 2007 12:13 AM
Transform multilined element value to one line ypomonh XSLT 2 April 27th, 2007 08:32 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.