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

RE: Trax and how to pass parameters to

Subject: RE: Trax and how to pass parameters to
From: "Michael Kay" <mhk@xxxxxxxxx>
Date: Thu, 26 Feb 2004 09:39:29 -0000
xmlfilter parameters
You can't. There's a recent thread on the Saxon forum about this:

http://sourceforge.net/forum/forum.php?thread_id=1027851&forum_id=94027

The answer is, instead of generating your transformation as an XMLFilter,
use a SAXTransformerHandler. You can still pipeline transformations, and in
many ways the code is easier.

Other options:

(a) In Saxon 7.x, you can cast the XMLFilter to a net.sf.saxon.Filter, which
provides access to getTransformer().setParameter()

(b) Pass the parameter values down the pipeline so they arrive as part of
the source document

(c) Write a URIResolver to deliver the parameter values in response to a
call on document()

Michael Kay

# -----Original Message-----
# From: owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx [mailto:owner-xsl-
# list@xxxxxxxxxxxxxxxxxxxxxx] On Behalf Of Paul Tremblay
# Sent: 26 February 2004 07:52
# To: xsl-list
# Subject:  Trax and how to pass parameters to
# 
# Can anyone tell me how to pass parameters to Trax (javax) if you are
# using a filter? I have included my sample code below.
# 
# Note that I have actually compiled one stylesheet and passed a parameter
# to it, but I can't actually use the passed parameters in my chain below.
# 
# I asked this question on the Sun mailing list with no responses. It
# seems using XMLFilter is still kind of a black art!
# 
# Thanks
# 
# Paul
# 
# 
#     Templates stylesheet1 = tfactory.newTemplates(new
# StreamSource(xslID_1));
#     Transformer transformer1 = stylesheet1.newTransformer();
#     transformer1.setParameter("date", "works");
# 
#      // If one success, assume all will succeed.
#     if (tfactory.getFeature(SAXSource.FEATURE))
#     {
#       SAXTransformerFactory stf = (SAXTransformerFactory)tfactory;
#       XMLReader reader=null;
# 
#       // Use JAXP1.1 ( if possible )
#       try {
# 	  javax.xml.parsers.SAXParserFactory factory=
# 	      javax.xml.parsers.SAXParserFactory.newInstance();
# 	  factory.setNamespaceAware( true );
# 	  javax.xml.parsers.SAXParser jaxpParser=
# 	      factory.newSAXParser();
# 	  reader=jaxpParser.getXMLReader();
# 
#       } catch( javax.xml.parsers.ParserConfigurationException ex ) {
# 	  throw new org.xml.sax.SAXException( ex );
#       } catch( javax.xml.parsers.FactoryConfigurationError ex1 ) {
# 	  throw new org.xml.sax.SAXException( ex1.toString() );
#       } catch( NoSuchMethodError ex2 ) {
#       }
#       if( reader==null ) reader = XMLReaderFactory.createXMLReader();
# 
#       XMLFilter filter1 = stf.newXMLFilter(stylesheet1);
#       XMLFilter filter2 = stf.newXMLFilter(new StreamSource(xslID_2));
#       XMLFilter filter3 = stf.newXMLFilter(new StreamSource(xslID_3));
# 
# 
# 
# --
# 
# ************************
# *Paul Tremblay         *
# *phthenry@xxxxxxxxxxxxx*
# ************************
# 
#  XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list




 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


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-2013 All Rights Reserved.