mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-09-12 13:49:51 +02:00
+ Fixes from Sebastian Guenther
This commit is contained in:
parent
f2818d7908
commit
e5ba3f245c
@ -348,7 +348,7 @@ type
|
|||||||
FAttributes: TDOMNamedNodeMap;
|
FAttributes: TDOMNamedNodeMap;
|
||||||
function FGetAttributes: TDOMNamedNodeMap; override;
|
function FGetAttributes: TDOMNamedNodeMap; override;
|
||||||
|
|
||||||
constructor Create(AOwner: TDOMDocument);virtual;
|
constructor Create(AOwner: TDOMDocument); virtual;
|
||||||
public
|
public
|
||||||
property TagName: DOMString read FNodeName;
|
property TagName: DOMString read FNodeName;
|
||||||
function GetAttribute(const name: DOMString): DOMString;
|
function GetAttribute(const name: DOMString): DOMString;
|
||||||
@ -993,11 +993,22 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
function TDOMAttr.FGetNodeValue: DOMString;
|
function TDOMAttr.FGetNodeValue: DOMString;
|
||||||
|
var
|
||||||
|
child: TDOMNode;
|
||||||
begin
|
begin
|
||||||
if FFirstChild = nil then
|
if FFirstChild = nil then
|
||||||
Result := ''
|
Result := ''
|
||||||
|
else begin
|
||||||
|
Result := '';
|
||||||
|
child := FFirstChild;
|
||||||
|
while child <> nil do begin
|
||||||
|
if child.NodeType = ENTITY_REFERENCE_NODE then
|
||||||
|
Result := Result + '&' + child.NodeName + ';'
|
||||||
else
|
else
|
||||||
Result := FFirstChild.NodeValue;
|
Result := Result + child.NodeValue;
|
||||||
|
child := child.NextSibling;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TDOMAttr.FSetNodeValue(AValue: DOMString);
|
procedure TDOMAttr.FSetNodeValue(AValue: DOMString);
|
||||||
@ -1228,7 +1239,10 @@ end.
|
|||||||
|
|
||||||
{
|
{
|
||||||
$Log$
|
$Log$
|
||||||
Revision 1.3 1999-07-10 21:48:26 michael
|
Revision 1.4 1999-07-11 20:20:11 michael
|
||||||
|
+ Fixes from Sebastian Guenther
|
||||||
|
|
||||||
|
Revision 1.3 1999/07/10 21:48:26 michael
|
||||||
+ Made domelement constructor virtual, needs overriding in thtmlelement
|
+ Made domelement constructor virtual, needs overriding in thtmlelement
|
||||||
|
|
||||||
Revision 1.2 1999/07/09 21:05:49 michael
|
Revision 1.2 1999/07/09 21:05:49 michael
|
||||||
|
@ -55,7 +55,7 @@ type
|
|||||||
TXMLReader = class
|
TXMLReader = class
|
||||||
protected
|
protected
|
||||||
doc: TXMLDocument;
|
doc: TXMLDocument;
|
||||||
buf: PChar;
|
buf, BufStart: PChar;
|
||||||
|
|
||||||
procedure RaiseExc(descr: String);
|
procedure RaiseExc(descr: String);
|
||||||
function SkipWhitespace: Boolean;
|
function SkipWhitespace: Boolean;
|
||||||
@ -91,8 +91,25 @@ type
|
|||||||
|
|
||||||
|
|
||||||
procedure TXMLReader.RaiseExc(descr: String);
|
procedure TXMLReader.RaiseExc(descr: String);
|
||||||
|
var
|
||||||
|
apos: PChar;
|
||||||
|
x, y: Integer;
|
||||||
begin
|
begin
|
||||||
raise Exception.Create('In XML reader: ' + descr);
|
// find out the line in which the error occured
|
||||||
|
apos := BufStart;
|
||||||
|
x := 1;
|
||||||
|
y := 1;
|
||||||
|
while apos < buf do begin
|
||||||
|
if apos[0] = #10 then begin
|
||||||
|
Inc(y);
|
||||||
|
x := 1;
|
||||||
|
end else
|
||||||
|
Inc(x);
|
||||||
|
Inc(apos);
|
||||||
|
end;
|
||||||
|
|
||||||
|
raise Exception.Create('In XML reader (line ' + IntToStr(y) + ' pos ' +
|
||||||
|
IntToStr(x) + '): ' + descr);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TXMLReader.SkipWhitespace: Boolean;
|
function TXMLReader.SkipWhitespace: Boolean;
|
||||||
@ -154,6 +171,7 @@ var
|
|||||||
LastNodeBeforeDoc: TDOMNode;
|
LastNodeBeforeDoc: TDOMNode;
|
||||||
begin
|
begin
|
||||||
buf := ABuf;
|
buf := ABuf;
|
||||||
|
BufStart := ABuf;
|
||||||
|
|
||||||
doc := TXMLDocument.Create;
|
doc := TXMLDocument.Create;
|
||||||
ExpectProlog;
|
ExpectProlog;
|
||||||
@ -262,12 +280,13 @@ begin
|
|||||||
if CheckFor('<?') then begin
|
if CheckFor('<?') then begin
|
||||||
StrLCopy(checkbuf, buf, 3);
|
StrLCopy(checkbuf, buf, 3);
|
||||||
if UpCase(StrPas(checkbuf)) = 'XML' then
|
if UpCase(StrPas(checkbuf)) = 'XML' then
|
||||||
RaiseExc('"<?XML" processing instruction not allowed here');
|
RaiseExc('"<?xml" processing instruction not allowed here');
|
||||||
ExpectName;
|
ExpectName;
|
||||||
if SkipWhitespace then
|
if SkipWhitespace then
|
||||||
while (buf[0] <> #0) and (buf[1] <> #0) and
|
while (buf[0] <> #0) and (buf[1] <> #0) and not
|
||||||
(buf[0] <> '?') and (buf[1] <> '>') do Inc(buf);
|
((buf[0] = '?') and (buf[1] = '>')) do Inc(buf);
|
||||||
ExpectString('?>');
|
ExpectString('?>');
|
||||||
|
Result := True;
|
||||||
end else
|
end else
|
||||||
Result := False;
|
Result := False;
|
||||||
end;
|
end;
|
||||||
@ -324,7 +343,7 @@ begin
|
|||||||
// Check for "Misc*"
|
// Check for "Misc*"
|
||||||
ParseMisc(doc);
|
ParseMisc(doc);
|
||||||
|
|
||||||
// Check for "(doctypedecl Misc*)?"
|
// Check for "(doctypedecl Misc*)?" [28]
|
||||||
if CheckFor('<!DOCTYPE') then begin
|
if CheckFor('<!DOCTYPE') then begin
|
||||||
SkipWhitespace;
|
SkipWhitespace;
|
||||||
ExpectName;
|
ExpectName;
|
||||||
@ -338,6 +357,7 @@ begin
|
|||||||
ExpectString(']');
|
ExpectString(']');
|
||||||
SkipWhitespace;
|
SkipWhitespace;
|
||||||
end;
|
end;
|
||||||
|
ExpectString('>');
|
||||||
ParseMisc(doc);
|
ParseMisc(doc);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -537,8 +557,9 @@ function TXMLReader.ParseMarkupDecl: Boolean; // [29]
|
|||||||
while not CheckFor(strdel) do
|
while not CheckFor(strdel) do
|
||||||
if ParsePEReference then
|
if ParsePEReference then
|
||||||
else if ParseReference(NewEntity) then
|
else if ParseReference(NewEntity) then
|
||||||
else
|
else begin
|
||||||
RaiseExc('Expected entity or PE reference');
|
Inc(buf); // Normal haracter
|
||||||
|
end;
|
||||||
Result := True;
|
Result := True;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -555,7 +576,7 @@ function TXMLReader.ParseMarkupDecl: Boolean; // [29]
|
|||||||
else
|
else
|
||||||
RaiseExc('Expected entity value or external ID');
|
RaiseExc('Expected entity value or external ID');
|
||||||
end else begin // [71]
|
end else begin // [71]
|
||||||
ExpectName;
|
NewEntity := doc.CreateEntity(ExpectName);
|
||||||
ExpectWhitespace;
|
ExpectWhitespace;
|
||||||
// Get EntityDef [73]
|
// Get EntityDef [73]
|
||||||
if ParseEntityValue then
|
if ParseEntityValue then
|
||||||
@ -601,9 +622,10 @@ begin
|
|||||||
Result := True;
|
Result := True;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TXMLReader.ProcessDTD(ABuf: PChar): TXMLDocument; // [1]
|
function TXMLReader.ProcessDTD(ABuf: PChar): TXMLDocument;
|
||||||
begin
|
begin
|
||||||
buf := ABuf;
|
buf := ABuf;
|
||||||
|
BufStart := ABuf;
|
||||||
|
|
||||||
doc := TXMLDocument.Create;
|
doc := TXMLDocument.Create;
|
||||||
ParseMarkupDecl;
|
ParseMarkupDecl;
|
||||||
@ -719,7 +741,7 @@ begin
|
|||||||
RaiseExc('Expected element');
|
RaiseExc('Expected element');
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TXMLReader.ParsePEReference: Boolean;
|
function TXMLReader.ParsePEReference: Boolean; // [69]
|
||||||
begin
|
begin
|
||||||
if CheckFor('%') then begin
|
if CheckFor('%') then begin
|
||||||
ExpectName;
|
ExpectName;
|
||||||
@ -735,6 +757,14 @@ begin
|
|||||||
Result := False;
|
Result := False;
|
||||||
exit;
|
exit;
|
||||||
end;
|
end;
|
||||||
|
if CheckFor('#') then begin // Test for CharRef [66]
|
||||||
|
if CheckFor('x') then begin
|
||||||
|
// *** there must be at leat one digit
|
||||||
|
while buf[0] in ['0'..'9', 'a'..'f', 'A'..'F'] do Inc(buf);
|
||||||
|
end else
|
||||||
|
// *** there must be at leat one digit
|
||||||
|
while buf[0] in ['0'..'9'] do Inc(buf);
|
||||||
|
end else
|
||||||
AOwner.AppendChild(doc.CreateEntityReference(ExpectName));
|
AOwner.AppendChild(doc.CreateEntityReference(ExpectName));
|
||||||
ExpectString(';');
|
ExpectString(';');
|
||||||
Result := True;
|
Result := True;
|
||||||
@ -924,7 +954,10 @@ end.
|
|||||||
|
|
||||||
{
|
{
|
||||||
$Log$
|
$Log$
|
||||||
Revision 1.3 1999-07-09 21:05:51 michael
|
Revision 1.4 1999-07-11 20:20:12 michael
|
||||||
|
+ Fixes from Sebastian Guenther
|
||||||
|
|
||||||
|
Revision 1.3 1999/07/09 21:05:51 michael
|
||||||
+ fixes from Guenther Sebastian
|
+ fixes from Guenther Sebastian
|
||||||
|
|
||||||
Revision 1.2 1999/07/09 10:42:50 michael
|
Revision 1.2 1999/07/09 10:42:50 michael
|
||||||
|
Loading…
Reference in New Issue
Block a user