XML Transformation question

E

Eta

Hi all,
I need to transform an XML input file throught Java. Use
javax.xml.transform package to do it.
The XSLT file need a PARAM but I don't know how pass its value to the
Transformer object.

Here the code who make the transformation:

Transformer transformer =factory.newTransformer(new StreamSource
("RUBRICA.xslt"));


transformer.transform(new StreamSource("RUBRICA.xml"),new StreamResult
("RUBRICA.txt"));


Its work fine but how can I pass a param value to the XSLT file??

Thanks in advance,

and sorry for my bad english.

Ciao,

Eta
 
M

Murray

Transformer transformer =factory.newTransformer(new StreamSource
("RUBRICA.xslt"));


transformer.transform(new StreamSource("RUBRICA.xml"),new StreamResult
("RUBRICA.txt"));


Its work fine but how can I pass a param value to the XSLT file??

Thanks in advance,

transformer.setParameter("paramName", paramValue);

Then in your XSLT

<xsl:param name="paramName"/> or alternatively <xsl:param
name="debug">defaultValue</xsl:param>

which essentially makes it globally available using $paramName
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,262
Messages
2,571,043
Members
48,769
Latest member
Clifft

Latest Threads

Top