Index: trunk/autoquest-plugin-html/src/main/java/de/ugoe/cs/autoquest/plugin/html/HTMLLogParser.java
===================================================================
--- trunk/autoquest-plugin-html/src/main/java/de/ugoe/cs/autoquest/plugin/html/HTMLLogParser.java	(revision 1272)
+++ trunk/autoquest-plugin-html/src/main/java/de/ugoe/cs/autoquest/plugin/html/HTMLLogParser.java	(revision 1339)
@@ -15,4 +15,5 @@
 package de.ugoe.cs.autoquest.plugin.html;
 
+import java.util.Arrays;
 import java.util.List;
 import java.util.Map;
@@ -31,4 +32,5 @@
 import de.ugoe.cs.autoquest.plugin.html.guimodel.HTMLGUIElement;
 import de.ugoe.cs.autoquest.plugin.html.guimodel.HTMLGUIElementSpec;
+import de.ugoe.cs.autoquest.plugin.html.guimodel.HTMLPageElement;
 import de.ugoe.cs.autoquest.plugin.html.guimodel.HTMLPageElementSpec;
 import de.ugoe.cs.autoquest.plugin.html.guimodel.HTMLServerSpec;
@@ -53,4 +55,36 @@
     private Pattern htmlElementPattern =
         Pattern.compile("(\\w+)(\\[(\\d+)\\]|\\(htmlId=([\\w-]+)\\))");
+    
+    /**
+     * <p>
+     * the pattern used for parsing parsing parameters
+     * </p>
+     */
+    private Pattern htmlElementSpecPattern =
+        Pattern.compile("(\\w+)(\\[(\\d+)\\]|\\(htmlId=([\\w-]+)\\))?");
+    
+    /**
+     * <p>
+     * parameters to influence parsing
+     * </p>
+     */
+    private Map<String, List<String>> parseParams;
+
+    /**
+     * <p>
+     * TODO: comment
+     * </p>
+     *
+     * @param parseParams
+     */
+    public HTMLLogParser(Map<String, List<String>> parseParams) {
+        this.parseParams = parseParams;
+        
+        for (String paramKey : parseParams.keySet()) {
+            if (!"clearId".equals(paramKey) && !"clearIndex".equals(paramKey)) {
+                throw new IllegalArgumentException("unknown parse parameter key " + paramKey);
+            }
+        }
+    }
 
     /* (non-Javadoc)
@@ -64,5 +98,5 @@
         
         String parentId = parameters.get("parent");
-        IGUIElement parent = super.getGUIElementTree().find(parentId);
+        HTMLGUIElement parent = (HTMLGUIElement) super.getGUIElementTree().find(parentId);
 
         if (parameters.containsKey("host")) {
@@ -122,8 +156,22 @@
                     index = Integer.parseInt(indexStr);
                 }
+                
+                String htmlId = parameters.get("htmlid");
+                
+                if (clearIndex(tagName, index, htmlId, parent)) {
+                    index = -1;
+                }
+                
+                if (clearHTMLId(tagName, index, htmlId, parent)) {
+                    htmlId = null;
+                }
+                
+                if ((htmlId == null) && (index == -1)) {
+                    // set at least a default index, if all is to be ignored.
+                    index = 0;
+                }
 
                 specification = new HTMLPageElementSpec
-                    ((HTMLDocumentSpec) document.getSpecification(), tagName,
-                     parameters.get("htmlid"), index);
+                    ((HTMLDocumentSpec) document.getSpecification(), tagName, htmlId, index);
                 
             }
@@ -151,4 +199,139 @@
     }
 
+    /**
+     * <p>
+     * TODO: comment
+     * </p>
+     *
+     * @param tagName
+     * @param parent
+     * @return
+     */
+    private boolean clearIndex(String tagName, int index, String id, HTMLGUIElement parent) {
+        return clearSomething("clearIndex", tagName, index, id, parent);
+    }
+
+    /**
+     * <p>
+     * TODO: comment
+     * </p>
+     *
+     * @param tagName
+     * @param parent
+     * @return
+     */
+    private boolean clearHTMLId(String tagName, int index, String id, HTMLGUIElement parent) {
+        return clearSomething("clearId", tagName, index, id, parent);
+    }
+    
+    /**
+     * <p>
+     * TODO: comment
+     * </p>
+     *
+     * @param tagName
+     * @param parent
+     * @return
+     */
+    private boolean clearSomething(String         parseParamId,
+                                   String         tagName,
+                                   int            index,
+                                   String         id,
+                                   HTMLGUIElement parent)
+    {
+        if (parseParams.containsKey(parseParamId)) {
+            for (String spec : parseParams.get(parseParamId)) {
+                // determine the specification parts
+                if (spec.startsWith("/")) {
+                    throw new IllegalArgumentException("can not handle absolute specifications");
+                }
+                else if (spec.endsWith("/")) {
+                    throw new IllegalArgumentException("specifications may not end with a /");
+                }
+                
+                String[] tagSpecs = spec.split("/");
+                
+                if (tagMatchesTagSpec(tagName, index, id, parent, tagSpecs)) {
+                    return true;
+                }
+            }
+        }
+        
+        return false;
+    }
+
+    /**
+     * <p>
+     * TODO: comment
+     * </p>
+     *
+     * @param tagName
+     * @param parent
+     * @param spec
+     * @return
+     */
+    private boolean tagMatchesTagSpec(String         tagName,
+                                      int            index,
+                                      String         id,
+                                      HTMLGUIElement parent,
+                                      String[]       tagSpecs)
+    {
+        
+        if (tagSpecs.length > 0) {
+            Matcher matcher = htmlElementSpecPattern.matcher(tagSpecs[tagSpecs.length - 1]);
+            
+            if (!matcher.matches()) {
+                throw new IllegalArgumentException
+                    ("illegal tag specification " + tagSpecs[tagSpecs.length - 1]);
+            }
+            
+            if (!tagName.equals(matcher.group(1))) {
+                return false;
+            }
+            
+            String idCondition = matcher.group(4);
+            
+            if (idCondition != null) {
+                if (!idCondition.equals(id)) {
+                    return false;
+                }
+            }
+            
+            String indexCondition = matcher.group(3);
+            
+            if (indexCondition != null) {
+                try {
+                    if (index != Integer.parseInt(indexCondition)) {
+                        return false;
+                    }
+                }
+                catch (NumberFormatException e) {
+                    throw new IllegalArgumentException
+                        ("illegal tag index specification " + indexCondition, e);
+                }
+            }
+            
+            if (tagSpecs.length > 1) {
+                if (parent instanceof HTMLPageElement) {
+                    return tagMatchesTagSpec(((HTMLPageElement) parent).getTagName(),
+                                             ((HTMLPageElement) parent).getIndex(),
+                                             ((HTMLPageElement) parent).getHtmlId(),
+                                             (HTMLGUIElement) parent.getParent(),
+                                             Arrays.copyOfRange(tagSpecs, 0, tagSpecs.length - 1));
+                }
+                else {
+                    throw new IllegalArgumentException
+                        ("specification matches documents or servers. This is not supported yet.");
+                }
+            }
+            else {
+                return true;
+            }
+        }
+        else {
+            return true;
+        }
+    }
+
     /* (non-Javadoc)
      * @see de.ugoe.cs.autoquest.plugin.html.AbstractDefaultLogParser#handleEvent(String, Map)
@@ -159,4 +342,9 @@
         
         if (targetId == null) {
+            if (parseParams.size() != 0) {
+                throw new SAXException
+                    ("old log file versions can not be parsed with parse parameters");
+            }
+            
             String targetDocument = parameters.get("targetDocument");
             String targetDOMPath = parameters.get("targetDOMPath");
