Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > XML > XSLT
Password Reminder
Register
| FAQ | Members List | Calendar | 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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
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
Reply With Quote
  #2 (permalink)  
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?
Reply With Quote
The Following User Says Thank You to samjudson For This Useful Post:
ilyaz (December 10th, 2010)
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


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



All times are GMT -4. The time now is 11:43 PM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.