* Flag undeclared elements with ContentType = ctUndeclared, it's much more self-documenting than the

mysterious HasElementDecl.

git-svn-id: trunk@13266 -
This commit is contained in:
sergei 2009-06-12 20:20:14 +00:00
parent b47650960e
commit f31048dc01

View File

@ -289,6 +289,7 @@ type
TXMLReadState = (rsProlog, rsDTD, rsRoot, rsEpilog); TXMLReadState = (rsProlog, rsDTD, rsRoot, rsEpilog);
TElementContentType = ( TElementContentType = (
ctUndeclared,
ctAny, ctAny,
ctEmpty, ctEmpty,
ctMixed, ctMixed,
@ -458,7 +459,6 @@ type
public public
FExternallyDeclared: Boolean; FExternallyDeclared: Boolean;
ContentType: TElementContentType; ContentType: TElementContentType;
HasElementDecl: Boolean;
IDAttr: TDOMAttrDef; IDAttr: TDOMAttrDef;
NotationAttr: TDOMAttrDef; NotationAttr: TDOMAttrDef;
RootCP: TContentParticle; RootCP: TContentParticle;
@ -2246,10 +2246,10 @@ var
ExtDecl: Boolean; ExtDecl: Boolean;
begin begin
CP := nil; CP := nil;
Typ := ctAny; // satisfy compiler Typ := ctUndeclared; // satisfy compiler
ExpectWhitespace; ExpectWhitespace;
ElDef := FindOrCreateElDef; ElDef := FindOrCreateElDef;
if ElDef.HasElementDecl then if ElDef.ContentType <> ctUndeclared then
ValidationError('Duplicate declaration of element ''%s''', [ElDef.TagName], FName.Length); ValidationError('Duplicate declaration of element ''%s''', [ElDef.TagName], FName.Length);
ExtDecl := FSource.DTDSubsetType <> dsInternal; ExtDecl := FSource.DTDSubsetType <> dsInternal;
@ -2306,9 +2306,8 @@ begin
else else
FatalError('Invalid content specification'); FatalError('Invalid content specification');
// SAX: DeclHandler.ElementDecl(name, model); // SAX: DeclHandler.ElementDecl(name, model);
if not ElDef.HasElementDecl then if ElDef.ContentType = ctUndeclared then
begin begin
ElDef.HasElementDecl := True;
ElDef.FExternallyDeclared := ExtDecl; ElDef.FExternallyDeclared := ExtDecl;
ElDef.ContentType := Typ; ElDef.ContentType := Typ;
ElDef.RootCP := CP; ElDef.RootCP := CP;
@ -2893,7 +2892,7 @@ begin
// Find declaration for this element // Find declaration for this element
ElDef := TDOMElementDef(ElName^.Data); ElDef := TDOMElementDef(ElName^.Data);
if (ElDef = nil) or (not ElDef.HasElementDecl) then if (ElDef = nil) or (ElDef.ContentType = ctUndeclared) then
ValidationError('Using undeclared element ''%s''',[ElName^.Key], FName.Length); ValidationError('Using undeclared element ''%s''',[ElName^.Key], FName.Length);
// Check if new element is allowed in current context // Check if new element is allowed in current context
@ -3485,7 +3484,7 @@ begin
else else
FFailed := True; // used to prevent extra error at the end of element FFailed := True; // used to prevent extra error at the end of element
end; end;
// ctAny: returns True by default // ctAny, ctUndeclared: returns True by default
end; end;
end; end;
end; end;