XML構文解析イベントの流れとしては、まずstart-documentメソッドが実行されます。ノードを読み込むとstart-elementメソッドが実行され、タグ名や属性などを取得できます。次に、start-elementメソッドが終了すると、charactersメソッドが実行され、テキストを取得できます。最後に終了タグを読み込むため、end-elementメソッドの中身が実行されます。
これらのハンドラの呼び出し方法は、以下のようにSAXパーサーを作成し、set-content-handlerを使用して、上記で作成したイベントハンドラを登録します。
{let xr:XMLReader = {SAXParser}}
{let handler:MySAXApp = {MySAXAppt}}
{xr.set-content-handler handler}
そして、SAXパーサーのparseメソッドを使用してXMLデータを解析します。
{xr.parse {InputSource system-id = XMLデータのURL}}
#start-document
#start-element
タグ = RecordSet
属性名 = <null>
属性 = <null>
#characters
要素 =
#start-element
タグ = Record
属性名 = name
属性 = AAA
#characters
要素 =
#start-element
タグ = Value
属性名 = <null>
属性 = <null>
#characters
要素 = "123"
#end-element
タグ = Value
#characters
要素 =
#start-element
タグ = Value
属性名 = <null>
属性 = <null>
#characters
要素 = "456"
#end-element
タグ = Value
#characters
要素 =
#end-element
タグ = Record
#characters
要素 =
#start-element
タグ = Record
属性名 = name
属性 = BBB
#characters
要素 =
#start-element
タグ = Value
属性名 = <null>
属性 = <null>
#characters
要素 = "xyz"
#end-element
タグ = Value
#characters
要素 =
#end-element
タグ = Record
#characters
要素 =
#end-element
タグ = RecordSet
#end-document

