package com.googlecode.totallylazy.xml;

import com.googlecode.totallylazy.Callable1;
import com.googlecode.totallylazy.Mapper;
import com.googlecode.totallylazy.Xml;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import org.w3c.dom.Text;

import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

public class XPathLookups {
    private static final Map<String, Callable1<String, String>> lookups = new ConcurrentHashMap<String, Callable1<String, String>>();

    @XPathFunction("lookup")
    public static NodeArrayList lookup(String name, NodeList types) {
        return new NodeArrayList<Text>(Xml.sequence(types).map(lookup(lookups.get(name))));
    }

    private static Mapper<Node, Text> lookup(final Callable1<String, String> data) {
        return new Mapper<Node, Text>() {
            @Override
            public Text call(Node node) throws Exception {
                return XPathFunctions.createText(node, data.call(node.getTextContent()));
            }
        };
    }

    public static void setLookup(String name, Callable1<String, String> lookup){
        lookups.put(name, lookup);
    }

}

@@ -79,16 +79,59 @@
 lable1;%0A
+import com.googlecode.totallylazy.Callers;%0A
 import c
@@ -606,19 +606,19 @@
 odeList 
-typ
+nod
 es) %7B%0A  
@@ -671,11 +671,11 @@
 nce(
-typ
+nod
 es).
@@ -710,24 +710,144 @@
 )));%0A    %7D%0A%0A
+    public static String lookup(String name, String text)%7B%0A        return Callers.call(lookups.get(name), text);%0A    %7D%0A%0A
     private 

Add an accessor for easy access to lookups