mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-12 18:49:16 +02:00
+ Initial implementation of property TDOMParseOptions.CanonicalForm. The only thing it does yet is ignoring the DTD.
* Fixed relevant tests. git-svn-id: trunk@13914 -
This commit is contained in:
parent
169ef946a2
commit
0c50cfe10a
@ -67,7 +67,10 @@ type
|
|||||||
FResolveExternals: Boolean;
|
FResolveExternals: Boolean;
|
||||||
FNamespaces: Boolean;
|
FNamespaces: Boolean;
|
||||||
FDisallowDoctype: Boolean;
|
FDisallowDoctype: Boolean;
|
||||||
|
FCanonical: Boolean;
|
||||||
FMaxChars: Cardinal;
|
FMaxChars: Cardinal;
|
||||||
|
function GetCanonical: Boolean;
|
||||||
|
procedure SetCanonical(aValue: Boolean);
|
||||||
public
|
public
|
||||||
property Validate: Boolean read FValidate write FValidate;
|
property Validate: Boolean read FValidate write FValidate;
|
||||||
property PreserveWhitespace: Boolean read FPreserveWhitespace write FPreserveWhitespace;
|
property PreserveWhitespace: Boolean read FPreserveWhitespace write FPreserveWhitespace;
|
||||||
@ -78,6 +81,7 @@ type
|
|||||||
property Namespaces: Boolean read FNamespaces write FNamespaces;
|
property Namespaces: Boolean read FNamespaces write FNamespaces;
|
||||||
property DisallowDoctype: Boolean read FDisallowDoctype write FDisallowDoctype;
|
property DisallowDoctype: Boolean read FDisallowDoctype write FDisallowDoctype;
|
||||||
property MaxChars: Cardinal read FMaxChars write FMaxChars;
|
property MaxChars: Cardinal read FMaxChars write FMaxChars;
|
||||||
|
property CanonicalForm: Boolean read GetCanonical write SetCanonical;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
// NOTE: DOM 3 LS ACTION_TYPE enumeration starts at 1
|
// NOTE: DOM 3 LS ACTION_TYPE enumeration starts at 1
|
||||||
@ -337,6 +341,7 @@ type
|
|||||||
FDTDStartPos: PWideChar;
|
FDTDStartPos: PWideChar;
|
||||||
FIntSubset: TWideCharBuf;
|
FIntSubset: TWideCharBuf;
|
||||||
FAttrTag: Cardinal;
|
FAttrTag: Cardinal;
|
||||||
|
FOwnsDoctype: Boolean;
|
||||||
|
|
||||||
FNSHelper: TNSSupport;
|
FNSHelper: TNSSupport;
|
||||||
FWorkAtts: array of TPrefixedAttr;
|
FWorkAtts: array of TPrefixedAttr;
|
||||||
@ -353,6 +358,7 @@ type
|
|||||||
FResolveExternals: Boolean;
|
FResolveExternals: Boolean;
|
||||||
FNamespaces: Boolean;
|
FNamespaces: Boolean;
|
||||||
FDisallowDoctype: Boolean;
|
FDisallowDoctype: Boolean;
|
||||||
|
FCanonical: Boolean;
|
||||||
FMaxChars: Cardinal;
|
FMaxChars: Cardinal;
|
||||||
|
|
||||||
procedure SkipQuote(out Delim: WideChar; required: Boolean = True);
|
procedure SkipQuote(out Delim: WideChar; required: Boolean = True);
|
||||||
@ -683,6 +689,30 @@ begin
|
|||||||
CompareMem(ABuf.Buffer, Pointer(Arg), ABuf.Length*sizeof(WideChar));
|
CompareMem(ABuf.Buffer, Pointer(Arg), ABuf.Length*sizeof(WideChar));
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
{ TDOMParseOptions }
|
||||||
|
|
||||||
|
function TDOMParseOptions.GetCanonical: Boolean;
|
||||||
|
begin
|
||||||
|
Result := FCanonical and FExpandEntities and FCDSectionsAsText and
|
||||||
|
{ (not normalizeCharacters) and } FNamespaces and
|
||||||
|
{ namespaceDeclarations and } FPreserveWhitespace;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TDOMParseOptions.SetCanonical(aValue: Boolean);
|
||||||
|
begin
|
||||||
|
FCanonical := aValue;
|
||||||
|
if aValue then
|
||||||
|
begin
|
||||||
|
FExpandEntities := True;
|
||||||
|
FCDSectionsAsText := True;
|
||||||
|
FNamespaces := True;
|
||||||
|
FPreserveWhitespace := True;
|
||||||
|
{ normalizeCharacters := False; }
|
||||||
|
{ namespaceDeclarations := True; }
|
||||||
|
{ wellFormed := True; }
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
{ TXMLInputSource }
|
{ TXMLInputSource }
|
||||||
|
|
||||||
constructor TXMLInputSource.Create(AStream: TStream);
|
constructor TXMLInputSource.Create(AStream: TStream);
|
||||||
@ -1421,6 +1451,7 @@ begin
|
|||||||
FResolveExternals := FCtrl.Options.ResolveExternals;
|
FResolveExternals := FCtrl.Options.ResolveExternals;
|
||||||
FNamespaces := FCtrl.Options.Namespaces;
|
FNamespaces := FCtrl.Options.Namespaces;
|
||||||
FDisallowDoctype := FCtrl.Options.DisallowDoctype;
|
FDisallowDoctype := FCtrl.Options.DisallowDoctype;
|
||||||
|
FCanonical := FCtrl.Options.CanonicalForm;
|
||||||
FMaxChars := FCtrl.Options.MaxChars;
|
FMaxChars := FCtrl.Options.MaxChars;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -1438,6 +1469,8 @@ begin
|
|||||||
ClearRefs(FIDRefs);
|
ClearRefs(FIDRefs);
|
||||||
FNsAttHash.Free;
|
FNsAttHash.Free;
|
||||||
FNSHelper.Free;
|
FNSHelper.Free;
|
||||||
|
if FOwnsDoctype then
|
||||||
|
FDocType.Free;
|
||||||
|
|
||||||
FNotationRefs.Free;
|
FNotationRefs.Free;
|
||||||
FIDRefs.Free;
|
FIDRefs.Free;
|
||||||
@ -2100,7 +2133,10 @@ begin
|
|||||||
SkipS;
|
SkipS;
|
||||||
finally
|
finally
|
||||||
// DONE: append node after its name has been set; always append to avoid leak
|
// DONE: append node after its name has been set; always append to avoid leak
|
||||||
Doc.AppendChild(FDocType);
|
if FCanonical then
|
||||||
|
FOwnsDoctype := True
|
||||||
|
else
|
||||||
|
Doc.AppendChild(FDocType);
|
||||||
FCursor := nil;
|
FCursor := nil;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
@ -88,10 +88,7 @@ var
|
|||||||
nodeValue: DOMString;
|
nodeValue: DOMString;
|
||||||
length: Integer;
|
length: Integer;
|
||||||
begin
|
begin
|
||||||
// canonical form: PreserveWhitespace, Namespaces, NamespaceDeclarations = True;
|
FParser.Options.CanonicalForm := True;
|
||||||
// Entities, CDSections = False;
|
|
||||||
FParser.Options.PreserveWhitespace := True;
|
|
||||||
FParser.Options.Namespaces := True;
|
|
||||||
LoadStringData(doc, canonicform01);
|
LoadStringData(doc, canonicform01);
|
||||||
begin
|
begin
|
||||||
node := TDOMNode(doc).firstChild;
|
node := TDOMNode(doc).firstChild;
|
||||||
@ -152,10 +149,7 @@ var
|
|||||||
nodeValue: DOMString;
|
nodeValue: DOMString;
|
||||||
length: Integer;
|
length: Integer;
|
||||||
begin
|
begin
|
||||||
// canonical form: PreserveWhitespace, Namespaces, NamespaceDeclarations = True;
|
FParser.Options.CanonicalForm := True;
|
||||||
// Entities, CDSections = False;
|
|
||||||
FParser.Options.PreserveWhitespace := True;
|
|
||||||
FParser.Options.Namespaces := True;
|
|
||||||
FParser.Options.IgnoreComments := True;
|
FParser.Options.IgnoreComments := True;
|
||||||
LoadStringData(doc, canonicform01);
|
LoadStringData(doc, canonicform01);
|
||||||
begin
|
begin
|
||||||
@ -198,8 +192,7 @@ var
|
|||||||
divEl: TDOMElement;
|
divEl: TDOMElement;
|
||||||
node: TDOMNode;
|
node: TDOMNode;
|
||||||
begin
|
begin
|
||||||
FParser.Options.PreserveWhitespace := True;
|
FParser.Options.CanonicalForm := True;
|
||||||
FParser.Options.Namespaces := True;
|
|
||||||
LoadStringData(doc, canonicform03);
|
LoadStringData(doc, canonicform03);
|
||||||
|
|
||||||
divList := doc.getElementsByTagName('div');
|
divList := doc.getElementsByTagName('div');
|
||||||
@ -220,8 +213,7 @@ var
|
|||||||
attrSpecified: Boolean;
|
attrSpecified: Boolean;
|
||||||
attrValue: DOMString;
|
attrValue: DOMString;
|
||||||
begin
|
begin
|
||||||
FParser.Options.PreserveWhitespace := True;
|
FParser.Options.CanonicalForm := True;
|
||||||
FParser.Options.Namespaces := True;
|
|
||||||
LoadStringData(doc, canonicform03);
|
LoadStringData(doc, canonicform03);
|
||||||
|
|
||||||
elemList := doc.getElementsByTagName('acronym');
|
elemList := doc.getElementsByTagName('acronym');
|
||||||
|
Loading…
Reference in New Issue
Block a user