|
@@ -109,8 +109,10 @@ type
|
|
// DOMString
|
|
// DOMString
|
|
// -------------------------------------------------------
|
|
// -------------------------------------------------------
|
|
|
|
|
|
|
|
+ TSetOfChar = set of Char;
|
|
DOMString = WideString;
|
|
DOMString = WideString;
|
|
DOMPChar = PWideChar;
|
|
DOMPChar = PWideChar;
|
|
|
|
+ PDOMString = ^DOMString;
|
|
|
|
|
|
EDOMError = class(Exception)
|
|
EDOMError = class(Exception)
|
|
public
|
|
public
|
|
@@ -205,6 +207,8 @@ type
|
|
function GetNodeType: Integer; virtual; abstract;
|
|
function GetNodeType: Integer; virtual; abstract;
|
|
function GetTextContent: DOMString; virtual;
|
|
function GetTextContent: DOMString; virtual;
|
|
procedure SetTextContent(const AValue: DOMString); virtual;
|
|
procedure SetTextContent(const AValue: DOMString); virtual;
|
|
|
|
+ function GetLocalName: DOMString; virtual;
|
|
|
|
+ function GetNamespaceURI: DOMString; virtual;
|
|
public
|
|
public
|
|
constructor Create(AOwner: TDOMDocument);
|
|
constructor Create(AOwner: TDOMDocument);
|
|
destructor Destroy; override;
|
|
destructor Destroy; override;
|
|
@@ -239,15 +243,13 @@ type
|
|
function HasAttributes: Boolean; virtual;
|
|
function HasAttributes: Boolean; virtual;
|
|
procedure Normalize;
|
|
procedure Normalize;
|
|
|
|
|
|
- (*
|
|
|
|
- // TODO: What is that Java NULL for strings ???
|
|
|
|
// always '' for nodes other than ELEMENT and ATTRIBUTE
|
|
// always '' for nodes other than ELEMENT and ATTRIBUTE
|
|
// as well as for nodes created with DOM 1 methods
|
|
// as well as for nodes created with DOM 1 methods
|
|
- property NamespaceURI: DOMString read GetNamespaceURI;
|
|
|
|
-
|
|
|
|
|
|
+ //property NamespaceURI: DOMString read GetNamespaceURI;
|
|
|
|
+ //property LocalName: DOMString read GetLocalName;
|
|
|
|
+ (*
|
|
// Prefix may only be changed if it was specified at creation time.
|
|
// Prefix may only be changed if it was specified at creation time.
|
|
property Prefix: DOMString read FPrefix (write SetPrefix?);
|
|
property Prefix: DOMString read FPrefix (write SetPrefix?);
|
|
- property LocalName: DOMString read FLocalName;
|
|
|
|
*)
|
|
*)
|
|
// DOM level 3
|
|
// DOM level 3
|
|
property TextContent: DOMString read GetTextContent write SetTextContent;
|
|
property TextContent: DOMString read GetTextContent write SetTextContent;
|
|
@@ -406,12 +408,17 @@ type
|
|
|
|
|
|
TDOMDocument = class(TDOMNode_WithChildren)
|
|
TDOMDocument = class(TDOMNode_WithChildren)
|
|
protected
|
|
protected
|
|
|
|
+ FIDList: TList;
|
|
FRevision: Integer;
|
|
FRevision: Integer;
|
|
|
|
+ FXML11: Boolean;
|
|
FImplementation: TDOMImplementation;
|
|
FImplementation: TDOMImplementation;
|
|
function GetDocumentElement: TDOMElement;
|
|
function GetDocumentElement: TDOMElement;
|
|
function GetDocType: TDOMDocumentType;
|
|
function GetDocType: TDOMDocumentType;
|
|
function GetNodeType: Integer; override;
|
|
function GetNodeType: Integer; override;
|
|
function GetNodeName: DOMString; override;
|
|
function GetNodeName: DOMString; override;
|
|
|
|
+ function IndexOfNS(const nsURI: DOMString): Integer;
|
|
|
|
+ function FindID(const aID: DOMString; out Index: LongWord): Boolean;
|
|
|
|
+ procedure ClearIDList;
|
|
public
|
|
public
|
|
property DocType: TDOMDocumentType read GetDocType;
|
|
property DocType: TDOMDocumentType read GetDocType;
|
|
property Impl: TDOMImplementation read FImplementation;
|
|
property Impl: TDOMImplementation read FImplementation;
|
|
@@ -444,17 +451,24 @@ type
|
|
// Extensions to DOM interface:
|
|
// Extensions to DOM interface:
|
|
// TODO: obsolete now, but must check for usage dependencies
|
|
// TODO: obsolete now, but must check for usage dependencies
|
|
constructor Create;
|
|
constructor Create;
|
|
|
|
+ destructor Destroy; override;
|
|
|
|
+ function AddID(Attr: TDOMAttr): Boolean;
|
|
|
|
+ procedure RemoveID(Attr: TDOMAttr);
|
|
end;
|
|
end;
|
|
|
|
|
|
TXMLDocument = class(TDOMDocument)
|
|
TXMLDocument = class(TDOMDocument)
|
|
|
|
+ private
|
|
|
|
+ FXMLVersion: DOMString;
|
|
|
|
+ procedure SetXMLVersion(const aValue: DOMString);
|
|
public
|
|
public
|
|
// These fields are extensions to the DOM interface:
|
|
// These fields are extensions to the DOM interface:
|
|
- XMLVersion, Encoding, StylesheetType, StylesheetHRef: DOMString;
|
|
|
|
|
|
+ Encoding, StylesheetType, StylesheetHRef: DOMString;
|
|
|
|
|
|
function CreateCDATASection(const data: DOMString): TDOMCDATASection; override;
|
|
function CreateCDATASection(const data: DOMString): TDOMCDATASection; override;
|
|
function CreateProcessingInstruction(const target, data: DOMString):
|
|
function CreateProcessingInstruction(const target, data: DOMString):
|
|
TDOMProcessingInstruction; override;
|
|
TDOMProcessingInstruction; override;
|
|
function CreateEntityReference(const name: DOMString): TDOMEntityReference; override;
|
|
function CreateEntityReference(const name: DOMString): TDOMEntityReference; override;
|
|
|
|
+ property XMLVersion: DOMString read FXMLVersion write SetXMLVersion;
|
|
end;
|
|
end;
|
|
|
|
|
|
|
|
|
|
@@ -462,12 +476,27 @@ type
|
|
// Attr
|
|
// Attr
|
|
// -------------------------------------------------------
|
|
// -------------------------------------------------------
|
|
|
|
|
|
|
|
+ TAttrDataType = (
|
|
|
|
+ dtCdata,
|
|
|
|
+ dtId,
|
|
|
|
+ dtIdRef,
|
|
|
|
+ dtIdRefs,
|
|
|
|
+ dtEntity,
|
|
|
|
+ dtEntities,
|
|
|
|
+ dtNmToken,
|
|
|
|
+ dtNmTokens,
|
|
|
|
+ dtNotation
|
|
|
|
+ );
|
|
|
|
+
|
|
TDOMAttr = class(TDOMNode_WithChildren)
|
|
TDOMAttr = class(TDOMNode_WithChildren)
|
|
protected
|
|
protected
|
|
FName: DOMString;
|
|
FName: DOMString;
|
|
- FSpecified: Boolean;
|
|
|
|
- FNormalize: Boolean;
|
|
|
|
FOwnerElement: TDOMElement;
|
|
FOwnerElement: TDOMElement;
|
|
|
|
+ // TODO: following 3 - replace with a link to AttDecl ??
|
|
|
|
+ // ('specified' isn't related...)
|
|
|
|
+ FSpecified: Boolean;
|
|
|
|
+ FDeclared: Boolean;
|
|
|
|
+ FDataType: TAttrDataType;
|
|
function GetNodeValue: DOMString; override;
|
|
function GetNodeValue: DOMString; override;
|
|
function GetNodeType: Integer; override;
|
|
function GetNodeType: Integer; override;
|
|
function GetNodeName: DOMString; override;
|
|
function GetNodeName: DOMString; override;
|
|
@@ -477,10 +506,10 @@ type
|
|
property Name: DOMString read FName;
|
|
property Name: DOMString read FName;
|
|
property Specified: Boolean read FSpecified;
|
|
property Specified: Boolean read FSpecified;
|
|
property Value: DOMString read GetNodeValue write SetNodeValue;
|
|
property Value: DOMString read GetNodeValue write SetNodeValue;
|
|
- // Introduced in DOM level 2:
|
|
|
|
property OwnerElement: TDOMElement read FOwnerElement;
|
|
property OwnerElement: TDOMElement read FOwnerElement;
|
|
// extensions
|
|
// extensions
|
|
function CompareName(const AName: DOMString): Integer; override;
|
|
function CompareName(const AName: DOMString): Integer; override;
|
|
|
|
+ property DataType: TAttrDataType read FDataType;
|
|
end;
|
|
end;
|
|
|
|
|
|
|
|
|
|
@@ -532,11 +561,16 @@ type
|
|
|
|
|
|
TDOMText = class(TDOMCharacterData)
|
|
TDOMText = class(TDOMCharacterData)
|
|
protected
|
|
protected
|
|
|
|
+ // set by parser if text contains only literal whitespace (i.e. not coming from CharRefs)
|
|
|
|
+ FMayBeIgnorable: Boolean;
|
|
function GetNodeType: Integer; override;
|
|
function GetNodeType: Integer; override;
|
|
function GetNodeName: DOMString; override;
|
|
function GetNodeName: DOMString; override;
|
|
|
|
+ procedure SetNodeValue(const aValue: DOMString); override;
|
|
public
|
|
public
|
|
function CloneNode(deep: Boolean; ACloneOwner: TDOMDocument): TDOMNode; overload; override;
|
|
function CloneNode(deep: Boolean; ACloneOwner: TDOMDocument): TDOMNode; overload; override;
|
|
function SplitText(offset: LongWord): TDOMText;
|
|
function SplitText(offset: LongWord): TDOMText;
|
|
|
|
+ // Extension
|
|
|
|
+ property MayBeIgnorable: Boolean read FMayBeIgnorable write FMayBeIgnorable;
|
|
end;
|
|
end;
|
|
|
|
|
|
|
|
|
|
@@ -577,10 +611,12 @@ type
|
|
FSystemID: DOMString;
|
|
FSystemID: DOMString;
|
|
FInternalSubset: DOMString;
|
|
FInternalSubset: DOMString;
|
|
FEntities, FNotations: TDOMNamedNodeMap;
|
|
FEntities, FNotations: TDOMNamedNodeMap;
|
|
|
|
+ FElementDefs: TDOMNamedNodeMap;
|
|
function GetEntities: TDOMNamedNodeMap;
|
|
function GetEntities: TDOMNamedNodeMap;
|
|
function GetNotations: TDOMNamedNodeMap;
|
|
function GetNotations: TDOMNamedNodeMap;
|
|
function GetNodeType: Integer; override;
|
|
function GetNodeType: Integer; override;
|
|
function GetNodeName: DOMString; override;
|
|
function GetNodeName: DOMString; override;
|
|
|
|
+ function GetElementDefs: TDOMNamedNodeMap;
|
|
public
|
|
public
|
|
destructor Destroy; override;
|
|
destructor Destroy; override;
|
|
function CloneNode(deep: Boolean; ACloneOwner: TDOMDocument): TDOMNode; overload; override;
|
|
function CloneNode(deep: Boolean; ACloneOwner: TDOMDocument): TDOMNode; overload; override;
|
|
@@ -591,6 +627,8 @@ type
|
|
property PublicID: DOMString read FPublicID;
|
|
property PublicID: DOMString read FPublicID;
|
|
property SystemID: DOMString read FSystemID;
|
|
property SystemID: DOMString read FSystemID;
|
|
property InternalSubset: DOMString read FInternalSubset;
|
|
property InternalSubset: DOMString read FInternalSubset;
|
|
|
|
+ // extensions
|
|
|
|
+ property ElementDefs: TDOMNamedNodeMap read GetElementDefs;
|
|
end;
|
|
end;
|
|
|
|
|
|
|
|
|
|
@@ -669,6 +707,15 @@ type
|
|
|
|
|
|
implementation
|
|
implementation
|
|
|
|
|
|
|
|
+uses
|
|
|
|
+ xmlutils;
|
|
|
|
+
|
|
|
|
+type
|
|
|
|
+ PIDItem = ^TIDItem;
|
|
|
|
+ TIDItem = record
|
|
|
|
+ ID: WideString;
|
|
|
|
+ Element: TDOMElement;
|
|
|
|
+ end;
|
|
|
|
|
|
constructor TRefClass.Create;
|
|
constructor TRefClass.Create;
|
|
begin
|
|
begin
|
|
@@ -881,7 +928,8 @@ begin
|
|
if Assigned(Txt) then
|
|
if Assigned(Txt) then
|
|
begin
|
|
begin
|
|
tmp := Child.NextSibling;
|
|
tmp := Child.NextSibling;
|
|
- Txt.AppendData(Child.nodeValue);
|
|
|
|
|
|
+ Txt.AppendData(TDOMText(Child).Data);
|
|
|
|
+ Txt.FMayBeIgnorable := Txt.FMayBeIgnorable and TDOMText(Child).FMayBeIgnorable;
|
|
RemoveChild(Child);
|
|
RemoveChild(Child);
|
|
Child := tmp;
|
|
Child := tmp;
|
|
end
|
|
end
|
|
@@ -910,6 +958,16 @@ begin
|
|
NodeValue := AValue;
|
|
NodeValue := AValue;
|
|
end;
|
|
end;
|
|
|
|
|
|
|
|
+function TDOMNode.GetNamespaceURI: DOMString;
|
|
|
|
+begin
|
|
|
|
+ Result := '';
|
|
|
|
+end;
|
|
|
|
+
|
|
|
|
+function TDOMNode.GetLocalName: DOMString;
|
|
|
|
+begin
|
|
|
|
+ Result := '';
|
|
|
|
+end;
|
|
|
|
+
|
|
function CompareDOMStrings(const s1, s2: DOMPChar; l1, l2: integer): integer;
|
|
function CompareDOMStrings(const s1, s2: DOMPChar; l1, l2: integer): integer;
|
|
var i: integer;
|
|
var i: integer;
|
|
begin
|
|
begin
|
|
@@ -935,16 +993,12 @@ end;
|
|
|
|
|
|
function CompareDOMNodeWithDOMNode(Node1, Node2: Pointer): integer;
|
|
function CompareDOMNodeWithDOMNode(Node1, Node2: Pointer): integer;
|
|
begin
|
|
begin
|
|
- Result:=CompareDOMStrings(DOMPChar(TDOMNode(Node1).NodeName),
|
|
|
|
- DOMPChar(TDOMNode(Node2).NodeName),
|
|
|
|
- length(TDOMNode(Node1).NodeName),
|
|
|
|
- length(TDOMNode(Node2).NodeName)
|
|
|
|
- );
|
|
|
|
|
|
+ Result := TDOMNode(Node1).CompareName(TDOMNode(Node2).NodeName);
|
|
end;
|
|
end;
|
|
|
|
|
|
function CompareDOMStringWithDOMNode(AKey, ANode: Pointer): integer;
|
|
function CompareDOMStringWithDOMNode(AKey, ANode: Pointer): integer;
|
|
begin
|
|
begin
|
|
- Result := TDOMNode(ANode).CompareName(DOMString(AKey));
|
|
|
|
|
|
+ Result := TDOMNode(ANode).CompareName(PDOMString(AKey)^);
|
|
end;
|
|
end;
|
|
|
|
|
|
|
|
|
|
@@ -1047,14 +1101,11 @@ end;
|
|
function TDOMNode_WithChildren.ReplaceChild(NewChild, OldChild: TDOMNode):
|
|
function TDOMNode_WithChildren.ReplaceChild(NewChild, OldChild: TDOMNode):
|
|
TDOMNode;
|
|
TDOMNode;
|
|
begin
|
|
begin
|
|
-// Inc(FOwnerDocument.FRevision); // invalidate nodelists (will happen anyway)
|
|
|
|
-
|
|
|
|
RemoveFromChildNodeTree(OldChild);
|
|
RemoveFromChildNodeTree(OldChild);
|
|
InsertBefore(NewChild, OldChild);
|
|
InsertBefore(NewChild, OldChild);
|
|
if Assigned(OldChild) then
|
|
if Assigned(OldChild) then
|
|
RemoveChild(OldChild);
|
|
RemoveChild(OldChild);
|
|
- // TODO: must return OldChild, if I understand that right...
|
|
|
|
- // but OldChild is destroyed!
|
|
|
|
|
|
+ // TODO: per DOM spec, must return OldChild, but OldChild is destroyed
|
|
Result := NewChild;
|
|
Result := NewChild;
|
|
end;
|
|
end;
|
|
|
|
|
|
@@ -1167,7 +1218,7 @@ var AVLNode: TAVLTreeNode;
|
|
begin
|
|
begin
|
|
Result:=nil;
|
|
Result:=nil;
|
|
if FChildNodeTree<>nil then begin
|
|
if FChildNodeTree<>nil then begin
|
|
- AVLNode:=FChildNodeTree.FindKey(DOMPChar(ANodeName),
|
|
|
|
|
|
+ AVLNode:=FChildNodeTree.FindKey(Pointer(ANodeName),
|
|
@CompareDOMStringWithDOMNode);
|
|
@CompareDOMStringWithDOMNode);
|
|
if AVLNode<>nil then
|
|
if AVLNode<>nil then
|
|
Result:=TDOMNode(AVLNode.Data);
|
|
Result:=TDOMNode(AVLNode.Data);
|
|
@@ -1289,7 +1340,7 @@ begin
|
|
BuildList;
|
|
BuildList;
|
|
|
|
|
|
if index < LongWord(FList.Count) then
|
|
if index < LongWord(FList.Count) then
|
|
- Result := TDOMNode(FList[index])
|
|
|
|
|
|
+ Result := TDOMNode(FList.List^[index])
|
|
else
|
|
else
|
|
Result := nil;
|
|
Result := nil;
|
|
end;
|
|
end;
|
|
@@ -1618,6 +1669,77 @@ begin
|
|
inherited Create(nil);
|
|
inherited Create(nil);
|
|
// TODO: DOM lvl 2 states that Document should be unowned. Any dependencies?
|
|
// TODO: DOM lvl 2 states that Document should be unowned. Any dependencies?
|
|
FOwnerDocument := Self;
|
|
FOwnerDocument := Self;
|
|
|
|
+ FIDList := TList.Create;
|
|
|
|
+end;
|
|
|
|
+
|
|
|
|
+destructor TDOMDocument.Destroy;
|
|
|
|
+begin
|
|
|
|
+ ClearIDList;
|
|
|
|
+ FIDList.Free;
|
|
|
|
+ inherited Destroy;
|
|
|
|
+end;
|
|
|
|
+
|
|
|
|
+function TDOMDocument.AddID(Attr: TDOMAttr): Boolean;
|
|
|
|
+var
|
|
|
|
+ I: Cardinal;
|
|
|
|
+ Item: PIDItem;
|
|
|
|
+begin
|
|
|
|
+ New(Item);
|
|
|
|
+ Item^.ID := Attr.Value;
|
|
|
|
+ Item^.Element := Attr.OwnerElement;
|
|
|
|
+ if not FindID(Item^.ID, I) then
|
|
|
|
+ begin
|
|
|
|
+ FIDList.Insert(I, Item);
|
|
|
|
+ Result := True;
|
|
|
|
+ end
|
|
|
|
+ else
|
|
|
|
+ begin
|
|
|
|
+ Dispose(Item);
|
|
|
|
+ Result := False;
|
|
|
|
+ end;
|
|
|
|
+end;
|
|
|
|
+
|
|
|
|
+procedure TDOMDocument.RemoveID(Attr: TDOMAttr);
|
|
|
|
+begin
|
|
|
|
+ // TODO: Implement this
|
|
|
|
+end;
|
|
|
|
+
|
|
|
|
+function TDOMDocument.FindID(const aID: DOMString; out Index: LongWord): Boolean;
|
|
|
|
+var
|
|
|
|
+ L, H, I, C: Integer;
|
|
|
|
+ P: PIDItem;
|
|
|
|
+begin
|
|
|
|
+ Result := False;
|
|
|
|
+ L := 0;
|
|
|
|
+ H := FIDList.Count - 1;
|
|
|
|
+ while L <= H do
|
|
|
|
+ begin
|
|
|
|
+ I := (L + H) shr 1;
|
|
|
|
+ P := PIDItem(FIDList.List^[I]);
|
|
|
|
+ C := CompareDOMStrings(PWideChar(aID), PWideChar(P^.ID), Length(aID), Length(P^.ID));
|
|
|
|
+ if C > 0 then L := I + 1 else
|
|
|
|
+ begin
|
|
|
|
+ H := I - 1;
|
|
|
|
+ if C = 0 then
|
|
|
|
+ begin
|
|
|
|
+ Result := True;
|
|
|
|
+ L := I;
|
|
|
|
+ end;
|
|
|
|
+ end;
|
|
|
|
+ end;
|
|
|
|
+ Index := L;
|
|
|
|
+end;
|
|
|
|
+
|
|
|
|
+procedure TDOMDocument.ClearIDList;
|
|
|
|
+var
|
|
|
|
+ I: Integer;
|
|
|
|
+begin
|
|
|
|
+ if Assigned(FIDList) then
|
|
|
|
+ begin
|
|
|
|
+ for I := 0 to FIDList.Count-1 do
|
|
|
|
+ Dispose(PIDItem(FIDList.List^[I]));
|
|
|
|
+ FIDList.Clear;
|
|
|
|
+ end;
|
|
end;
|
|
end;
|
|
|
|
|
|
function TDOMDocument.GetNodeType: Integer;
|
|
function TDOMDocument.GetNodeType: Integer;
|
|
@@ -1652,6 +1774,8 @@ end;
|
|
|
|
|
|
function TDOMDocument.CreateElement(const tagName: DOMString): TDOMElement;
|
|
function TDOMDocument.CreateElement(const tagName: DOMString): TDOMElement;
|
|
begin
|
|
begin
|
|
|
|
+ if not IsXmlName(tagName, FXML11) then
|
|
|
|
+ raise EDOMError.Create(INVALID_CHARACTER_ERR, 'DOMDocument.CreateElement');
|
|
Result := TDOMElement.Create(Self);
|
|
Result := TDOMElement.Create(Self);
|
|
Result.FNodeName := tagName;
|
|
Result.FNodeName := tagName;
|
|
// TODO: attach default attributes
|
|
// TODO: attach default attributes
|
|
@@ -1710,6 +1834,8 @@ end;
|
|
|
|
|
|
function TDOMDocument.CreateAttribute(const name: DOMString): TDOMAttr;
|
|
function TDOMDocument.CreateAttribute(const name: DOMString): TDOMAttr;
|
|
begin
|
|
begin
|
|
|
|
+ if not IsXmlName(name, FXML11) then
|
|
|
|
+ raise EDOMError.Create(INVALID_CHARACTER_ERR, 'DOMDocument.CreateAttribute');
|
|
Result := TDOMAttr.Create(Self);
|
|
Result := TDOMAttr.Create(Self);
|
|
Result.FName := name;
|
|
Result.FName := name;
|
|
end;
|
|
end;
|
|
@@ -1718,6 +1844,7 @@ function TDOMDocument.CreateAttributeBuf(Buf: DOMPChar; Length: Integer): TDOMAt
|
|
begin
|
|
begin
|
|
Result := TDOMAttr.Create(Self);
|
|
Result := TDOMAttr.Create(Self);
|
|
SetString(Result.FName, Buf, Length);
|
|
SetString(Result.FName, Buf, Length);
|
|
|
|
+ Result.FSpecified := True;
|
|
end;
|
|
end;
|
|
|
|
|
|
function TDOMDocument.CreateEntityReference(const name: DOMString):
|
|
function TDOMDocument.CreateEntityReference(const name: DOMString):
|
|
@@ -1753,13 +1880,15 @@ begin
|
|
Result := nil;
|
|
Result := nil;
|
|
end;
|
|
end;
|
|
|
|
|
|
-function TDOMDocument.GetElementById(
|
|
|
|
- const ElementID: DOMString): TDOMElement;
|
|
|
|
|
|
+function TDOMDocument.GetElementById(const ElementID: DOMString): TDOMElement;
|
|
|
|
+var
|
|
|
|
+ I: Cardinal;
|
|
begin
|
|
begin
|
|
// TODO: Implement TDOMDocument.GetElementById
|
|
// TODO: Implement TDOMDocument.GetElementById
|
|
- // "Implementations that do not know whether attributes are
|
|
|
|
- // of type ID or not are expected to return null"
|
|
|
|
- Result := nil;
|
|
|
|
|
|
+ if FindID(ElementID, I) then
|
|
|
|
+ Result := PIDItem(FIDList.List^[I])^.Element
|
|
|
|
+ else
|
|
|
|
+ Result := nil;
|
|
end;
|
|
end;
|
|
|
|
|
|
function TDOMDocument.ImportNode(ImportedNode: TDOMNode;
|
|
function TDOMDocument.ImportNode(ImportedNode: TDOMNode;
|
|
@@ -1770,6 +1899,12 @@ begin
|
|
Result := nil;
|
|
Result := nil;
|
|
end;
|
|
end;
|
|
|
|
|
|
|
|
+function TDOMDocument.IndexOfNS(const nsURI: DOMString): Integer;
|
|
|
|
+begin
|
|
|
|
+ // TODO: implement
|
|
|
|
+ Result := -1;
|
|
|
|
+end;
|
|
|
|
+
|
|
|
|
|
|
function TXMLDocument.CreateCDATASection(const data: DOMString):
|
|
function TXMLDocument.CreateCDATASection(const data: DOMString):
|
|
TDOMCDATASection;
|
|
TDOMCDATASection;
|
|
@@ -1781,6 +1916,8 @@ end;
|
|
function TXMLDocument.CreateProcessingInstruction(const target,
|
|
function TXMLDocument.CreateProcessingInstruction(const target,
|
|
data: DOMString): TDOMProcessingInstruction;
|
|
data: DOMString): TDOMProcessingInstruction;
|
|
begin
|
|
begin
|
|
|
|
+ if not IsXmlName(target, FXML11) then
|
|
|
|
+ raise EDOMError.Create(INVALID_CHARACTER_ERR, 'XMLDocument.CreateProcessingInstruction');
|
|
Result := TDOMProcessingInstruction.Create(Self);
|
|
Result := TDOMProcessingInstruction.Create(Self);
|
|
Result.FTarget := target;
|
|
Result.FTarget := target;
|
|
Result.FNodeValue := data;
|
|
Result.FNodeValue := data;
|
|
@@ -1789,10 +1926,17 @@ end;
|
|
function TXMLDocument.CreateEntityReference(const name: DOMString):
|
|
function TXMLDocument.CreateEntityReference(const name: DOMString):
|
|
TDOMEntityReference;
|
|
TDOMEntityReference;
|
|
begin
|
|
begin
|
|
|
|
+ if not IsXmlName(name, FXML11) then
|
|
|
|
+ raise EDOMError.Create(INVALID_CHARACTER_ERR, 'XMLDocument.CreateEntityReference');
|
|
Result := TDOMEntityReference.Create(Self);
|
|
Result := TDOMEntityReference.Create(Self);
|
|
Result.FName := name;
|
|
Result.FName := name;
|
|
end;
|
|
end;
|
|
|
|
|
|
|
|
+procedure TXMLDocument.SetXMLVersion(const aValue: DOMString);
|
|
|
|
+begin
|
|
|
|
+ FXMLVersion := aValue;
|
|
|
|
+ FXML11 := (aValue = '1.1');
|
|
|
|
+end;
|
|
|
|
|
|
// -------------------------------------------------------
|
|
// -------------------------------------------------------
|
|
// Attr
|
|
// Attr
|
|
@@ -1813,31 +1957,16 @@ begin
|
|
// Cloned attribute is always specified and carries its children
|
|
// Cloned attribute is always specified and carries its children
|
|
Result := ACloneOwner.CreateAttribute(FName);
|
|
Result := ACloneOwner.CreateAttribute(FName);
|
|
TDOMAttr(Result).FSpecified := True;
|
|
TDOMAttr(Result).FSpecified := True;
|
|
- TDOMAttr(Result).FNormalize := FNormalize;
|
|
|
|
|
|
+ TDOMAttr(Result).FDataType := FDataType;
|
|
|
|
+ // Declared = ?
|
|
CloneChildren(Result, ACloneOwner);
|
|
CloneChildren(Result, ACloneOwner);
|
|
end;
|
|
end;
|
|
|
|
|
|
function TDOMAttr.GetNodeValue: DOMString;
|
|
function TDOMAttr.GetNodeValue: DOMString;
|
|
-var
|
|
|
|
- I,J: Integer;
|
|
|
|
begin
|
|
begin
|
|
Result := GetTextContent;
|
|
Result := GetTextContent;
|
|
- // TODO: probably must be speed optimized
|
|
|
|
- if FNormalize then
|
|
|
|
- begin
|
|
|
|
- Result := Trim(Result);
|
|
|
|
- I := 1;
|
|
|
|
- while I < Length(Result) do
|
|
|
|
- begin
|
|
|
|
- if Result[I] = #32 then
|
|
|
|
- begin
|
|
|
|
- J := I+1;
|
|
|
|
- while (J <= Length(Result)) and (Result[J] = #32) do Inc(J);
|
|
|
|
- if J-I > 1 then Delete(Result, I+1, J-I-1);
|
|
|
|
- end;
|
|
|
|
- Inc(I);
|
|
|
|
- end;
|
|
|
|
- end;
|
|
|
|
|
|
+ if FDataType <> dtCdata then
|
|
|
|
+ NormalizeSpaces(Result);
|
|
end;
|
|
end;
|
|
|
|
|
|
procedure TDOMAttr.SetNodeValue(const AValue: DOMString);
|
|
procedure TDOMAttr.SetNodeValue(const AValue: DOMString);
|
|
@@ -1945,7 +2074,7 @@ procedure TDOMElement.RemoveAttributeNS(const namespaceURI,
|
|
localName: DOMString);
|
|
localName: DOMString);
|
|
begin
|
|
begin
|
|
// TODO: Implement TDOMElement.RemoveAttributeNS
|
|
// TODO: Implement TDOMElement.RemoveAttributeNS
|
|
- raise EDOMNotSupported.Create('TDOMElement.RemoveAttributeNS');
|
|
|
|
|
|
+ raise EDOMNotSupported.Create('TDOMElement.RemoveAttributeNS');
|
|
end;
|
|
end;
|
|
|
|
|
|
procedure TDOMElement.SetAttributeNS(const namespaceURI, qualifiedName,
|
|
procedure TDOMElement.SetAttributeNS(const namespaceURI, qualifiedName,
|
|
@@ -2057,9 +2186,17 @@ begin
|
|
Result := '#text';
|
|
Result := '#text';
|
|
end;
|
|
end;
|
|
|
|
|
|
|
|
+procedure TDOMText.SetNodeValue(const aValue: DOMString);
|
|
|
|
+begin
|
|
|
|
+ // TODO: may analyze aValue, but this will slow things down...
|
|
|
|
+ FMayBeIgnorable := False;
|
|
|
|
+ FNodeValue := aValue;
|
|
|
|
+end;
|
|
|
|
+
|
|
function TDOMText.CloneNode(deep: Boolean; ACloneOwner: TDOMDocument): TDOMNode;
|
|
function TDOMText.CloneNode(deep: Boolean; ACloneOwner: TDOMDocument): TDOMNode;
|
|
begin
|
|
begin
|
|
Result := ACloneOwner.CreateTextNode(FNodeValue);
|
|
Result := ACloneOwner.CreateTextNode(FNodeValue);
|
|
|
|
+ TDOMText(Result).FMayBeIgnorable := FMayBeIgnorable;
|
|
end;
|
|
end;
|
|
|
|
|
|
function TDOMText.SplitText(offset: LongWord): TDOMText;
|
|
function TDOMText.SplitText(offset: LongWord): TDOMText;
|
|
@@ -2069,6 +2206,7 @@ begin
|
|
|
|
|
|
Result := TDOMText.Create(FOwnerDocument);
|
|
Result := TDOMText.Create(FOwnerDocument);
|
|
Result.FNodeValue := Copy(FNodeValue, offset + 1, Length);
|
|
Result.FNodeValue := Copy(FNodeValue, offset + 1, Length);
|
|
|
|
+ Result.FMayBeIgnorable := FMayBeIgnorable;
|
|
FNodeValue := Copy(FNodeValue, 1, offset);
|
|
FNodeValue := Copy(FNodeValue, 1, offset);
|
|
FParentNode.InsertBefore(Result, FNextSibling);
|
|
FParentNode.InsertBefore(Result, FNextSibling);
|
|
end;
|
|
end;
|
|
@@ -2132,6 +2270,7 @@ destructor TDOMDocumentType.Destroy;
|
|
begin
|
|
begin
|
|
FEntities.Free;
|
|
FEntities.Free;
|
|
FNotations.Free;
|
|
FNotations.Free;
|
|
|
|
+ FElementDefs.Free;
|
|
inherited Destroy;
|
|
inherited Destroy;
|
|
end;
|
|
end;
|
|
|
|
|
|
@@ -2159,6 +2298,13 @@ begin
|
|
Result := FNotations;
|
|
Result := FNotations;
|
|
end;
|
|
end;
|
|
|
|
|
|
|
|
+function TDOMDocumentType.GetElementDefs: TDOMNamedNodeMap;
|
|
|
|
+begin
|
|
|
|
+ if FElementDefs = nil then
|
|
|
|
+ FElementDefs := TDOMNamedNodeMap.Create(Self, ELEMENT_NODE);
|
|
|
|
+ Result := FElementDefs;
|
|
|
|
+end;
|
|
|
|
+
|
|
// -------------------------------------------------------
|
|
// -------------------------------------------------------
|
|
// Notation
|
|
// Notation
|
|
// -------------------------------------------------------
|
|
// -------------------------------------------------------
|