This file is indexed.

/usr/share/doc/opensp/generic.htm is in opensp 1.5.2-13+b1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

   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
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML Strict//EN">
<html>
<head>
<title>The generic API to OpenSP</title>
</head>
<body>
<h1>The generic API to OpenSP</h1>
<p>
OpenSP provides a generic API in addition to its native API.  The generic
interface is much simpler than the native interface.  It is generic in
the sense that it could be easily implemented using parsers other than
OpenSP.  It provides all ESIS information as well as some other
information about the instance that is commonly needed by
applications.  However, it doesn't provide access to all information
available from OpenSP; in particular, it doesn't provide information about
the DTD.  It is also slightly less efficient than the native
interface.
<p>
The interface uses two related abstract classes.  An
<code>SGMLApplication</code> is an object that can handle a number of
different kinds of event which correspond to information in an SGML
document.  An <code>EventGenerator</code> is an object that can
generate a sequence of events of the kinds handled by an
<code>SGMLApplication</code>.  The
<code>ParserEventGeneratorKit</code> class makes an
<code>EventGenerator</code> that generates events using OpenSP.

<h2>Types</h2>
<p>
<code>SGMLApplication</code> has a number of local types that are used
in several contexts:
<dl>
<dt>
<code>Char</code>
<dd>
This typedef is an unsigned integral type that represents a single bit
combination (character).  It is <code>unsigned short</code> if
<code>SP_MULTI_BYTE</code> is defined and <code>unsigned char</code>
otherwise.
<dt>
<code>CharString</code>
<dd>
This struct represents a string of <code>Char</code>.
It has the following members:
<dl>
<dt>
<code>const Char *ptr</code>
<dd>
A pointer to the <code>Char</code>s of the string.
<dt>
<code>size_t len</code>
<dd>
The number of <code>Char</code>s in the string.
</dl>
<dt>
<code>Location</code>
<dd>
This struct holds information about a location in the entity structure
of a document.  It is constucted using an <code>OpenEntityPtr</code>
and a <code>Position</code>.  The <code>CharString</code>s in it will
remain valid as long as the <code>OpenEntity</code> that is pointed to
by the <code>OpenEntityPtr</code> that was used to construct it
remains valid.
<p>
It has the following members:
<dl>
<dt>
<code>unsigned long lineNumber</code>
<dd>
The line number.
<code>(unsigned long)-1</code> if invalid.
<dt>
<code>unsigned long columnNumber</code>
<dd>
The column number.
Note that tabs are not treated specially.
<code>(unsigned long)-1</code> if invalid.
<dt>
<code>unsigned long byteOffset</code>
<dd>
The number of bytes in the storage object preceding the location.
<code>(unsigned long)-1</code> if invalid.
<dt>
<code>unsigned long entityOffset</code>
<dd>
The number of bit combinations in the entity preceding the location.
<code>(unsigned long)-1</code> if invalid.
<dt>
<code>CharString entityName</code>
<dd>
The name of the external entity containing the location.
An empty string if invalid.
<dt>
<code>CharString filename</code>
<dd>
The name of the file containing the location.
An empty string if invalid.
<dt>
<code>const void *other</code>
<dd>
Other implementation-dependent information about the location.  In the
OpenSP implementation it will be a pointer to a StorageObjectSpec.  0 if
invalid.
</dl>
<p>
When a location is in an internal entity, the location of the reference
to the entity will be used instead.
<dt>
<code>OpenEntity</code>
<dd>
This class represents a currently open entity.  The only use for an
<code>OpenEntity</code> is, in conjunction with a
<code>Position</code>, to create a <code>Location</code>.  An
<code>OpenEntity</code> is accessed using an
<code>OpenEntityPtr</code>.
<dt>
<code>OpenEntityPtr</code>
<dd>
This class is a reference-counted pointer to an <code>OpenEntity</code>.
<dt>
<code>Position</code>
<dd>
This is an integral type that represents a position in an open entity.
The meaning of a <code>Position</code> is completely determined by the
<code>OpenEntity</code> object with which it is associated.  The only
use for an <code>Position</code> is, in conjunction with an
<code>OpenEntity</code>, to create a <code>Location</code>.
<dt>
<code>ExternalId</code>
<dd>
This struct represents an external identifier.  It has the following
members:
<dl>
<dt>
<code>bool haveSystemId</code>
<dd>
True iff the external identifier included an explicit system identifier.
<dt>
<code>CharString systemId</code>
<dd>
The system identifier included in the external identifier.
Valid only if <code>havePublicId</code> is true.
<dt>
<code>bool havePublicId</code>
<dd>
True iff the external identifier included an explicit public identifier.
<dt>
<code>CharString publicId</code>
<dd>
The public identifier included in the external identifier.
Valid only if <code>havePublicId</code> is true.
<dt>
<code>bool haveGeneratedSystemId</code>
<dd>
True iff a system identifier was generated for the external identifier.
<dt>
<dt>
<code>CharString generatedSystemId</code>
<dd>
The system identifier generated for the external identifier.
Valid only if <code>haveGeneratedSystemId</code> is true.
</dl>
<dt>
<code>Notation</code>
<dd>
This struct represents a notation.
It has the following members:
<dl>
<dt>
<code>CharString name</code>
<dd>
The name of the notation.
<dt>
<code>ExternalId externalId</code>
<dd>
The external identifier of the notation.
</dl>
<dt>
<code>Entity</code>
<dd>
This struct represents an entity.
It has the following members.
<dl>
<dt>
<code>CharString name</code>
<dd>
The name of the entity.
<dt>
<code>Entity::DataType dataType</code>
<dd>
The type of the data of the entity.
<p>
<code>Entity::DataType</code> is a local enum with the following possible
values:
<dl>
<dt>
<code>Entity::sgml</code>
<dd>
<dt>
<code>Entity::cdata</code>
<dd>
<dt>
<code>Entity::sdata</code>
<dd>
<dt>
<code>Entity::ndata</code>
<dd>
<dt>
<code>Entity::subdoc</code>
<dd>
<dt>
<code>Entity::pi</code>
<dd>
</dl>
<dt>
<code>Entity::DeclType declType</code>
<dd>
The type of the declaration of the entity.
<p>
<code>Entity::DeclType</code> is a local enum with the following possible
values:
<dl>
<dt>
<code>Entity::general</code>
<dd>
The entity is a general entity.
<dt>
<code>Entity::parameter</code>
<dd>
The entity is a parameter entity.
<dt>
<code>Entity::doctype</code>
<dd>
The entity was declared in a doctype declaration.
<dt>
<code>Entity::linktype</code>
<dd>
The entity was declared in a linktype declaration.
</dl>
<dt>
<code>bool isInternal</code>
<dd>
True iff the entity is internal rather than external.
<dt>
<code>CharString text</code>
<dd>
The replacement text of the entity.
Valid only if <code>isInternal</code> is true.
<dt>
<code>ExternalId externalId</code>
<dd>
The external identifier of the entity.
Valid only if <code>isInternal</code> is false.
<dt>
<code>const Attribute *attributes</code>
<dd>
Pointer to the data attributes of the entity.
Valid only if <code>isInternal</code> is false.
<dt>
<code>size_t nAttributes</code>
<dd>
The number of data attributes of the entity.
Valid only if <code>isInternal</code> is false.
<dt>
<code>Notation notation</code>
<dd>
The entity's notation.
An empty string if the entity has no notation.
Valid only if <code>isInternal</code> is false.
</dl>
<dt>
<code>Attribute</code>
<dd>
This struct represents an attribute.  More precisely it represents the
assignment of an attribute value to an attribute name.
It has the following members:
<dl>
<dt>
<code>CharString name</code>
<dd>
The attribute name.
<dt>
<code>Attribute::Type type</code>
<dd>
An enumeration describing the type of the attribute.
<p>
<code>Attribute::Type</code> is a local type with the following possible
values:
<dl>
<dt><code>Attribute::invalid</code>
<dd>
The attribute is invalid.
<dt><code>Attribute::implied</code>
<dd>
The attribute is an impliable attribute for which
no value was specified.
<dt><code>Attribute::cdata</code>
<dd>
The attribute is a CDATA attribute.
<dt><code>Attribute::tokenized</code>
<dd>
The attribute is a tokenized attribute.
</dl>
<dt>
<code>Attribute::Defaulted defaulted</code>
<dd>
An enumeration specifying whether the entity was defaulted, and, if
so, how.
This is non-ESIS information.
<p>
<code>Attribute::Defaulted</code> is a local enum with the following
possible values:
<dl>
<dt>
<code>Attribute::specified</code>
<dd>
The value was explicitly specified.
<dt>
<code>Attribute::definition</code>
<dd>
The value was defaulted from the attribute definition.
<dt>
<code>Attribute::current</code>
<dd>
The value was defaulted using the CURRENT value of the attribute.
</dl>
<dt>
<code>size_t nCdataChunks</code>
<dd>
The number of <code>Attribute::CdataChunk</code>s comprising the value
of the attribute.  Valid only if <code>type</code> is
<code>cdata</code>.
<dt>
<code>const Attribute::CdataChunk *cdataChunks</code>
<dd>
The <code>Attribute::CdataChunk</code>s comprising the value of this attribute.
Valid only if <code>type</code> is <code>cdata</code>.
<p>
<code>Attribute::CdataChunk</code> is a local struct with the
following members:
<dl>
<dt>
<code>bool isSdata</code>
<dd>
True iff this chunk is the replacement text of an internal SDATA entity.
<dt>
<code>CharString data</code>
<dd>
The data of this chunk.
<dt>
<code>CharString entityName</code>
<dd>
The name of the internal SDATA entity that this chunk is the
replacement text of.  Valid only if <code>isSdata</code> is true.
This is non-ESIS information.
</dl>
<dt>
<code>CharString tokens</code>
<dd>
Valid only if <code>type</code> is <code>Attribute::tokenized</code>.
<dt>
<code>bool isId</code>
<dd>
True iff the declared value is ID.
This is non-ESIS information.
<dt>
<code>size_t nEntities</code>
<dd>
The number of entities associated with this attribute.
This will be zero unless the declared value is ENTITY or ENTITIES.
<dt>
<code>const Entity *entities</code>
<dd>
The entities associated with this attribute.
<dt>
<code>Notation notation</code>
<dd>
The notation associated with this attribute.
If the declared value of the attribute is not NOTATION,
then the name member will be an empty string.
</dl>
</dl>
<h2>Events</h2>
<p>
For each event <code><var>xyz</var>Event</code> handled by
<code>SGMLApplication</code>, there is a virtual function of
<code>SGMLApplication</code> named <code><var>xyz</var></code> to
handle the event, and a local struct of <code>SGMLApplication</code>
named <code><var>Xyz</var>Event</code>.
<p>
Pointers within an event <code><var>xyz</var>Event</code> are valid
only during the call to <code><var>xyz</var></code>.  None of the
structs in events have copy constructors or assignment operators
defined.  It is up to the event handling function to make a copy of
any data that it needs to preserve after the function returns.
<p>
Except as otherwise stated,
the information in events is ESIS information.
All position information is non-ESIS information.
<p>
There are the following types of event:
<dl>
<dt>
<code>AppinfoEvent</code>
<dd>
Generated for the APPINFO section of the SGML declaration.
The event has the following members:
<dl>
<dt><code>Position pos</code>
<dd>
The position of APPINFO parameter of the SGML declaration.
<dt><code>bool none</code>
<dd>
True iff APPINFO NONE was specified.
<dt><code>CharString string</code>
<dd>
The interpreted value of the minimum literal specified
in the appinfo parameter of the SGML declaration.
Valid only if <code>none</code> is false.
</dl>
<dt>
<code>PiEvent</code>
<dd>
Generated for a processing instruction.
The event has the following members:
<dl>
<dt>
<code>Position pos</code>
<dd>
The position of the processing instruction.
<dt>
<code>CharString data</code>
<dd>
The system data of the processing instuction.
<dt>
<code>CharString entityName</code>
<dd>
If the processing instruction was the result of the
reference to a PI entity, the name of the entity.
If not, an empty string.
This is non-ESIS information.
</dl>
<dt>
<code>StartElementEvent</code>
<dd>
Generated for the start of an element.
The event has the following members:
<dl>
<dt>
<code>Position pos</code>
<dd>
The position of the start of the element.
<dt>
<code>CharString gi</code>
<dd>
The generic identifier of the element.
<dt>
<code>Element::ContentType contentType</code>
<dd>
The type of the element's content.
This is non-ESIS information.
<p>
<code>Element::ContentType</code> is an enum with the following
possible values:
<dl>
<dt>
<code>Element::empty</code>
<dd>
The element has empty content, either because it was
declared as EMPTY or because there was a #CONREF attribute.
<dt>
<code>Element::cdata</code>
<dd>
The element has CDATA content.
<dt>
<code>Element::rcdata</code>
<dd>
The element has RCDATA content.
<dt>
<code>Element::mixed</code>
<dd>
The element has mixed content.
<dt>
<code>Element::element</code>
<dd>
The element has element content.
</dl>
<dt>
<code>bool included</code>
<dd>
True iff the element was an included subelement
(rather than a proper subelement).
This is non-ESIS information.
<dt>
<code>size_t nAttributes</code>
<dd>
The number of attributes of this element.
<dt>
<code>const Attribute *attributes</code>
<dd>
A pointer to the attributes for this element.
</dl>
<dt>
<code>EndElementEvent</code>
<dd>
Generated for the end of an elemenet.
The event has the following members:
<dl>
<dt>
<code>Position pos</code>
<dd>
The position of the end of the element.
<dt>
<code>CharString gi</code>
<dd>
The generic identifier of the element.
</dl>
<dt>
<code>DataEvent</code>
<dd>
Generated for character data.
Separate data events may be generated for consecutive data characters.
Applications should make no assumptions about how character data is split
into <code>DataEvent</code>s.
The event has the following members:
<dl>
<dt>
<code>Position pos</code>
<dd>
The position of the first character of the data.
<dt>
<code>CharString data</code>
<dd>
The data.
</dl>
<dt>
<code>SdataEvent</code>
<dd>
Generated for a reference to an internal sdata entity in content.
The event has the following members:
<dl>
<dt>
<code>Position pos</code>
<dd>
The position of the entity reference.
<dt>
<code>CharString text</code>
<dd>
The replacement text of the entity.
<dt>
<code>CharString entityName</code>
<dd>
The entity name.
This is non-ESIS information.
</dl>
<dt>
<code>ExternalDataEntityRefEvent</code>
<dd>
Generated for a reference to an external data entity.
The event has the following members:
<dl>
<dt>
<code>Position pos</code>
<dd>
The position of the entity reference.
<dt>
<code>Entity entity</code>
<dd>
The referenced entity.
</dl>
<dt>
<code>SubdocEntityRefEvent</code>
<dd>
Generated for a reference to a subdoc entity.
The event has the following members:
<dl>
<dt>
<code>Position pos</code>
<dd>
The position of the entity reference.
<dt>
<code>Entity entity</code>
<dd>
The referenced entity.
</dl>
<dt>
<code>StartDtdEvent</code>
<dd>
Generated at the start of a document type declaration.
This is non-ESIS information.
The event has the following members:
<dl>
<dt>
<code>Position pos</code>
<dd>
The position of the start of the document type declaration.
<dt>
<code>CharString name</code>
<dd>
The document type name.
<dt>
<code>bool haveExternalId</code>
<dd>
The external identifier for the entity declared in the document type
declaration.
<dt>
<code>ExternalId externalId</code>
<dd>
Valid iff haveExternalId is true.
</dl>
<dt>
<code>EndDtdEvent</code>
<dd>
Generated at the end of a document type declaration.
This is non-ESIS information.
The event has the following members:
<dl>
<dt>
<code>Position pos</code>
<dd>
The position of the end of the DTD.
<dt>
<code>CharString name</code>
<dd>
</dl>
<dt>
<code>EndPrologEvent</code>
<dd>
Generated at the end of the prolog.
The event has the following members:
<dl>
<dt>
<code>Position pos</code>
<dd>
The position of the start of the instance.
</dl>
<dt>
<code>GeneralEntityEvent</code>
<dd>
Generated for each general entity in the name space of the governing
doctype, but only if the
<code>ParserEventGeneratorKit::outputGeneralEntities</code> option is
enabled.  This is non-ESIS information.  The event has the following
members:
<dl>
<dt>
<code>Entity entity</code>
<dd>
The entity.
</dl>
<p>
No event will be generated for the declaration of the
<code>#default</code> entity; instead an event will be generated when
an entity reference uses the <code>#default</code> entity if that is
the first time on which an entity with that name is used.  This means
that <code>GeneralEntityEvent</code> can occur after the end of the
prolog.
<dt>
<code>CommentDeclEvent</code>
<dd>
Generated for each comment declaration in the instance, but only if
<code>ParserEventGeneratorKit::outputCommentDecls</code> option is
enabled.  This is non-ESIS information.  The event has the following
members:
<dl>
<dt>
<code>Position pos</code>
<dd>
The position of the start of the comment declaration.
<dt>
<code>size_t nComments</code>
<dd>
The number of comments in the comment declaration.
<dt>
<code>const CharString *comments</code>
<dd>
The content of each comment in the declaration.
This excludes the com delimiters.
<dt>
<code>const CharString *seps</code>
<dd>
The separator following each comment in the declaration.
</dl>
<dt>
<code>MarkedSectionStartEvent</code>
<dd>
Generated for the start of a marked section in the instance,
but only if the <code>ParserEventGeneratorKit::outputMarkedSections</code>
option is enabled.
This is non-ESIS information.
The event has the following members:
<dl>
<dt>
<code>Position pos</code>
<dd>
The position of the start of the marked section declaration.
<dt>
<code>MarkedSectionStartEvent::Status status</code>
<dd>
The effective status of the marked section.
<p>
<code>MarkedSectionStartEvent::Status</code> is a local enum with the
following possible values:
<ul>
<li><code>MarkedSectionStartEvent::include</code>
<li><code>MarkedSectionStartEvent::rcdata</code>
<li><code>MarkedSectionStartEvent::cdata</code>
<li><code>MarkedSectionStartEvent::ignore</code>
</ul>
<dt>
<code>size_t nParams</code>
<dd>
The number of top-level parameters in the status keyword specification.
<dt>
<code>const MarkedSectionStartEvent::Param *params</code>
<dd>
The top-level parameters in the status keyword specification.
<p>
<code>Param</code> is a local struct with the following members:
<dl>
<dt>
<code>MarkedSectionStartEvent::Param::Type type</code>
<dd>
The type of top-level parameter:
<p>
<code>MarkedSectionStartEvent::Param::Type</code> is a local enum with the
following possible values:
<dl>
<dt>
<code>MarkedSectionStartEvent::Param::temp</code>
<dt>
<code>MarkedSectionStartEvent::Param::include</code>
<dt>
<code>MarkedSectionStartEvent::Param::rcdata</code>
<dt>
<code>MarkedSectionStartEvent::Param::cdata</code>
<dt>
<code>MarkedSectionStartEvent::Param::ignore</code>
<dd>
The parameter is the corresponding keyword.
<dt>
<code>MarkedSectionStartEvent::Param::entityRef</code>
<dd>
The parameter is an entity reference.
</dl>
<dt>
<code>CharString entityName</code>
<dd>
Valid when <code>type</code> is
<code>MarkedSectionStartEvent::Param::entityRef</code>.
</dl>
</dl>
<dt>
<code>MarkedSectionEndEvent</code>
<dd>
Generated for the end of a marked section in the instance, but only if
the <code>ParserEventGeneratorKit::outputMarkedSections</code> option is
enabled.  This is non-ESIS information.  The event has the following
members:
<dl>
<dt>
<code>Position pos</code>
<dd>
The position of the end of the marked section declaration.
<dt>
<code>MarkedSectionEndEvent::Status status</code>
<dd>
The effective status of the marked section.
<p>
<code>MarkedSectionEndEvent::Status</code> is a local enum with the
following possible values:
<ul>
<li><code>MarkedSectionEndEvent::include</code>
<li><code>MarkedSectionEndEvent::rcdata</code>
<li><code>MarkedSectionEndEvent::cdata</code>
<li><code>MarkedSectionEndEvent::ignore</code>
</ul>
</dl>
<dt>
<code>IgnoredCharsEvent</code>
<dd>
Generated for a sequence of characters in an ignored marked section in
the instance, but only if the
<code>ParserEventGeneratorKit::outputMarkedSections</code> option is
enabled.  This is non-ESIS information.  The event has the following
members:
<dl>
<dt>
<code>Position pos</code>
<dd>
The position of the first of the ignored characters.
<dt>
<code>CharString data</code>
<dd>
The ignored characters.
</dl>
<dt>
<code>ErrorEvent</code>
<dd>
Generated for each error detected by the parser,
and also for any other cases where the parser produces a message.
This is non-ESIS information.
It has the following members:
<dl>
<dt>
<code>Position pos</code>
<dd>
The position at which the error was detected.
<dt>
<code>ErrorEvent::Type type</code>
<dd>
The type of error.
<p>
<code>ErrorEvent::Type</code> is a local enum with the following possible
values:
<dl>
<dt>
<code>ErrorEvent::quantity</code>
<dd>
Exceeding a quantity limit.
<dt>
<code>ErrorEvent::idref</code>
<dd>
An IDREF to a non-existent ID.
<dt>
<code>ErrorEvent::capacity</code>
<dd>
Exceeding a capacity limit.
<dt>
<code>ErrorEvent::otherError</code>
<dd>
Any other kind of error.
<dt>
<code>ErrorEvent::warning</code>
<dd>
A warning.  Not actually an error.
<dt>
<code>ErrorEvent::info</code>
<dd>
An informational message.  Not actually an error.
</dl>
<dt>
<code>CharString message</code>
<dd>
The message produced by the parser.
If messages are not disabled, this will be the same as the message
printed to standard error.
</dl>
</dl>
<p>
<code>SGMLApplication</code> also has a virtual function
<pre>
void openEntityChange(const OpenEntityPtr &);
</pre>
<p>
which is similar to an event.  An application that wishes to makes use
of position information must maintain a variable of type
<code>OpenEntityPtr</code> representing the current open entity, and
must provide an implementation of the <code>openEntityChange</code>
function that updates this variable.  It can then use the value of
this variable in conjunction with a <code>Position</code> to obtain a
<code>Location</code>; this can be relatively slow.  Unlike events, an
<code>OpenEntityPtr</code> has copy constructors and assignment
operators defined.

<h2>EventGenerator</h2>
<p>
The <code>EventGenerator</code> interface provides the following
functions:
<dl>
<dt>
<code>unsigned run(SGMLApplication &<var>app</var>)</code>
<dd>
Generate the sequence of events, calling the corresponding member of
<code><var>app</var></code> for each event.  Returns the number of
errors.  This must not be called more than once for any
<code>EventGenerator</code>object.
<dt>
<code>
EventGenerator *makeSubdocEventGenerator(const SGMLApplication::Char *<var>s</var>, size_t <var>n</var>)
</code>
<dd>
Makes a new <code>EventGenerator</code> for a subdocument of the
current document.  <var>s</var> and <var>n</var> together specify the
system identifier of the subdocument entity.  These should usually be
obtained from the <code>generatedSystemId</code> member of the
<code>externalId</code> member of the <code>Entity</code> object for
the subdocument entity.  This function can only be called after
<code>run</code> has been called; the call to <code>run</code> need
not have returned, but the <code>SGMLApplication
</code>
must have been passed events from the prolog or instance (ie the SGML
declaration must have been parsed).
<dt>
<code>void inhibitMessages(bool <var>b</var>)</code>
<dd>
If <var>b</var> is true, disables error and warning messages,
otherwise enables them.  Initially errors and warnings are enabled.
This function may be called at any time, including while
<code>run()</code> is executing.
<dt>
<code>void halt()</code>
<dd>
Halt the generation of events by <code>run()</code>.
This can be at any point during the execution of <code>run()</code>.
It is safe to call this function from a different thread from that which
called <code>run()</code>.
</dl>
<h2>ParserEventGeneratorKit</h2>
<p>
The <code>ParserEventGeneratorKit</code> class is used to create an
<code>EventGenerator</code> that  generate events using OpenSP.  It
provides the following members:
<dl>
<dt>
<code>EventGenerator *makeEventGenerator(int <var>nFiles</var>, char *const *<var>files</var>)</code>
<dd>
This returns a new <code>EventGenerator</code> that will generate events
for the SGML document whose document entity is contained in the
<code><var>files</var></code>.
The returned <code>EventGenerator</code> should be deleted when it
is no longer needed.
<code>makeEventGenerator</code> may be called more than once.
<dt>
<code>void setOption(ParserEventGeneratorKit::Option <var>opt</var>)</code>
<dd>
This can be called any time before <code>makeEventGenerator()</code> is called.
<p>
<code>ParserEventGeneratorKit::Option</code> is a local enum with the following possible
values:
<dl>
<dt>
<code>ParserEventGeneratorKit::showOpenEntities</code>
<dd>
This corresponds to the <code>-e</code> option of nsgmls.
<dt>
<code>ParserEventGeneratorKit::showOpenElements</code>
<dd>
This corresponds to the <code>-g</code> option of nsgmls.
<dt>
<code>ParserEventGeneratorKit::outputCommentDecls</code>
<dd>
This will cause <code>CommentDeclEvent</code>s to be generated.
<dt>
<code>ParserEventGeneratorKit::outputMarkedSections</code>
<dd>
This will cause
<code>MarkedSectionStartEvent</code>s,
<code>MarkedSectionStartEvent</code>s
and <code>IgnoredCharsEvent</code>s
to be generated.
<dt>
<code>ParserEventGeneratorKit::outputGeneralEntities</code>
<dd>
This will cause <code>GeneralEntityEvent</code>s to be generated.
<dt>
<code>ParserEventGeneratorKit::showErrorNumbers</code>
<dd>
This corresponds to the <code>-n</code> option of nsgmls.
</dl>
<dt>
<code>
void setOption(ParserEventGeneratorKit::OptionWithArg <var>opt</var>, const char *<var>arg</var>)
</code>
<dd>
This can be called any time before <code>makeEventGenerator()</code> is called.
<p>
<code>ParserEventGeneratorKit::OptionWithArg</code> is a local enum with the following possible
values:
<dl>
<dt>
<code>ParserEventGeneratorKit::addCatalog</code>
<dd>
This corresponds to the <code>-m</code> option of nsgmls.
<dt>
<code>ParserEventGeneratorKit::includeParam</code>
<dd>
This corresponds to the <code>-i</code> option of nsgmls.
<dt>
<code>ParserEventGeneratorKit::enableWarning</code>
<dd>
This corresponds to the <code>-w</code> option of nsgmls.
<dt>
<code>ParserEventGeneratorKit::addSearchDir</code>
<dd>
This corresponds to the <code>-D</code> option of nsgmls.
</dl>
</dl>

<h2>Using the interface</h2>
<p>
Creating an application with this interface involves the following steps:
<ul>
<li>
Derive a class from <code>SGMLApplication</code>,
called, say, <code>MyApplication</code>.
<li>
For each kind of event <code><var>Foo</var>Event</code> that the application
needs information from, define a member of <code>MyApplication</code>
<code>void MyApplication::<var>foo</var>(const <var>Foo</var>Event &)</code>.
<li>
Declare an object of type <code>ParserEventGeneratorKit</code>.
<li>
Optionally set options for the <code>ParserEventGeneratorKit</code> using
<code>ParserEventGeneratorKit::setOption</code>.
<li>
Create an <code>EventGenerator</code> using
<code>ParserEventGeneratorKit::makeEventGenerator</code>.
<li>
Create an instance of <code>MyApplication</code>
(usually on the stack).
<li>
Call <code>EventGenerator::run</code> passing it a reference to
the instance of <code>MyApplication</code>.
<li>
Delete the <code>EventGenerator</code>.
</ul>
<p>
The application must include the <code>ParserEventGeneratorKit.h</code>
file (which in turn includes <code>EventGenerator.h</code> and
<code>SGMLApplication.h</code>), which is in the <code>generic</code>
directory.  If your compiler does not support the standard C++
<code>bool</code> type, you must ensure that <code>bool</code> is
defined as a typedef for <code>int</code>, before including this.  One
way to do this is to include <code>config.h</code> and then
<code>Boolean.h</code> from the <code>lib</code> subdirectory of the OpenSP
distribution.
<p>
On Unix, the application must be linked with the
<code>lib/libsp.a</code> library.

<h2>Example</h2>
<p>
Here's a simple example of an application that uses this interface.
The application prints an outline of the element structure of a
document, using indentation to represent nesting.
<pre>
// The next two lines are only to ensure bool gets defined appropriately.
#include "config.h"
#include "Boolean.h"

#include "ParserEventGeneratorKit.h"
#include &lt;iostream.h>

ostream &amp;operator<<<!>(ostream &amp;os, SGMLApplication::CharString s)
{
  for (size_t i = 0; i < s.len; i++)
    os << char(s.ptr[i]);
  return os;
}

class OutlineApplication : public SGMLApplication {
public:
  OutlineApplication() : depth_(0) { }
  void startElement(const StartElementEvent &amp;event) {
    for (unsigned i = 0; i < depth_; i++)
      cout << "    ";
    cout << event.gi << '\n';
    depth_++;
  }
  void endElement(const EndElementEvent &amp;) { depth_--; }
private:
  unsigned depth_;
};

int main(int argc, char **argv)
{
  ParserEventGeneratorKit parserKit;
  // Use all the arguments after argv[0] as filenames.
  EventGenerator *egp = parserKit.makeEventGenerator(argc - 1, argv + 1);
  OutlineApplication app;
  unsigned nErrors = egp->run(app);
  delete egp;
  return nErrors > 0;
}
</pre>
<p>
This example will only work for the non-multibyte version of OpenSP;
for the multibyte version you will need to use the standard C++ library's
facilities for wide character output, or roll your own equivalents
(like the OutputCharStream used by OpenSP applications).
<p>
There's a bigger example in the <code>osgmlnorm</code> directory in the OpenSP
distribution.
This uses the <code>SGMLApplication</code> interface, but it doesn't
use the <code>ParserEventGeneratorKit</code> interface.
</body>
</html>