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

RE: Passing a Map as parameter to XSLT.

Subject: RE: Passing a Map as parameter to XSLT.
From: "Michael Kay" <mike@xxxxxxxxxxxx>
Date: Fri, 3 Mar 2006 22:57:18 -0000
RE:  Passing a Map as parameter to XSLT.
> I want to pass a java.util.Map object to a XSLT as a parameter.

Why do you want to pass a java.util.Map, and if that's what you want to do,
why are you passing an org.w3c.dom.Document?

> Currently the way I am doing is:
> 1. Creating an org.w3c.dom.Document object in the format
>     <x:map>
>     <entry key="..." value="..."/>
>           ...
>     </x:map>
> 
> 2. I have defined a parameter in xslt
> <xsl:param name="XSLTParameter" />
> 
> 
> Now how do I access this map in the XSLT.

Your application has to tell the XSLT processor to use the document(1) as
the value of the parameter(2). The way you do this depends on your
processor. Look for a method called setParameter() or addParameter().

Then you access the parameter as $XSLTParameter.

 I am not able to access it.
> I was trying to use the key function as follows:
> 
> <xsl:key name="xsltParameterMap" match="document('')/*/map/entry" 
> use="@key"/>
> 

A key might be useful to find an entry within your map, but it isn't going
to help you access the map. Once you've loaded the document you can define a
key as

 <xsl:key name="xsltParameterMap" match="/*/map/entry" use="@key"/>

(though match="entry" will work equally well)

and then access a value with

key('xsltParameterMap', $requiredValue)

having made sure that $XSLTParameter is the context node.

Michael Kay
http://www.saxonica.com/

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.