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

Subject: RE: XML fragment as a param ?

Subject: Subject: RE: XML fragment as a param ?
From: "Fraser Goffin" <goffinf@xxxxxxxxxxx>
Date: Tue, 15 Nov 2005 17:30:47 +0000
transformer and param
recap: I'm trying to pass XML through to a param in my stylesheet. I'm using Xalan.

When I do this :-

transformer.setParameter(param.name, param.value);

where param.name and param.value are both Strings and contain - "inboundXML" and "<Numbers><Odds><One>1</One>... "

and when the stylesheet looks like this :-

...
 <xsl:param name="inboundXML" select="/"/>
 <xsl:template match="/">
   <rootContainer>
       <xsl:copy-of select="$inboundXML"/>
   </rootContainer>
 </xsl:template>
...

I get this (almost correct but no cigar :-) :-

<rootContainer>
       &lt;Numbers&gt;&lt:Odds&gt;&lt;One&gt;1.....
</rootContainer>


Previously Michael commented :-


Michael> Xalan, like Saxon, uses the setParameter() method on the JAXP javax.xml.transform.Transformer class.

Michael> However, the JAXP API doesn't actually say what kind of object you can
Michael> supply as the value. Most products will allow you to supply a DOM node (they
Michael> may restrict which DOM implementations you are allowed to use). Saxon allows
Michael> you to supply any JAXP Source object, so if you supply a StreamSource
Michael> containing raw XML, the XML will be parsed and the stylesheet will see the
Michael> resulting document node as the parameter value.


That's interesting I thought so I tried doing this (admittedly I'm not using Saxon (sorry Michael) so no guarantees) :-

transformer.setParameter(param.name, new StreamSource(new StringReader(param.value)));

but unfortunately all that gave me was :-

<rootContainer>javax.xml.transform.stream.StreamSource@4c6ca8b6</rootContainer>

I have tried using the exslt:node-set function, but I'm not sure I got it correct.

I would welcome any suggestions and perhaps a small example ?

Cheers

Fraser.

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.