Index: applications/editors/josm/plugins/tag2link/resources/tag2link_sources.xml
===================================================================
--- applications/editors/josm/plugins/tag2link/resources/tag2link_sources.xml	(revision 26917)
+++ applications/editors/josm/plugins/tag2link/resources/tag2link_sources.xml	(revision 26918)
@@ -24,9 +24,9 @@
        <rule>
            <condition k="website" />
-           <link name="View website" href="{v}" />
+           <link name="View website" href="%v%" />
        </rule>
        <rule>
            <condition k="url" />
-           <link name="View URL" href="{v}" />
+           <link name="View URL" href="%v%" />
        </rule>
     </source>
@@ -35,5 +35,5 @@
 	   <rule>
 	       <condition k="wikipedia(?::([\p{Lower}]{2,}))?" />
-           <link name="View {name} article" href="http://{k.1:en}.wikipedia.org/wiki/{v}" />
+           <link name="View %name% article" href="http://%k.1:en%.wikipedia.org/wiki/%v%" />
 	   </rule>
 	</source>
@@ -44,5 +44,5 @@
        <rule>
            <condition k="ref:sandre" v="[A-Z0-9-]{8}" />
-           <link name="View {name} sheet of river" href="http://services.sandre.eaufrance.fr/Courdo/Fiche/client/fiche_courdo.php?CdSandre={v}" />
+           <link name="View %name% sheet of river" href="http://services.sandre.eaufrance.fr/Courdo/Fiche/client/fiche_courdo.php?CdSandre=%v%" />
        </rule>
     </source>
@@ -52,35 +52,35 @@
            <condition k="admin_level" v="8"/>
            <condition k="ref:INSEE" v="(\p{Digit}{2})(\p{Digit}{3})" id="ref"/>
-           <link name="View {name} municipality sheet" href="http://www.insee.fr/fr/methodes/nomenclatures/cog/fichecommunale.asp?codedep={ref.v.1}&amp;codecom={ref.v.2}" />
+           <link name="View %name% municipality sheet" href="http://www.insee.fr/fr/methodes/nomenclatures/cog/fichecommunale.asp?codedep=%ref.v.1%&amp;codecom=%ref.v.2%" />
        </rule>
        <rule>
            <condition k="political_division" v="FR:canton"/>
            <condition k="ref:INSEE" v="(\p{Digit}{2})(\p{Digit}{2})" id="ref"/>
-           <link name="View {name} map of municipalities" href="http://www.insee.fr/fr/methodes/nomenclatures/cog/carte_comcan.asp?codecan={ref.v}" />
-           <link name="View {name} list of municipalities" href="http://www.insee.fr/fr/methodes/nomenclatures/cog/comcan.asp?codedep={ref.v.1}&amp;codecan={ref.v.2}" />
+           <link name="View %name% map of municipalities" href="http://www.insee.fr/fr/methodes/nomenclatures/cog/carte_comcan.asp?codecan=%ref.v%" />
+           <link name="View %name% list of municipalities" href="http://www.insee.fr/fr/methodes/nomenclatures/cog/comcan.asp?codedep={ref.v.1}&amp;codecan=%ref.v.2%" />
        </rule>
        <rule>
            <condition k="admin_level" v="7"/>
            <condition k="ref:INSEE" v="(\p{Digit}{2})(\p{Digit}{1})" id="ref"/>
-           <link name="View {name} map of cantons" href="http://www.insee.fr/fr/methodes/nomenclatures/cog/carte_canarr.asp?codearr={ref.v}" />
-           <link name="View {name} list of cantons" href="http://www.insee.fr/fr/methodes/nomenclatures/cog/canarr.asp?codedep={ref.v.1}&amp;codearr={ref.v.2}" />
+           <link name="View %name% map of cantons" href="http://www.insee.fr/fr/methodes/nomenclatures/cog/carte_canarr.asp?codearr=%ref.v%" />
+           <link name="View %name% list of cantons" href="http://www.insee.fr/fr/methodes/nomenclatures/cog/canarr.asp?codedep=%ref.v.1%&amp;codearr=%ref.v.2%" />
        </rule>
        <rule>
            <condition k="admin_level" v="6"/>
            <condition k="ref:INSEE" v="\p{Digit}{2}" id="ref"/>
-           <link name="View {name} map of arrondissements" href="http://www.insee.fr/fr/methodes/nomenclatures/cog/carte_arrdep.asp?codedep={ref.v}" />
-           <link name="View {name} list of arrondissements" href="http://www.insee.fr/fr/methodes/nomenclatures/cog/arrdep.asp?codedep={ref.v}" />
+           <link name="View %name% map of arrondissements" href="http://www.insee.fr/fr/methodes/nomenclatures/cog/carte_arrdep.asp?codedep=%ref.v%" />
+           <link name="View %name% list of arrondissements" href="http://www.insee.fr/fr/methodes/nomenclatures/cog/arrdep.asp?codedep=%ref.v%" />
        </rule>
        <rule>
            <condition k="admin_level" v="4"/>
            <condition k="ref:INSEE" v="\p{Digit}{2}" id="ref"/>
-           <link name="View {name} map of departments" href="http://www.insee.fr/fr/methodes/nomenclatures/cog/carte_depreg.asp?codereg={ref.v}" />
-           <link name="View {name} list of departments" href="http://www.insee.fr/fr/methodes/nomenclatures/cog/depreg.asp?codereg={ref.v}" />
+           <link name="View %name% map of departments" href="http://www.insee.fr/fr/methodes/nomenclatures/cog/carte_depreg.asp?codereg=%ref.v%" />
+           <link name="View %name% list of departments" href="http://www.insee.fr/fr/methodes/nomenclatures/cog/depreg.asp?codereg=%ref.v%" />
        </rule>
        <rule>
            <condition k="admin_level" v="2"/>
            <condition k="name" v="France*"/>
-           <link name="View {name} map of regions" href="http://www.insee.fr/fr/methodes/nomenclatures/cog/carte_regions.asp" />
-           <link name="View {name} list of regions" href="http://www.insee.fr/fr/methodes/nomenclatures/cog/region.asp" />
+           <link name="View %name% map of regions" href="http://www.insee.fr/fr/methodes/nomenclatures/cog/carte_regions.asp" />
+           <link name="View %name% list of regions" href="http://www.insee.fr/fr/methodes/nomenclatures/cog/region.asp" />
        </rule>
     </source>
Index: applications/editors/josm/plugins/tag2link/src/org/openstreetmap/josm/plugins/tag2link/Tag2LinkRuleChecker.java
===================================================================
--- applications/editors/josm/plugins/tag2link/src/org/openstreetmap/josm/plugins/tag2link/Tag2LinkRuleChecker.java	(revision 26917)
+++ applications/editors/josm/plugins/tag2link/src/org/openstreetmap/josm/plugins/tag2link/Tag2LinkRuleChecker.java	(revision 26918)
@@ -18,6 +18,4 @@
 import java.util.ArrayList;
 import java.util.Collection;
-import java.util.HashSet;
-import java.util.Set;
 
 import org.openstreetmap.josm.data.osm.OsmPrimitive;
@@ -48,7 +46,11 @@
                 EvalResult eval = rule.evaluates(p);
                 if (eval.matches()) {
-                    Set<String> links = new HashSet<String>();
-                    for (MatchingTag tag : eval.matchingTags) {
-                        
+                    for (Link link : rule.links) {
+                    	Link copy = new Link(link);
+                    	copy.name = copy.name.replaceAll("%name%", source.name);
+                    	MatchingTag firstTag = eval.matchingTags.iterator().next();
+                    	copy.url = copy.url.replaceAll("%k%", firstTag.key)
+                    			           .replaceAll("%v%", firstTag.value);
+                    	result.add(copy);
                     }
                 }
Index: applications/editors/josm/plugins/tag2link/src/org/openstreetmap/josm/plugins/tag2link/action/OpenLinkAction.java
===================================================================
--- applications/editors/josm/plugins/tag2link/src/org/openstreetmap/josm/plugins/tag2link/action/OpenLinkAction.java	(revision 26917)
+++ applications/editors/josm/plugins/tag2link/src/org/openstreetmap/josm/plugins/tag2link/action/OpenLinkAction.java	(revision 26918)
@@ -10,4 +10,5 @@
 import org.openstreetmap.josm.tools.OpenBrowser;
 
+@SuppressWarnings("serial")
 public class OpenLinkAction extends JosmAction implements Tag2LinkConstants {
 
@@ -15,5 +16,5 @@
     
     public OpenLinkAction(Link link) {
-        super(tr(link.name), ICON_16, tr("Launch browser with information about the selected object"), null, true);
+        super(tr(link.name), ICON_24, tr("Launch browser with information about the selected object"), null, true);
         this.url = link.url;
     }
Index: applications/editors/josm/plugins/tag2link/src/org/openstreetmap/josm/plugins/tag2link/data/Link.java
===================================================================
--- applications/editors/josm/plugins/tag2link/src/org/openstreetmap/josm/plugins/tag2link/data/Link.java	(revision 26917)
+++ applications/editors/josm/plugins/tag2link/src/org/openstreetmap/josm/plugins/tag2link/data/Link.java	(revision 26918)
@@ -4,13 +4,26 @@
     public String name;
     public String url;
+    
+    public Link(String name, String url) {
+    	this.name = name;
+    	this.url = url;
+    }
+    
+    public Link(Link link) {
+    	this(link.name, link.url);
+    }
+    
     private boolean containsParams(String s) {
         return s.matches("[^{}]*{[^{}]*}[^{}]*");
     }
+    
     public boolean nameContainsParams() {
         return containsParams(name);
     }
+    
     public boolean urlContainsParams() {
         return containsParams(url);
     }
+    
     public boolean containsParams() {
         return nameContainsParams() || urlContainsParams();
Index: applications/editors/josm/plugins/tag2link/src/org/openstreetmap/josm/plugins/tag2link/data/Rule.java
===================================================================
--- applications/editors/josm/plugins/tag2link/src/org/openstreetmap/josm/plugins/tag2link/data/Rule.java	(revision 26917)
+++ applications/editors/josm/plugins/tag2link/src/org/openstreetmap/josm/plugins/tag2link/data/Rule.java	(revision 26918)
@@ -17,4 +17,13 @@
         public String value;
         public final Map<String, String> params = new HashMap<String, String>();
+        public MatchingTag(String key, String value) {
+        	this.key = key;
+        	this.value = value;
+        }
+        public void addParams(Matcher m, String prefix) {
+    		for (int i = 1; i<=m.groupCount(); i++) {
+    			this.params.put(prefix+i, m.group(i));
+    		}
+        }
     }
     
@@ -31,7 +40,21 @@
         for (Condition c : conditions) {
             for (String key : tags.keySet()) {
-                Matcher m = c.keyPattern.matcher(key);
-                if (m.matches()) {
-                    
+                Matcher keyMatcher = c.keyPattern.matcher(key);
+                if (keyMatcher.matches()) {
+                	String idPrefix = c.id == null ? "" : c.id+".";
+            		MatchingTag tag = new MatchingTag(key, tags.get(key));
+            		tag.addParams(keyMatcher, idPrefix+"k.");
+                	boolean matchingTag = true;
+                	if (c.valPattern != null) {
+                		Matcher valMatcher = c.valPattern.matcher(tag.value);
+                		if (valMatcher.matches()) {
+                			tag.addParams(valMatcher, idPrefix+"v.");
+                		} else {
+                			matchingTag = false;
+                		}
+                	}
+                	if (matchingTag) {
+                		result.matchingTags.add(tag);
+                	}
                 }
             }
Index: applications/editors/josm/plugins/tag2link/src/org/openstreetmap/josm/plugins/tag2link/data/Source.java
===================================================================
--- applications/editors/josm/plugins/tag2link/src/org/openstreetmap/josm/plugins/tag2link/data/Source.java	(revision 26917)
+++ applications/editors/josm/plugins/tag2link/src/org/openstreetmap/josm/plugins/tag2link/data/Source.java	(revision 26918)
@@ -5,5 +5,9 @@
 
 public class Source {
-    public String name;
+    public final String name;
     public final Collection<Rule> rules = new ArrayList<Rule>();
+
+    public Source(String name) {
+		this.name = name;
+	}
 }
Index: applications/editors/josm/plugins/tag2link/src/org/openstreetmap/josm/plugins/tag2link/io/SourcesReader.java
===================================================================
--- applications/editors/josm/plugins/tag2link/src/org/openstreetmap/josm/plugins/tag2link/io/SourcesReader.java	(revision 26917)
+++ applications/editors/josm/plugins/tag2link/src/org/openstreetmap/josm/plugins/tag2link/io/SourcesReader.java	(revision 26918)
@@ -126,5 +126,5 @@
 
     private Source parseSource() throws XMLStreamException {
-        Source source = new Source();
+        Source source = new Source(parser.getAttributeValue(null, "name"));
         while (parser.hasNext()) {
             int event = parser.next();
@@ -174,7 +174,8 @@
 
     private Link parseLink() throws XMLStreamException {
-        Link link = new Link();
-        link.name = parser.getAttributeValue(null, "name");
-        link.url  = parser.getAttributeValue(null, "href");
+        Link link = new Link(
+	        parser.getAttributeValue(null, "name"),
+	        parser.getAttributeValue(null, "href")
+        );
         jumpToEnd();
         return link;
