xsl-list
[Top] [All Lists]

Subject: RE: [xsl] XML fragment as a param ?

2005-11-15 10:30:47
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(_dot_)xml(_dot_)transform(_dot_)stream(_dot_)StreamSource(_at_)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.



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