1<?xml version="1.0" encoding="UTF-8"?>
2<!DOCTYPE script:module PUBLIC "-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "module.dtd">
3<script:module xmlns:script="http://openoffice.org/2000/script" script:name="xml_sax_XDocumentHandler" script:language="StarBasic">
4
5
6'*************************************************************************
7'
8'  Licensed to the Apache Software Foundation (ASF) under one
9'  or more contributor license agreements.  See the NOTICE file
10'  distributed with this work for additional information
11'  regarding copyright ownership.  The ASF licenses this file
12'  to you under the Apache License, Version 2.0 (the
13'  "License"); you may not use this file except in compliance
14'  with the License.  You may obtain a copy of the License at
15'
16'    http://www.apache.org/licenses/LICENSE-2.0
17'
18'  Unless required by applicable law or agreed to in writing,
19'  software distributed under the License is distributed on an
20'  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
21'  KIND, either express or implied.  See the License for the
22'  specific language governing permissions and limitations
23'  under the License.
24'
25'*************************************************************************
26
27
28
29
30
31' Be sure that all variables are dimensioned:
32option explicit
33
34'*************************************************************************
35' This Interface/Service test depends on the following GLOBAL variables,
36' which must be specified in the object creation:
37
38'     - Global vXMLData As Variant
39
40'*************************************************************************
41
42
43
44
45
46Sub RunTest()
47
48'*************************************************************************
49' INTERFACE:
50' com.sun.star.xml.sax.XDocumentHandler
51'*************************************************************************
52On Error Goto ErrHndl
53    Dim bOK As Boolean
54    Dim i As Integer
55
56    Test.StartMethod("startDocument()")
57    bOK = true
58    oObj.startDocument()
59    Test.MethodTested("startDocument()", bOK)
60    out.log("StartDocument")
61
62'  Imports the XML-data
63    For i = 0 to ubound(vXMLData)
64        Dim data As Variant
65        data = vXMLData(i)
66        If data(0) = "start" then
67            Dim oAttr As Object
68            oAttr = createUnoService("basichelper.AttributeList")
69
70            Dim upBound as Integer
71            upBound = ubound(data())
72            If upBound > 1 then
73                Dim j As Integer
74                Dim args As Variant
75                args = DimArray(upBound - 2)
76                For j = 0 to ubound(args())
77                    args(j) = data(2 + j)
78                Next j
79                oAttr.initialize(args())
80            EndIf
81
82            oObj.startElement(data(1), oAttr)
83            out.log("&lt;" + data(1) + "&gt;")
84        EndIf
85        If data(0) = "end" then
86            oObj.endElement(data(1))
87            out.log("&lt;/" + data(1) + "&gt;")
88        EndIf
89        If data(0) = "chars" then
90            oObj.characters(data(1))
91            out.log(data(1))
92        EndIf
93    Next i
94
95    out.log("EndDocument")
96    Test.StartMethod("endDocument()")
97    oObj.endDocument()
98    bOK = CheckImport()
99    Test.MethodTested("endDocument()", bOK)
100
101    Test.StartMethod("startElement()")
102    bOK = true
103    Test.MethodTested("startElement()", bOK)
104
105    Test.StartMethod("endElement()")
106    bOK = true
107    Test.MethodTested("endElement()", bOK)
108
109
110    Test.StartMethod("characters()")
111    bOK = true
112    Test.MethodTested("characters()", bOK)
113
114    Test.StartMethod("ignorableWhitespace()")
115    bOK = true
116    Test.MethodTested("ignorableWhitespace()", bOK)
117
118    Test.StartMethod("processingInstruction()")
119    bOK = true
120    Test.MethodTested("processingInstruction()", bOK)
121
122    Test.StartMethod("setDocumentLocator()")
123    bOK = true
124    Test.MethodTested("setDocumentLocator()", bOK)
125
126Exit Sub
127ErrHndl:
128    Test.Exception()
129    bOK = false
130    resume next
131End Sub
132</script:module>
133