[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: Wed, 16 Nov 2005 09:27:31 +0000
subject re
Fraser>recap: I'm trying to pass XML through to a param in my stylesheet. I'm using Xalan.
Fraser>
Fraser>When I do this :-
Fraser>
Fraser>transformer.setParameter(param.name, param.value);
Fraser>
Fraser>where param.name and param.value are both Strings and contain - "inboundXML" Fraser>and "<Numbers><Odds><One>1</One>... "
Fraser>
Fraser>I get this (almost correct but no cigar :-) :-
Fraser>
Fraser><rootContainer>&lt;Numbers&gt;&lt:Odds&gt;&lt;One&gt;1.....</rootContainer>
Fraser>


Nick,

thanks for your helpful response.

As you point out, if the XML I wanted to set as the param was already in a DOM I could indeed pass the DOM itself or a node selected from it. Unfortunately it isn't and the amount of XML is large so I didn't really want to have to load up a DOM simply to pass it through to an XSLT processor (I do use this technique in other places but only if the the data is already conveniently packaged or the amount of data is small).

Yes, I had thought of setting the output escaping, but am pretty reluctant to take that route for the reasons you mention (it is quite likely that the XML I'm passing in contains content that needs to be escaped).

Fraser> transformer.setParameter(param.name, new StreamSource(new
Fraser> StringReader(param.value)));
Fraser>
Fraser> but unfortunately all that gave me was :-
Fraser>
Fraser>
Fraser> <rootContainer>javax.xml.transform.stream.StreamSource@4c6ca8b6</rootContainer>


Nick> Which is also correct (in your environment) as that is the string
Nick> representation of the StreamSource: clearly the processor you are using
Nick> doesn't support using a StreamSource as a parameter, and so took the
Nick> result of that object's toString() method.


Oh, ok, thanks for clearing that up.

The 'HowTo' on exslt:node-set suggest that it can create a node set from a text() node, but I'm not sure a 'string' parameter (especially one that has been 'escaped') qualifies. In any event I couldn't get it to co-operate.

I have written a URI Resolver so I can pass my data in through the document() function, but I wanted cake (and eat it) by being able to have 2 options to provide this XML to the stylesheet (just greedy I guess :-)

Thanks

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.