forked from mremec/omnixml
-
Notifications
You must be signed in to change notification settings - Fork 0
/
OmniXML.pas
4028 lines (3645 loc) · 131 KB
/
OmniXML.pas
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
(*******************************************************************************
* The contents of this file are subject to the Mozilla Public License Version *
* 1.1 (the "License"); you may not use this file except in compliance with the *
* License. You may obtain a copy of the License at http://www.mozilla.org/MPL/ *
* *
* Software distributed under the License is distributed on an "AS IS" basis, *
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for *
* the specific language governing rights and limitations under the License. *
* *
* The Original Code is OmniXML.pas *
* *
* The Initial Developer of the Original Code is Miha Remec *
* http://www.MihaRemec.com/ *
* *
* Contributor(s): *
* Primoz Gabrijelcic (gp) *
* Erik Berry (eb) *
* Ondrej Pokorny (op) *
*******************************************************************************)
unit OmniXML;
interface
{$I OmniXML.inc}
{$IFDEF OmniXML_HasZeroBasedStrings}
{$ZEROBASEDSTRINGS OFF}
{$ENDIF}
uses
{$IFDEF OmniXML_Namespaces}
System.Classes, System.SysUtils,
{$ELSE}
Classes, SysUtils,
{$ENDIF}
OEncoding, OTextReadWrite, OmniXML_Types, OmniXML_Dictionary
{$IFDEF OmniXML_Generics}, Generics.Collections{$ENDIF}
;
const
DEFAULT_DECIMALSEPARATOR = '.'; // don't change!
DEFAULT_TRUE = '1'; // don't change!
DEFAULT_FALSE = '0'; // don't change!
DEFAULT_DATETIMESEPARATOR = 'T'; // don't change!
DEFAULT_DATESEPARATOR = '-'; // don't change!
DEFAULT_TIMESEPARATOR = ':'; // don't change!
DEFAULT_MSSEPARATOR = '.'; // don't change!
const
// element node
ELEMENT_NODE = 1;
// attribute node
ATTRIBUTE_NODE = 2;
// text node
TEXT_NODE = 3;
// CDATA section node
CDATA_SECTION_NODE = 4;
// entity reference node
ENTITY_REFERENCE_NODE = 5;
// entity node
ENTITY_NODE = 6;
// processing instruction node
PROCESSING_INSTRUCTION_NODE = 7;
// comment node
COMMENT_NODE = 8;
// document node
DOCUMENT_NODE = 9;
// document type node
DOCUMENT_TYPE_NODE = 10;
// document fragment node
DOCUMENT_FRAGMENT_NODE = 11;
// notation node
NOTATION_NODE = 12;
type
TNodeType = 1..12;
const
// these codes are part of Exception codes
// W3C DOM Level 1
// index or size is negative, or greater than the allowed value
INDEX_SIZE_ERR = 1;
// the specified range of text does not fit into a DOMString
DOMSTRING_SIZE_ERR = 2;
// any node is inserted somewhere it doesn't belong
HIERARCHY_REQUEST_ERR = 3;
// a node is used in a different document than the one that created it (that doesn't support it)
WRONG_DOCUMENT_ERR = 4;
// an invalid character is specified, such as in a name
INVALID_CHARACTER_ERR = 5;
// data is specified for a node which does not support data
NO_DATA_ALLOWED_ERR = 6;
// an attempt is made to modify an object where modifications are not allowed
NO_MODIFICATION_ALLOWED_ERR = 7;
// an attempt was made to reference a node in a context where it does not exist
NOT_FOUND_ERR = 8;
// the implementation does not support the type of object requested
NOT_SUPPORTED_ERR = 9;
// an attempt is made to add an attribute that is already in use elsewhere
INUSE_ATTRIBUTE_ERR = 10;
// W3C DOM Level 2
// an attempt is made to use an object that is not, or is no longer, usable
INVALID_STATE_ERR = 11;
// an invalid or illegal string is specified
SYNTAX_ERR = 12;
// an attempt is made to modify the type of the underlying object
INVALID_MODIFICATION_ERR = 13;
// an attempt is made to create or change an object in a way which is incorrect with regard to namespaces
NAMESPACE_ERR = 14;
// parameter or an operation is not supported by the underlying object
INVALID_ACCESS_ERR = 15;
const
MSG_E_NOTEXT = $0000;
MSG_E_BASE = $0001;
MSG_E_FORMATINDEX_BADINDEX = MSG_E_BASE + 0;
MSG_E_FORMATINDEX_BADFORMAT = MSG_E_BASE + 1;
MSG_E_SYSTEM_ERROR = MSG_E_BASE + 2;
MSG_E_MISSINGEQUALS = MSG_E_BASE + 3;
MSG_E_EXPECTED_TOKEN = MSG_E_BASE + 4;
MSG_E_UNEXPECTED_TOKEN = MSG_E_BASE + 5;
MSG_E_MISSINGQUOTE = MSG_E_BASE + 6;
MSG_E_COMMENTSYNTAX = MSG_E_BASE + 7;
MSG_E_BADSTARTNAMECHAR = MSG_E_BASE + 8;
MSG_E_BADNAMECHAR = MSG_E_BASE + 9;
MSG_E_BADCHARINSTRING = MSG_E_BASE + 10;
MSG_E_XMLDECLSYNTAX = MSG_E_BASE + 11;
MSG_E_BADCHARDATA = MSG_E_BASE + 12;
MSG_E_MISSINGWHITESPACE = MSG_E_BASE + 13;
MSG_E_EXPECTINGTAGEND = MSG_E_BASE + 14;
MSG_E_BADCHARINDTD = MSG_E_BASE + 15;
MSG_E_BADCHARINDECL = MSG_E_BASE + 16;
MSG_E_MISSINGSEMICOLON = MSG_E_BASE + 17;
MSG_E_BADCHARINENTREF = MSG_E_BASE + 18;
MSG_E_UNBALANCEDPAREN = MSG_E_BASE + 19;
MSG_E_EXPECTINGOPENBRACKET = MSG_E_BASE + 20;
MSG_E_BADENDCONDSECT = MSG_E_BASE + 21;
MSG_E_INTERNALERROR = MSG_E_BASE + 22;
MSG_E_UNEXPECTED_WHITESPACE = MSG_E_BASE + 23;
MSG_E_INCOMPLETE_ENCODING = MSG_E_BASE + 24;
MSG_E_BADCHARINMIXEDMODEL = MSG_E_BASE + 25;
MSG_E_MISSING_STAR = MSG_E_BASE + 26;
MSG_E_BADCHARINMODEL = MSG_E_BASE + 27;
MSG_E_MISSING_PAREN = MSG_E_BASE + 28;
MSG_E_BADCHARINENUMERATION = MSG_E_BASE + 29;
MSG_E_PIDECLSYNTAX = MSG_E_BASE + 30;
MSG_E_EXPECTINGCLOSEQUOTE = MSG_E_BASE + 31;
MSG_E_MULTIPLE_COLONS = MSG_E_BASE + 32;
MSG_E_INVALID_DECIMAL = MSG_E_BASE + 33;
MSG_E_INVALID_HEXADECIMAL = MSG_E_BASE + 34;
MSG_E_INVALID_UNICODE = MSG_E_BASE + 35;
MSG_E_WHITESPACEORQUESTIONMARK = MSG_E_BASE + 36;
MSG_E_SUSPENDED = MSG_E_BASE + 37;
MSG_E_STOPPED = MSG_E_BASE + 38;
MSG_E_UNEXPECTEDENDTAG = MSG_E_BASE + 39;
MSG_E_UNCLOSEDTAG = MSG_E_BASE + 40;
MSG_E_DUPLICATEATTRIBUTE = MSG_E_BASE + 41;
MSG_E_MULTIPLEROOTS = MSG_E_BASE + 42;
MSG_E_INVALIDATROOTLEVEL = MSG_E_BASE + 43;
MSG_E_BADXMLDECL = MSG_E_BASE + 44;
MSG_E_MISSINGROOT = MSG_E_BASE + 45;
MSG_E_UNEXPECTEDEOF = MSG_E_BASE + 46;
MSG_E_BADPEREFINSUBSET = MSG_E_BASE + 47;
MSG_E_PE_NESTING = MSG_E_BASE + 48;
MSG_E_INVALID_CDATACLOSINGTAG = MSG_E_BASE + 49;
MSG_E_UNCLOSEDPI = MSG_E_BASE + 50;
MSG_E_UNCLOSEDSTARTTAG = MSG_E_BASE + 51;
MSG_E_UNCLOSEDENDTAG = MSG_E_BASE + 52;
MSG_E_UNCLOSEDSTRING = MSG_E_BASE + 53;
MSG_E_UNCLOSEDCOMMENT = MSG_E_BASE + 54;
MSG_E_UNCLOSEDDECL = MSG_E_BASE + 55;
MSG_E_UNCLOSEDMARKUPDECL = MSG_E_BASE + 56;
MSG_E_UNCLOSEDCDATA = MSG_E_BASE + 57;
MSG_E_BADDECLNAME = MSG_E_BASE + 58;
MSG_E_BADEXTERNALID = MSG_E_BASE + 59;
MSG_E_BADELEMENTINDTD = MSG_E_BASE + 60;
MSG_E_RESERVEDNAMESPACE = MSG_E_BASE + 61;
MSG_E_EXPECTING_VERSION = MSG_E_BASE + 62;
MSG_E_EXPECTING_ENCODING = MSG_E_BASE + 63;
MSG_E_EXPECTING_NAME = MSG_E_BASE + 64;
MSG_E_UNEXPECTED_ATTRIBUTE = MSG_E_BASE + 65;
MSG_E_ENDTAGMISMATCH = MSG_E_BASE + 66;
MSG_E_INVALIDENCODING = MSG_E_BASE + 67;
MSG_E_INVALIDSWITCH = MSG_E_BASE + 68;
MSG_E_EXPECTING_NDATA = MSG_E_BASE + 69;
MSG_E_INVALID_MODEL = MSG_E_BASE + 70;
MSG_E_INVALID_TYPE = MSG_E_BASE + 71;
MSG_E_INVALIDXMLSPACE = MSG_E_BASE + 72;
MSG_E_MULTI_ATTR_VALUE = MSG_E_BASE + 73;
MSG_E_INVALID_PRESENCE = MSG_E_BASE + 74;
MSG_E_BADXMLCASE = MSG_E_BASE + 75;
MSG_E_CONDSECTINSUBSET = MSG_E_BASE + 76;
MSG_E_CDATAINVALID = MSG_E_BASE + 77;
MSG_E_INVALID_STANDALONE = MSG_E_BASE + 78;
MSG_E_UNEXPECTED_STANDALONE = MSG_E_BASE + 79;
MSG_E_DOCTYPE_IN_DTD = MSG_E_BASE + 80;
MSG_E_MISSING_ENTITY = MSG_E_BASE + 81;
MSG_E_ENTITYREF_INNAME = MSG_E_BASE + 82;
MSG_E_DOCTYPE_OUTSIDE_PROLOG = MSG_E_BASE + 83;
MSG_E_INVALID_VERSION = MSG_E_BASE + 84;
MSG_E_DTDELEMENT_OUTSIDE_DTD = MSG_E_BASE + 85;
MSG_E_DUPLICATEDOCTYPE = MSG_E_BASE + 86;
MSG_E_RESOURCE = MSG_E_BASE + 87;
MSG_E_INVALID_OPERATION = MSG_E_BASE + 88;
MSG_E_WRONG_DOCUMENT = MSG_E_BASE + 89;
XML_BASE = MSG_E_BASE + 90;
XML_IOERROR = XML_BASE + 0;
XML_ENTITY_UNDEFINED = XML_BASE + 1;
XML_INFINITE_ENTITY_LOOP = XML_BASE + 2;
XML_NDATA_INVALID_PE = XML_BASE + 3;
XML_REQUIRED_NDATA = XML_BASE + 4;
XML_NDATA_INVALID_REF = XML_BASE + 5;
XML_EXTENT_IN_ATTR = XML_BASE + 6;
XML_STOPPED_BY_USER = XML_BASE + 7;
XML_PARSING_ENTITY = XML_BASE + 8;
XML_E_MISSING_PE_ENTITY = XML_BASE + 9;
XML_E_MIXEDCONTENT_DUP_NAME = XML_BASE + 10;
XML_NAME_COLON = XML_BASE + 11;
XML_ELEMENT_UNDECLARED = XML_BASE + 12;
XML_ELEMENT_ID_NOT_FOUND = XML_BASE + 13;
XML_DEFAULT_ATTRIBUTE = XML_BASE + 14;
XML_XMLNS_RESERVED = XML_BASE + 15;
XML_EMPTY_NOT_ALLOWED = XML_BASE + 16;
XML_ELEMENT_NOT_COMPLETE = XML_BASE + 17;
XML_ROOT_NAME_MISMATCH = XML_BASE + 18;
XML_INVALID_CONTENT = XML_BASE + 19;
XML_ATTRIBUTE_NOT_DEFINED = XML_BASE + 20;
XML_ATTRIBUTE_FIXED = XML_BASE + 21;
XML_ATTRIBUTE_VALUE = XML_BASE + 22;
XML_ILLEGAL_TEXT = XML_BASE + 23;
XML_MULTI_FIXED_VALUES = XML_BASE + 24;
XML_NOTATION_DEFINED = XML_BASE + 25;
XML_ELEMENT_DEFINED = XML_BASE + 26;
XML_ELEMENT_UNDEFINED = XML_BASE + 27;
XML_XMLNS_UNDEFINED = XML_BASE + 28;
XML_XMLNS_FIXED = XML_BASE + 29;
XML_E_UNKNOWNERROR = XML_BASE + 30;
XML_REQUIRED_ATTRIBUTE_MISSING = XML_BASE + 31;
XML_MISSING_NOTATION = XML_BASE + 32;
XML_ATTLIST_DUPLICATED_ID = XML_BASE + 33;
XML_ATTLIST_ID_PRESENCE = XML_BASE + 34;
XML_XMLLANG_INVALIDID = XML_BASE + 35;
XML_PUBLICID_INVALID = XML_BASE + 36;
XML_DTD_EXPECTING = XML_BASE + 37;
XML_NAMESPACE_URI_EMPTY = XML_BASE + 38;
XML_LOAD_EXTERNALENTITY = XML_BASE + 39;
XML_BAD_ENCODING = XML_BASE + 40;
type
EXMLException = class(Exception)
private
FDOMCode: Integer;
FXMLCode: Integer;
public
property DOMCode: Integer read FDOMCode;
property XMLCode: Integer read FXMLCode;
constructor CreateParseError(const DOMCode, XMLCode: Integer; const Args: array of const);
end;
{ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * }
{ }
{ S T A R T O F I N T E R F A C E D E C L A R A T I O N }
{ }
{ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * }
type
TOutputFormat = (ofNone, ofFlat, ofIndent);
IUnicodeStream = interface
['{F3ECA11F-EA18-491C-B59A-4203D5DC8CCA}']
// private
function GetEncoding: TEncoding;
procedure SetEncoding(const AEncoding: TEncoding);
function GetBOMFound: Boolean;
function GetOutputFormat: TOutputFormat;
procedure SetOutputFormat(const Value: TOutputFormat);
// public
procedure IncreaseIndent;
procedure DecreaseIndent;
procedure WriteIndent(const ForceNextLine: Boolean = False);
property OutputFormat: TOutputFormat read GetOutputFormat write SetOutputFormat;
property Encoding: TEncoding read GetEncoding write SetEncoding;
property BOMFound: Boolean read GetBOMFound;
procedure UndoRead;
function ProcessChar(var Char: XmlChar): Boolean;
function GetNextString(var ReadString: XmlString; const Len: Integer): Boolean;
procedure WriteOutputChar(const OutChar: XmlChar);
function GetOutputBuffer: XmlString;
function OutputBufferLen: Integer;
procedure ClearOutputBuffer;
procedure WriteString(const Value: XmlString);
end;
type
TStreamMode = (smRead, smWrite);
TXMLTextStream = class(TInterfacedObject, IUnicodeStream)
private
FStreamMode: TStreamMode;
FReader: TOTextReader;
FWriter: TOTextWriter;
FPreviousOutBuffer: XmlString;
FOutBuffer: PXmlChar;
FOutBufferPos,
FOutBufferSize: Integer;
FIndent: Integer;
FOutputFormat: TOutputFormat;
fBOMFound: Boolean;
function GetEncoding: TEncoding;
procedure SetEncoding(const AEncoding: TEncoding);
function GetBOMFound: Boolean;
function GetOutputFormat: TOutputFormat;
procedure SetOutputFormat(const Value: TOutputFormat);
protected
FStream: TStream;
FEOF: Boolean;
function ReadChar(var ReadChar: XmlChar): Boolean; virtual;
function ProcessChar(var ch: XmlChar): Boolean; virtual;
procedure IncreaseIndent;
procedure DecreaseIndent;
procedure WriteIndent(const ForceNextLine: Boolean = False);
// helper functions
function GetPreviousOutputBuffer: XmlString;
public
property OutputFormat: TOutputFormat read GetOutputFormat write SetOutputFormat;
property Encoding: TEncoding read GetEncoding write SetEncoding;
property BOMFound: Boolean read GetBOMFound;
constructor Create(const Stream: TStream; const Mode: TStreamMode; const Encoding: TEncoding; const WriteBOM: Boolean);
destructor Destroy; override;
procedure UndoRead; virtual;
function GetNextString(var ReadString: XmlString; const Len: Integer): Boolean;
procedure WriteOutputChar(const OutChar: XmlChar);
function GetOutputBuffer: XmlString;
function OutputBufferLen: Integer;
procedure ClearOutputBuffer;
procedure WriteString(const Value: XmlString);
end;
IXMLParseError = interface
['{546E9AE4-4E1E-4014-B0B8-4F024C797544}']
// private
function GetErrorCode: Integer;
function GetFilePos: Integer;
function GetLine: Integer;
function GetLinePos: Integer;
function GetSrcTextPos: Integer;
function GetReason: string;
function GetSrcText: XmlString;
function GetURL: string;
// public
property ErrorCode: Integer read GetErrorCode;
property FilePos: Integer read GetFilePos;
property Line: Integer read GetLine;//1-based
property LinePos: Integer read GetLinePos;//1-based
property Reason: string read GetReason;
property SrcText: XmlString read GetSrcText;
property SrcTextPos: Integer read GetSrcTextPos;//1-based, position of error in SrcText
property URL: string read GetURL;
end;
IXMLElement = interface;
IXMLDocument = interface;
IXMLNodeList = interface;
IXMLNamedNodeMap = interface;
IXMLNode = interface
['{F4D7D3DE-C6EC-4191-8E35-F652C2705E81}']
// private
function GetAttributes: IXMLNamedNodeMap;
function GetChildNodes: IXMLNodeList;
function GetFirstChild: IXMLNode;
function GetLastChild: IXMLNode;
function GetNextSibling: IXMLNode;
function GetNodeName: XmlString;
function GetNodeType: TNodeType;
function GetNodeValue: XmlString;
function GetOwnerDocument: IXMLDocument;
function GetParentNode: IXMLNode;
function GetPreviousSibling: IXMLNode;
procedure SetNodeValue(const Value: XmlString);
procedure SetParentNode(const Parent: IXMLNode);
// public
function InsertBefore(const NewChild, RefChild: IXMLNode): IXMLNode;
function ReplaceChild(const NewChild, OldChild: IXMLNode): IXMLNode;
function RemoveChild(const OldChild: IXMLNode): IXMLNode;
function AppendChild(const NewChild: IXMLNode): IXMLNode;
function HasChildNodes: Boolean;
function CloneNode(const Deep: Boolean): IXMLNode;
procedure SetCachedNodeIndex(const Index: integer);
property NodeName: XmlString read GetNodeName;
property NodeValue: XmlString read GetNodeValue write SetNodeValue;
property NodeType: TNodeType read GetNodeType;
property ParentNode: IXMLNode read GetParentNode;
property ChildNodes: IXMLNodeList read GetChildNodes;
property FirstChild: IXMLNode read GetFirstChild;
property LastChild: IXMLNode read GetLastChild;
property PreviousSibling: IXMLNode read GetPreviousSibling;
property NextSibling: IXMLNode read GetNextSibling;
property Attributes: IXMLNamedNodeMap read GetAttributes;
property OwnerDocument: IXMLDocument read GetOwnerDocument;
// MS (non-standard) extensions
function GetText: XmlString;
procedure SetText(const Value: XmlString);
property Text: XmlString read GetText write SetText;
procedure WriteToStream(const OutputStream: IUnicodeStream);
procedure SelectSingleNode(Pattern: string; var Result: IXMLNode); overload;
function SelectSingleNode(Pattern: string): IXMLNode; overload;
procedure SelectNodes(Pattern: string; var Result: IXMLNodeList); overload;
function SelectNodes(Pattern: string): IXMLNodeList; overload;
function GetXML: XmlString;
property XML: XmlString read GetXML;
end;
IXMLCustomList = interface
['{6520A0BC-8738-4E40-8CDB-33713DED32ED}']
// protected
function GetLength: Integer;
function GetItem(const Index: Integer): IXMLNode;
procedure MakeChildrenCacheSiblings(const Value: boolean);
// public
property Item[const Index: Integer]: IXMLNode read GetItem;
property Length: Integer read GetLength;
function Add(const XMLNode: IXMLNode): Integer;
function IndexOf(const XMLNode: IXMLNode): Integer;
procedure Insert(const Index: Integer; const XMLNode: IXMLNode);
function Remove(const XMLNode: IXMLNode): Integer;
procedure Delete(const Index: Integer);
procedure Clear;
end;
IXMLNodeList = interface(IXMLCustomList)
['{66AF674E-4697-4356-ACCC-4258DA138EA1}']
// public
function AddNode(const Arg: IXMLNode): IXMLNode;
// MS (non-standard) extensions
procedure Reset;
function NextNode: IXMLNode;
end;
IXMLNamedNodeMap = interface(IXMLCustomList)
['{87964B1D-F6CC-46D2-A602-67E198C8BFF5}']
// public
function GetNamedItem(const Name: XmlString): IXMLNode;
function SetNamedItem(const Arg: IXMLNode): IXMLNode;
function RemoveNamedItem(const Name: XmlString): IXMLNode;
end;
{ TODO -omr : re-add after IXMLDocumentType will be properly supported }
(*
IXMLDocumentType = interface(IXMLNode)
['{881517D3-A2F5-4AF0-8A3D-5A57D2C77ED9}']
// private
function GetEntities: IXMLNamedNodeMap;
function GetName: XmlString;
function GetNotations: IXMLNamedNodeMap;
// public
property Name: XmlString read GetName;
property Entities: IXMLNamedNodeMap read GetEntities;
property Notations: IXMLNamedNodeMap read GetNotations;
end;
*)
IXMLDocumentFragment = interface(IXMLNode)
['{A21A11BF-E489-4416-9607-172EFA2CFE45}']
end;
IXMLCharacterData = interface(IXMLNode)
['{613A6538-A0DC-49BC-AFA6-D8E611176B86}']
// private
function GetData: XmlString;
function GetLength: Integer;
procedure SetData(const Value: XmlString);
// public
property Data: XmlString read GetData write SetData;
property Length: Integer read GetLength;
function SubstringData(const Offset, Count: Integer): XmlString;
procedure AppendData(const Arg: XmlString);
procedure InsertData(const Offset: Integer; const Arg: XmlString);
procedure DeleteData(const Offset, Count: Integer);
procedure ReplaceData(const Offset, Count: Integer; const Arg: XmlString);
end;
IXMLText = interface(IXMLCharacterData)
['{0EC46ED2-AB58-4DC9-B964-965615248564}']
// public
function SplitText(const Offset: Integer): IXMLText;
end;
IXMLComment = interface(IXMLCharacterData)
['{B094A54C-039F-4ED7-9331-F7CF5A711EDA}']
end;
IXMLCDATASection = interface(IXMLText)
['{CF58778D-775D-4299-884C-F1DC61925D54}']
end;
IXMLDocumentType = interface(IXMLText)
['{E956F945-E8F6-4589-BF8D-D4DC23DE1089}']
end;
IXMLProcessingInstruction = interface(IXMLNode)
['{AF449E32-2615-4EF7-82B6-B2E9DCCE9FC3}']
// private
function GetData: XmlString;
function GetTarget: XmlString;
// public
property Target: XmlString read GetTarget;
property Data: XmlString read GetData;
end;
IXMLAttr = interface(IXMLNode)
['{10796B8E-FBAC-4ADF-BDD8-E4BBC5A5196F}']
// private
function GetName: XmlString;
function GetSpecified: Boolean;
function GetValue: XmlString;
procedure SetValue(const Value: XmlString);
// public
property Name: XmlString read GetName;
property Specified: Boolean read GetSpecified;
property Value: XmlString read GetValue write SetValue;
end;
IXMLEntityReference = interface(IXMLNode)
['{4EC18B2B-BD52-464D-BAD1-1FBE2C445989}']
end;
IXMLDocument = interface(IXMLNode)
['{59A76970-451C-4343-947C-242EFF17413C}']
// private
function GetDocType: IXMLDocumentType;
{ TODO -omr : re-add after IXMLDocumentType will be properly supported }
// procedure SetDocType(const Value: IXMLDocumentType);
function GetDocumentElement: IXMLElement;
procedure SetDocumentElement(const Value: IXMLElement);
function GetPreserveWhiteSpace: Boolean;
procedure SetPreserveWhiteSpace(const Value: Boolean);
// public
property DocType: IXMLDocumentType read GetDocType;
property DocumentElement: IXMLElement read GetDocumentElement write SetDocumentElement;
property PreserveWhiteSpace: Boolean read GetPreserveWhiteSpace write SetPreserveWhiteSpace;
function CreateAttribute(const Name: XmlString): IXMLAttr;
function CreateCDATASection(const Data: XmlString): IXMLCDATASection;
function CreateComment(const Data: XmlString): IXMLComment;
function CreateDocType(const Data: XmlString): IXMLDocumentType;
function CreateDocumentFragment: IXMLDocumentFragment;
function CreateElement(const TagName: XmlString): IXMLElement;
function CreateEntityReference(const Name: XmlString): IXMLEntityReference;
function CreateProcessingInstruction(const Target, Data: XmlString): IXMLProcessingInstruction;
function CreateTextNode(const Data: XmlString): IXMLText;
function GetElementsByTagName(const TagName: XmlString): IXMLNodeList;
// MS (non-standard) extensions
function Load(const FileName: string): Boolean;
function LoadFromStream(const Stream: TStream): Boolean;
procedure Save(const FileName: string; const OutputFormat: TOutputFormat = ofNone);
procedure SaveToStream(const OutputStream: TStream; const OutputFormat: TOutputFormat = ofNone);
function LoadXML(const XML: XmlString): Boolean;
function GetParseError: IXMLParseError;
property ParseError: IXMLParseError read GetParseError;
end;
IXMLElement = interface(IXMLNode)
['{C858C4E1-FB3F-4C98-8BDE-671E060D17B9}']
// private
function GetTagName: XmlString;
// public
property TagName: XmlString read GetTagName;
function GetAttribute(const Name: XmlString): XmlString;
procedure SetAttribute(const Name, Value: XmlString);
procedure RemoveAttribute(const Name: XmlString);
function GetAttributeNode(const Name: XmlString): IXMLAttr;
function SetAttributeNode(const NewAttr: IXMLAttr): IXMLAttr;
function RemoveAttributeNode(const OldAttr: IXMLAttr): IXMLAttr;
function GetElementsByTagName(const Name: XmlString): IXMLNodeList;
procedure Normalize;
end;
{ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * }
{ }
{ E N D O F I N T E R F A C E D E C L A R A T I O N }
{ }
{ }
{ S T A R T O F I N T E R F A C E I M P L E M E N T A T I O N }
{ }
{ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * }
type
TXMLParseError = class(TInterfacedObject, IXMLParseError)
private
FErrorCode: Integer;
FFilePos: Integer;
FLine: Integer;
FLinePos: Integer;
FReason: string;
FSrcText: XmlString;
FSrcTextPos: Integer;
FURL: string;
function GetErrorCode: Integer;
function GetFilePos: Integer;
function GetLine: Integer;
function GetLinePos: Integer;
function GetSrcTextPos: Integer;
function GetReason: string;
function GetSrcText: XmlString;
function GetURL: string;
protected
procedure SetErrorCode(const ErrorCode: Integer);
procedure SetFilePos(const FilePos: Integer);
procedure SetLine(const Line: Integer);
procedure SetLinePos(const LinePos: Integer);
procedure SetReason(const Reason: string);
procedure SetSrcText(const SrcTextBefore, SrcTextAfter: XmlString);
procedure SetURL(const URL: string);
public
property ErrorCode: Integer read GetErrorCode;
property FilePos: Integer read GetFilePos;
property Line: Integer read GetLine;
property LinePos: Integer read GetLinePos;
property Reason: string read GetReason;
property SrcText: XmlString read GetSrcText;
property SrcTextPos: Integer read GetSrcTextPos;
property URL: string read GetURL;
end;
TXMLNodeList = class;
TXMLNamedNodeMap = class;
TXMLDocument = class;
TXMLAttr = class;
TXMLElement = class;
TXMLText = class;
TXMLComment = class;
TXMLCDATASection = class;
TXMLProcessingInstruction = class;
TXMLNode = class(TInterfacedObject, IXMLNode)
protected
{$IFDEF AUTOREFCOUNT} [weak] {$ENDIF} FOwnerDocument: TXMLDocument;
FNodeType: TNodeType;
FAttributes: IXMLNamedNodeMap;
FChildNodes: IXMLNodeList;
FParentNode: IXMLNode;
FNodeValueId: TDicId;
FCachedNodeIndex: integer; // < 0 if non-cached hence unknown
procedure ClearChildNodes;
function HasAttributes: Boolean;
function GetAttributes: IXMLNamedNodeMap;
function GetChildNodes: IXMLNodeList;
function GetFirstChild: IXMLNode;
function GetLastChild: IXMLNode;
function GetNextSibling: IXMLNode;
function GetNodeName: XmlString; virtual; abstract;
function GetNodeType: TNodeType;
function GetNodeValue: XmlString; virtual;
function GetOwnerDocument: IXMLDocument; virtual;
function GetParentNode: IXMLNode;
function GetPreviousSibling: IXMLNode;
procedure SetNodeValue(const Value: XmlString); virtual;
procedure InternalWriteToStream(const OutputStream: IUnicodeStream); virtual;
procedure ReadFromStream(const Parent: TXMLNode; const InputStream: IUnicodeStream); virtual;
procedure SetParentNode(const Parent: IXMLNode);
function GetText: XmlString; virtual;
procedure SetText(const Value: XmlString); virtual;
function GetXML: XmlString;
procedure SelectNodes(Pattern: string; var Result: IXMLNodeList); overload; virtual;
procedure SelectSingleNode(Pattern: string; var Result: IXMLNode); overload; virtual;
procedure SetCachedNodeIndex(const Index: integer);
public
Dictionary: TDictionary;
property NodeName: XmlString read GetNodeName;
property NodeValue: XmlString read GetNodeValue write SetNodeValue;
property NodeType: TNodeType read GetNodeType;
property ParentNode: IXMLNode read GetParentNode;
property ChildNodes: IXMLNodeList read GetChildNodes;
property FirstChild: IXMLNode read GetFirstChild;
property LastChild: IXMLNode read GetLastChild;
property PreviousSibling: IXMLNode read GetPreviousSibling;
property NextSibling: IXMLNode read GetNextSibling;
property Attributes: IXMLNamedNodeMap read GetAttributes;
property OwnerDocument: IXMLDocument read GetOwnerDocument;
property Text: XmlString read GetText write SetText;
constructor Create(const AOwnerDocument: TXMLDocument);
destructor Destroy; override;
function InsertBefore(const NewChild, RefChild: IXMLNode): IXMLNode;
function ReplaceChild(const NewChild, OldChild: IXMLNode): IXMLNode;
function RemoveChild(const OldChild: IXMLNode): IXMLNode;
function AppendChild(const NewChild: IXMLNode): IXMLNode;
function HasChildNodes: Boolean;
function CloneNode(const Deep: Boolean): IXMLNode; virtual;
procedure WriteToStream(const OutputStream: IUnicodeStream);
function SelectNodes(Pattern: string): IXMLNodeList; overload; virtual;
function SelectSingleNode(Pattern: string): IXMLNode; overload; virtual;
property XML: XmlString read GetXML;
end;
{ TODO -omr : re-add after IXMLDocumentType will be properly supported }
(*
TXMLDocumentType = class(TXMLNode, IXMLNode)
private
function GetEntities: IXMLNamedNodeMap;
function GetName: XmlString;
function GetNotations: IXMLNamedNodeMap;
public
property Name: XmlString read GetName;
property Entities: IXMLNamedNodeMap read GetEntities;
property Notations: IXMLNamedNodeMap read GetNotations;
end;
*)
TXMLEntityReference = class(TXMLNode, IXMLEntityReference);
TXMLDocumentFragment = class(TXMLNode, IXMLDocumentFragment)
protected
function GetNodeName: XmlString; override;
procedure ReadFromStream(const Parent: TXMLNode; const InputStream: IUnicodeStream); override;
public
constructor Create(const OwnerDocument: TXMLDocument);
end;
TXMLCustomList = class(TInterfacedObject, IXMLCustomList)
private
{$IFDEF OmniXML_Generics}
FList: TList<IXMLNode>;
{$ELSE}
FList: TList;
{$ENDIF}
FChildrenCachedSiblings: boolean;
protected
function GetLength: Integer;
function GetItem(const Index: Integer): IXMLNode;
procedure Put(Index: Integer; Item: IXMLNode);
procedure MakeChildrenCacheSiblings(const Value: boolean);
public
constructor Create;
destructor Destroy; override;
property Item[const Index: Integer]: IXMLNode read GetItem; default;
property Length: Integer read GetLength;
function Add(const XMLNode: IXMLNode): Integer;
function IndexOf(const XMLNode: IXMLNode): Integer;
procedure Insert(const Index: Integer; const XMLNode: IXMLNode);
function Remove(const XMLNode: IXMLNode): Integer;
procedure Delete(const Index: Integer);
procedure Clear;
end;
TXMLNodeList = class(TXMLCustomList, IXMLNodeList)
protected
FItemNo: Integer;
public
procedure Reset;
function NextNode: IXMLNode;
function AddNode(const Arg: IXMLNode): IXMLNode;
end;
TXMLNamedNodeMap = class(TXMLCustomList, IXMLNamedNodeMap)
public
function GetNamedItem(const Name: XmlString): IXMLNode;
function SetNamedItem(const Arg: IXMLNode): IXMLNode;
function RemoveNamedItem(const Name: XmlString): IXMLNode;
end;
TXMLElement = class(TXMLNode, IXMLElement)
private
FTagNameId: TDicId;
protected
function GetNodeName: XmlString; override;
function GetTagName: XmlString;
procedure InternalWriteToStream(const OutputStream: IUnicodeStream); override;
procedure ReadFromStream(const Parent: TXMLNode; const InputStream: IUnicodeStream); override;
procedure SetTagName(const TagName: XmlString);
public
property TagName: XmlString read GetTagName;
constructor CreateElement(const OwnerDocument: TXMLDocument; const TagName: XmlString);
function GetAttribute(const Name: XmlString): XmlString;
procedure SetAttribute(const Name, Value: XmlString);
procedure RemoveAttribute(const Name: XmlString);
function GetAttributeNode(const Name: XmlString): IXMLAttr;
function SetAttributeNode(const NewAttr: IXMLAttr): IXMLAttr;
function RemoveAttributeNode(const OldAttr: IXMLAttr): IXMLAttr;
function GetElementsByTagName(const Name: XmlString): IXMLNodeList;
procedure Normalize;
// function CloneNode(const Deep: Boolean): IXMLNode; override;
end;
TXMLProcessingInstruction = class(TXMLNode, IXMLProcessingInstruction)
private
FTarget: XmlString;
FData: XmlString;
function GetData: XmlString;
function GetTarget: XmlString;
protected
function GetNodeName: XmlString; override;
procedure SetData(Data: XmlString); virtual;
procedure InternalWriteToStream(const OutputStream: IUnicodeStream); override;
procedure ReadFromStream(const Parent: TXMLNode; const InputStream: IUnicodeStream); override;
public
property Target: XmlString read GetTarget;
property Data: XmlString read GetData;
constructor CreateProcessingInstruction(const OwnerDocument: TXMLDocument; const Target, Data: XmlString);
end;
TXMLAttr = class(TXMLNode, IXMLAttr)
private
FNameId: TDicId;
FSpecified: Boolean;
function GetName: XmlString;
function GetSpecified: Boolean;
function GetValue: XmlString;
procedure SetValue(const Value: XmlString);
procedure SetName(const Value: XmlString);
protected
function GetNodeName: XmlString; override;
procedure SetNodeValue(const Value: XmlString); override;
function GetText: XmlString; override;
procedure ReadFromStream(const Parent: TXMLNode; const InputStream: IUnicodeStream); override;
procedure InternalWriteToStream(const OutputStream: IUnicodeStream); override;
public
property Name: XmlString read GetName;
property Specified: Boolean read GetSpecified;
property Value: XmlString read GetValue write SetValue;
constructor CreateAttr(const OwnerDocument: TXMLDocument; const Name: XmlString);
end;
TXMLCharacterData = class(TXMLNode, IXMLCharacterData)
private
function GetData: XmlString;
function GetLength: Integer;
protected
FNodeValue: XmlString;
procedure SetData(const Value: XmlString); virtual;
function GetNodeValue: XmlString; override;
procedure SetNodeValue(const Value: XmlString); override;
procedure InternalWriteToStream(const OutputStream: IUnicodeStream); override;
procedure ReadFromStream(const Parent: TXMLNode; const InputStream: IUnicodeStream); override;
public
property Data: XmlString read GetData write SetData;
property Length: Integer read GetLength;
constructor CreateCharacterData(const OwnerDocument: TXMLDocument; const Data: XmlString); virtual;
function SubstringData(const Offset, Count: Integer): XmlString;
procedure AppendData(const Arg: XmlString);
procedure InsertData(const Offset: Integer; const Arg: XmlString);
procedure DeleteData(const Offset, Count: Integer);
procedure ReplaceData(const Offset, Count: Integer; const Arg: XmlString);
end;
TXMLText = class(TXMLCharacterData, IXMLText)
protected
function GetNodeName: XmlString; override;
procedure ReadFromStream(const Parent: TXMLNode; const InputStream: IUnicodeStream); override;
public
constructor Create(const OwnerDocument: TXMLDocument; const Data: XmlString); overload;
function SplitText(const Offset: Integer): IXMLText;
end;
TXMLComment = class(TXMLCharacterData, IXMLComment)
protected
function GetNodeName: XmlString; override;
procedure InternalWriteToStream(const OutputStream: IUnicodeStream); override;
procedure ReadFromStream(const Parent: TXMLNode; const InputStream: IUnicodeStream); override;
public
constructor CreateComment(const OwnerDocument: TXMLDocument; const Data: XmlString); virtual;
end;
TXMLCDATASection = class(TXMLText, IXMLCDATASection)
private
procedure CheckValue(const Value: XmlString);
protected
function GetNodeName: XmlString; override;
procedure SetData(const Value: XmlString); override;
procedure SetNodeValue(const Value: XmlString); override;
procedure InternalWriteToStream(const OutputStream: IUnicodeStream); override;
procedure ReadFromStream(const Parent: TXMLNode; const InputStream: IUnicodeStream); override;
public
constructor CreateCDATASection(const OwnerDocument: TXMLDocument; const Data: XmlString); virtual;
end;
TXMLDocumentType = class(TXMLText, IXMLDocumentType)
protected
function GetNodeName: XmlString; override;
procedure InternalWriteToStream(const OutputStream: IUnicodeStream); override;
procedure ReadFromStream(const Parent: TXMLNode; const InputStream: IUnicodeStream); override;
public
constructor CreateDocumentType(const OwnerDocument: TXMLDocument; const Data: XmlString); virtual;
end;
TXMLAttrClass = class of TXMLAttr;
TXMLCDATASectionClass = class of TXMLCDATASection;
TXMLCommentClass = class of TXMLComment;
TXMLDocumentTypeClass = class of TXMLDocumentType;
TXMLElementClass = class of TXMLElement;
TXMLProcessingInstructionClass = class of TXMLProcessingInstruction;
TXMLTextClass = class of TXMLText;
TXMLDocument = class(TXMLNode, IXMLDocument)
private
FDocType: IXMLDocumentType;
FIParseError: IXMLParseError;
FParseError: TXMLParseError;
FPreserveWhiteSpace: Boolean;
FURL: string;
protected
function GetNodeName: XmlString; override;
function GetParseError: IXMLParseError;
function GetDocType: IXMLDocumentType;
{ TODO -omr : re-add after IXMLDocumentType will be properly supported }
// procedure SetDocType(const Value: IXMLDocumentType);
function GetDocumentElement: IXMLElement;
procedure SetDocumentElement(const Value: IXMLElement);
function GetPreserveWhiteSpace: Boolean;
procedure SetPreserveWhiteSpace(const Value: Boolean);
function GetText: XmlString; override;
function GetOwnerDocument: IXMLDocument; override;
protected
FXMLAttrClass: TXMLAttrClass;
FXMLCDATASectionClass: TXMLCDATASectionClass;
FXMLCommentClass: TXMLCommentClass;
FXMLDocTypeClass: TXMLDocumentTypeClass;
FXMLElementClass: TXMLElementClass;
FXMLProcessingInstructionClass: TXMLProcessingInstructionClass;
FXMLTextClass: TXMLTextClass;
// creating new childs
function InternalCreateAttribute(const Name: XmlString): TXMLAttr;
function InternalCreateCDATASection(const Data: XmlString): TXMLCDATASection;
function InternalCreateComment(const Data: XmlString): TXMLComment;
function InternalCreateDocType(const Data: XmlString): TXMLDocumentType;
function InternalCreateDocumentFragment: TXMLDocumentFragment;
function InternalCreateElement(const TagName: XmlString): TXMLElement;
function InternalCreateEntityReference(const Name: XmlString): TXMLEntityReference;
function InternalCreateProcessingInstruction(const Target, Data: XmlString): TXMLProcessingInstruction;
function InternalCreateTextNode(const Data: XmlString): TXMLText;
// reading / writing support
procedure ReadFromStream(const Parent: TXMLNode; const InputStream: IUnicodeStream); override;
procedure InternalWriteToStream(const OutputStream: IUnicodeStream); override;
public
UnclosedElementList: TInterfaceList;
property DocType: IXMLDocumentType read GetDocType;
property DocumentElement: IXMLElement read GetDocumentElement write SetDocumentElement;
property PreserveWhiteSpace: Boolean read GetPreserveWhiteSpace write SetPreserveWhiteSpace;
constructor Create; virtual;
destructor Destroy; override;
function CreateAttribute(const Name: XmlString): IXMLAttr;
function CreateCDATASection(const Data: XmlString): IXMLCDATASection;
function CreateComment(const Data: XmlString): IXMLComment;
function CreateDocType(const Data: XmlString): IXMLDocumentType;
function CreateDocumentFragment: IXMLDocumentFragment;
function CreateElement(const TagName: XmlString): IXMLElement;
function CreateEntityReference(const Name: XmlString): IXMLEntityReference;
function CreateProcessingInstruction(const Target, Data: XmlString): IXMLProcessingInstruction;
function CreateTextNode(const Data: XmlString): IXMLText;
function GetElementsByTagName(const TagName: XmlString): IXMLNodeList;
function Load(const FileName: string): Boolean; virtual;
function LoadFromStream(const Stream: TStream): Boolean;
procedure Save(const FileName: string; const OutputFormat: TOutputFormat = ofNone); virtual;
procedure SaveToStream(const OutputStream: TStream; const OutputFormat: TOutputFormat = ofNone);
function LoadXML(const XML: XmlString): Boolean; virtual;
property ParseError: IXMLParseError read GetParseError;
end;
// helper functions
function CreateXMLDoc: IXMLDocument;
// Unicode functions
function UniTrim(const Value: XmlString): XmlString;
// XML related helper functions
function CharIs_BaseChar(const ch: XmlChar): Boolean;
function CharIs_Ideographic(const ch: XmlChar): Boolean;
function CharIs_Letter(const ch: XmlChar): Boolean;
function CharIs_Extender(const ch: XmlChar): Boolean;
function CharIs_Digit(const ch: XmlChar): Boolean;
function CharIs_CombiningChar(const ch: XmlChar): Boolean;
function CharIs_WhiteSpace(const ch: XmlChar): Boolean;
function CharIs_Char(const ch: XmlChar): Boolean;
function CharIs_NameChar(const ch: XmlChar): Boolean;
function CharIs_Name(const ch: XmlChar; const IsFirstChar: Boolean): Boolean;
function EncodeText(const Value: XmlString): XmlString;
function ShrinkEol(const Value: XmlString): XmlString;
function ExpandEol(const Value: XmlString): XmlString;
implementation
uses
OmniXML_LookupTables, OmniXMLXPath;
const
MAX_OUTPUTBUFFERSIZE = 256; // initial output buffer size (it only stores one tag at once!)
OUTPUT_INDENT = 2;
type
TCharRef = record