xsl-list
[Top] [All Lists]

Re: [xsl] pass parameter to XSL

2008-02-20 06:25:59
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(_at_)ikasle(_dot_)ehu(_dot_)es> 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

--~------------------------------------------------------------------
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>
--~--

<Prev in Thread] Current Thread [Next in Thread>