[fpc-pascal] fcl-xml

dev.dliw at gmail.com dev.dliw at gmail.com
Tue Mar 12 14:04:34 CET 2013


> Maybe the bug is that it checks case sensitive:
> 
> procedure TXMLTextReader.ParseAttlistDecl;
> ...
>           Found := FSource.Matches(AttrDataTypeNames[dt]);

ParseAttlistDecl isn't called a single time...
- to me it sounds like "Parse Attribute *declaration*" - and I don't have a 
DTD (the file is actually HTML).

When switching Validate *on*, there are lot of DoError calls - but don't know 
if this is related...

>From what I see: (trunk)
AddId is only called from ValidateAttrValue
ValidateAttrValue is only called from ValidateCurrentNode
and this is only when the parser does validation...

For me there is missing something in ParseAttribute(ElDef: TElementDecl);

===
  if Assigned(ElDef) then
  begin
    AttDef := ElDef.GetAttrDef(attrName);
    // mark attribute as specified
    if Assigned(AttDef) then
      FAttrDefIndex[AttDef.Index] := FAttrTag;
  end
  else
    AttDef := nil;
===

ElDef is not assigned, so AttDef is nil...
AttDef holds TAttrDataType which should be recognised as "dtId"...

I hope I got it right so far - but still don't know what the actual problem 
is...

-----------------------------------------------------------------------------------------------------

That't what I'm currently testing with:

=== test.xml ===

<?xml version="1.0" encoding="UTF-8"?>
<html>
  <div id="test">Test</div>
</html>

=== test.pas ===

program test;

{$mode objfpc}{$H+}

Uses
  Classes, XMLRead, DOM;

Var
  Doc : TXMLDocument;
  Parser : TDOMParser;
  Source : TXMLInputSource;
  List   : TStringList;

begin
  List := TStringList.Create;
  List.LoadFromFile('test.xml');

  Parser := TDOMParser.Create;
  try
    Parser.Options.IgnoreComments := true;
    //Parser.Options.Validate := true;

    Source := TXMLInputSource.Create(List.Text);
    try
      Parser.Parse(Source, Doc);
    finally
      Source.Free;
    end;
  finally
    Parser.Free;
  end;

  WriteLn(assigned(Doc.IDs));  // output: false

  List.Free;
end.

======                    



More information about the fpc-pascal mailing list