RSS Forums RSS
Please support our XML, XSLT and XPATH advertiser: Programming Forums
Views: 419 | Replies: 0 | Thread Tools  Display Modes
Reply
Join Date: Nov 2008
Posts: 3
Reputation: michux is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
michux michux is offline Offline
Newbie Poster

Passing XML (node) parameters to XSLT in Saxon

  #1  
Nov 13th, 2008
Hi,

Here is my use case
- I have a Java app from which I'm calling an XSLT to transform XML into HTML
- The XSLT is a file in JAR
- The XML is passed as a stream from another application

Now, the problem is:
- I need to pass another XML document to this XSLT, from a different application and then access it as a node in XSLT

Here are the alternatives I can think of :
1. Using the document() xslt function with XML as stream.
I tried doing it with document() function but it doesn't seem to work in Saxon when the document has to be passed as stream. Here is my moaning: http://groups.google.com/group/XSLT/...2442738196933e

2. Using the document() xslt function by refering to an external document (using REST)
I don't really like that idea, as I'd have to expose the service for providing additional data as REST (lots of issues with that, especially permissioning is tricky)

3. Passing the XML documents as parameters to XSLT using something like:

XsltTransformer trans = comp.compile(new StreamSource(MyTransformerClass.getResourceAsStream(XSLT_FILE)).load();
trans.setParameter(new QName(paramName), new XdmAtomicValue(params.get(paramName)));
but with using a XdmNode instead of the XdmAtomicValue.

A few issues with this solution:
- I'm not sure how create an XdmNode - it does not have a public constructor (but probably there is a way, more investigation is needed here)
- More important: not sure if I can use parameters are nodes in XSLT, so that I could declare something like:
<xsl:param name="operatingSystems" as="xs:node" required="yes" />
and then use XPath like $operatingSystems/system[@name='Linux']/defaultHomeDirectory

4. Adding the additional XML at the end of the source XML for my XSLT.

A VERY very ugly solution which just works....

I'm be very glad to hear your ideas!

michuk
AddThis Social Bookmark Button
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.



Other Threads in the XML, XSLT and XPATH Forum
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes
Forums | Blogs | Tutorials | Code Snippets | Whitepapers | RSS Feeds | Advertising
All times are GMT -4. The time now is 9:13 pm.
Newsletter Archive - Sitemap - Privacy Statement - Acceptable Use Policy - Contact Us
Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC