Well recently I wanted to do the same, but I use saxon-he 9.5 where some features are not present comparing to 9.1. ( they are present in PE/EE versions in http://saxonica.com/documentation/html/extensibility/ but  yeah…nobody wants to pay).


However there is a workaround which will also work in 9.1


Convert a map to two list: keys and values (use LinkedHashMap to maintain correct order)

Here is a snippet from my last transformation:



    <xsl:param name="headersNames" select="()"/>

    <xsl:param name="headersValues" select="()"/>


    <xsl:template match="/">

        <xsl:element name="soap-env:Envelope" namespace="http://schemas.xmlsoap.org/soap/envelope/">

            <xsl:element name="soap-env:Header">

                <xsl:namespace name="eh" select="'http://someNamespace'"/>

                <xsl:for-each select="$headersNames">

                    <xsl:element name="eh:{.}" inherit-namespaces="yes">

                        <xsl:variable name="pos" select="fn:position()"/>

                        <xsl:value-of select="$headersValues[fn:position() = $pos]"/>




            <xsl:element name="soap-env:Body">

                <xsl:copy-of select="*" copy-namespaces="no"/>





Hope it helps.


PS. You can always upgrade and   pay and use promising xslt 3.0 features like map.

Or write custom http://saxonica.com/documentation/html/extensibility/integratedfunctions/

which is still for free.




Mateusz Nowakowski


From: alan.painter@hsbc.fr [mailto:alan.painter@hsbc.fr]
Sent: 20 września 2013 07:57
To: saxon-help@lists.sourceforge.net
Subject: [saxon] ghosts of saxon past (saxon Help on the magic incantation for setParameter(new QName("map"), ArbitraryJavaObject) ?



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.