Alan, you didn't finish your sentence where I think you were going to explain what goes wrong.

Memories of 9.1 are fading fast, but I think you should be able to wrap the HashMap in an instance of net.sf.saxon.value.ObjectValue, and pass that as the parameter. I would also have expected you to be able to pass the HashMap directly, but passing instances of Java's collection classes is a bit fragile because Saxon sometimes converts them to an XDM sequence or (in recent releases) an XDM map.

Michael Kay

On 20 Sep 2013, at 06:57, wrote:


In saxon (saxon-B), trying to pull information out of a Java Map.

I'm able to retrieve such a map from a java static method that returns a map, getMap(), as in this stylesheet:

<xsl:stylesheet version="2.0"


                exclude-result-prefixes="xsl class map mapGetter">

    <xsl:param name="map" as="class:java.util.Map" required="no" select="mapGetter:getMap()"/>

    <xsl:output method="xml" indent="yes"/>

    <xsl:template name="writeMapContents">
            <xsl:for-each select="map:keySet($map)">
                <mapEntry key="{.}" value="{map:get($map, .)}"/>


However, when I want to remove the default value from the stylesheet parameter and pass the map as a parameter, as in:

    <xsl:param name="map" as="class:java.util.Map" required="yes" />

with this java code

public static void main(String args[]) throws IOException, SaxonApiException {
        final Processor processor = new Processor(false);
        final XsltCompiler compiler = processor.newXsltCompiler();
        final XsltExecutable compiledXslt = compiler.compile(new StreamSource("ReturnsMapContents.xslt"));

        final XsltTransformer transformer = compiledXslt.load();

        final Serializer serializer = new Serializer();

        final Map<String, String> map = new HashMap<String, String>();
        map.put("keyOne",   "valueOne");
        map.put("keyTwo",   "valueTwo");
        map.put("keyThree", "valueThree");

        transformer.setParameter(new QName("map"), *** How to create an XdmValue from a Java Map object? ***);
        transformer.setInitialTemplate(new QName("writeMapContents"));


Thanks for any help and apologies for using an old version (with the feeble disclaimer that it is tried and true)

Ensemble adoptons des gestes responsables : N'imprimez ce mail que si necessaire. Les informations contenues dans ce message et les pieces jointes (ci-apres denomme le message) sont confidentielles et peuvent etre couvertes par le secret professionnel. Si vous n'etes pas le destinataire de ce message, il vous est interdit de le copier, de le faire suivre, de le divulguer ou d'en utiliser tout ou partie. Si vous avez recu ce message par erreur, nous vous remercions de le supprimer de votre systeme, ainsi que toutes ses copies, et d'en avertir immediatement HSBC France et ses filiales par message de retour. Il est impossible de garantir que les communications par messagerie electronique arrivent en temps utile, sont securisees ou denuees de toute erreur, alteration, falsification ou virus. En consequence, HSBC France et ses filiales declinent toute responsabilite du fait des erreurs, alterations, falsifications ou omissions qui pourraient en resulter. Consider the environment before printing this mail. The information contained in this e-mail is confidential. It may also be legally privileged. If you are not the addressee you may not copy, forward, disclose or use any part of it. If you have received this message by error, please delete it and all copies from your system and notify the sender immediately by return e-mail. E-mail communications cannot be guaranteed to be timely secure, error or virus-free. The sender does not accept liability for any errors or omissions which arise as a result.------------------------------------------------------------------------------
LIMITED TIME SALE - Full Year of Microsoft Training For Just $49.99!
1,500+ hours of tutorials including VisualStudio 2012, Windows 8, SharePoint
2013, SQL 2012, MVC 4, more. BEST VALUE: New Multi-Library Power Pack includes
Mobile, Cloud, Java, and UX Design. Lowest price ever! Ends 9/20/13.
saxon-help mailing list archived at