[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: pass parameter to XSL

Subject: Re: pass parameter to XSL
From: "Mukul Gandhi" <gandhi.mukul@xxxxxxxxx>
Date: Wed, 20 Feb 2008 18:55:31 +0530
Re:  pass parameter to XSL
Hi Izaskun,
    If you are using JAXP to invoke the XSLT transformation, then you
can pass parameters to the stylesheet like following:

TransformerFactory tfactory = TransformerFactory.newInstance();
Transformer transformer = tfactory.newTransformer(xslSource);

transformer.setParameter("campo", "author");     //you set parameter, here
transformer.setParameter("moreParam", paramValue);

transformer.transform( ....

On Wed, Feb 20, 2008 at 6:44 PM,  <igutierrez027@xxxxxxxxxxxxx> wrote:
> Hello everybody:
>
> I am spanish student and I am doing my Project in my university and I
> need help about how to pass a parameter to a XSL.
>
> I have one interface doing in Java. The user gives me a variable that I
> take like String. And I want to pass this variable to a XSL stylesheet
> to use it, but I don't know how to do this. I'm using Oxygen to work
> with
> XSL.
>
> This is my stylesheet:
>
> author and book are tags of the xml file. I have give the values to de
> field and class parameters. But the user gives me strings in the
> interface.
>
>
> <?xml version="1.0" encoding="UTF-8"?>
> <xsl:stylesheet xmlns:xsl=http://www.w3.org/1999/XSL/Transform
>  version="1.0" xmlns:pepe="http://bibtexml.sf.net/">
>
>
> <xsl:param name="campo" >author</xsl:param>
>
> <xsl:param name="clase">book</xsl:param>
> <xsl:template match="/">
> <xsl:value-of
> select="pepe:file/ pepe:entry/*[name()=$clase]/*[name()=$campo]"/>
> </xsl:template>
> </xsl:stylesheet>
>
> How I can pass the strings to the stylesheet?
> Thank you for your help.
>
> Izaskun


-- 
Regards,
Mukul Gandhi

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2007 All Rights Reserved.