anchor.diff:    else
       rule(false, 'Unknown XPath name '+s);
     if readNext then
  +  begin
  +    if isXmlWhiteSpace(peek) then
  +      if (node.value = 'if') then
  +        mode := esmIfStmt
  +      else if (node.value = 'for') then
  +        mode := esmForLoop;
       s := readXPathToken(true, true);
  -  if (s = '(') then
  -  begin
  +  end;
  +  if mode = esmIfStmt then
  +  begin
  +    readXpathExpression(node.addParam, ['then'], s);
  +    readXpathExpression(node.addParam, ['else']);
  +    s := readXpathExpression(node.addParam, endTokens);
  +  end
  +  else if mode = esmForLoop then
  +  begin
  +    rule(s = '$', 'expected a variablt ($xxx) parsing a for loop');
  +    node.nodeType := xeoIterator;
  +    node.value := readXPathToken(false);
       s := readXPathToken(true);
  -    done := s = ')';
  -    while not done do
  +    rule(s = 'in', 'Unexpected token '''+s+''' reading or iterator');
  +    s := readXpathExpression(node.addParam, ['return']);
  +    s := readXpathExpression(node.addParam, endTokens);
  +  end
  +  else // mode = esmNormal
  +  begin
  +    if (s = '(') then
       begin
  -      p := TXPathExpressionNode.Create;
  +      s := readXPathToken(true);
  +      done := s = ')';
  +      while not done do
  +      begin
  +        s := readXpathExpression(node.addParam, [',', ')'], s);
  +        if (s = ',') then
  +          s := readXPathToken(true)
  +        else if (s = ')') then
  +          done := true
  +        else
  +          rule(false, 'expected '','' at this point but found '+s);
  +      end;
  +      node.NodeType := xentFunction;
  +      s := readXPathToken(true, true);
  +    end;
  +    while (s = '[') do
  +    begin
  +      f := TXPathExpressionNode.Create;
         try
  -        s := readXpathExpression(p, [',', ')'], s);
  -        node.Params.Add(p.Link);
  +        readXpathExpression(f, [']']);
  +        s := readXPathToken(true, true);
  +        node.Filters.Add(f.Link);
         finally
  -        p.Free;
  +        f.Free;
         end;
  -      if (s = ',') then
  -        s := readXPathToken(true)
  -      else if (s = ')') then
  -        done := true
  -      else
  -        rule(false, 'expected '','' at this point but found '+s);
  -    end;
  -    node.NodeType := xentFunction;
  -    s := readXPathToken(true, true);
  -  end;
  -  while (s = '[') do
  -  begin
  -    f := TXPathExpressionNode.Create;
  -    try
  -      readXpathExpression(f, [']']);
  -      s := readXPathToken(true, true);
  -      node.Filters.Add(f.Link);
  -    finally
  -      f.Free;
  -    end;
  -  end;
  -  if (s = '/') then
  -  begin
  -    node.Next := TXPathExpressionNode.Create;
  -    s := readXpathExpression(node.next, endTokens);
  -  end;
  -  if StringArrayExistsSensitive(['=', '+', 'and', 'or', '>', '>=', '!=', '|', '<', '<='], s) then
  -  begin
  -    node.Op := TXPathExpressionOperation(StringArrayIndexOfSensitive(['', '=', '+', 'and', 'or', '>', '>=', '!=', '|', '<', '<='], s));
  -    node.NextOp := TXPathExpressionNode.Create;
  -    s := readXpathExpression(node.NextOp, endTokens);
  -  end;
  -  if s = '' then
  -    rule(length(endTokens) = 0, 'Unexpected end of expression expecting '+describeTokens(endTokens))
  -  else
  -    rule(StringArrayExistsSensitive(endTokens, s), 'Found '+s+' expecting '+describeTokens(endTokens));
  +    end;
  +    if (s = '/') then
  +    begin
  +      node.Next := TXPathExpressionNode.Create;
  +      s := readXpathExpression(node.next, endTokens);
  +    end;
  +    if StringArrayExistsSensitive(['=', '+', 'and', 'or', '>', '>=', '!=', '|', '<', '<='], s) or ((s = ',') and not StringArrayExistsSensitive(endTokens, ',')) then
  +    begin
  +      node.Op := TXPathExpressionOperation(StringArrayIndexOfSensitive(['', '=', '+', 'and', 'or', '>', '>=', '!=', '|', '<', '<=', ','], s));
  +      node.NextOp := TXPathExpressionNode.Create;
  +      s := readXpathExpression(node.NextOp, endTokens);
  +    end;
  +    if s = '' then
  +      rule(length(endTokens) = 0, 'Unexpected end of expression expecting '+describeTokens(endTokens))
  +    else
  +      rule(StringArrayExistsSensitive(endTokens, s), 'Found '+s+' expecting '+describeTokens(endTokens));
  +  end;
     result := s;
   end;
   
  
positive.code: end;
  
  { TXPathExpressionNode }
  
  destructor TXPathExpressionNode.Destroy;
  begin
  
negative.code:   else if (s = '(') then
    begin
      node.nodeType := xentGroup;
      s := readXPathToken(true, true);
      if s <> ')' then
      begin
        node.group := TXPathExpressionNode.Create;
        s := readXpathExpression(node.Group, [')'], s);
      end;
      rule(s = ')', 'Expected ''('' at this point but found '+s);
    end
    else if (s = '/') then
  