| | 138 | # Read XML document with complex DOCTYPE element. |
|---|
| | 139 | |
|---|
| | 140 | def minixml_3(): |
|---|
| | 141 | |
|---|
| | 142 | fp = open( 'data/doctype.xml', 'r' ) |
|---|
| | 143 | text = fp.read() |
|---|
| | 144 | tree = gdal.ParseXMLString( text ) |
|---|
| | 145 | |
|---|
| | 146 | if tree[0] != gdal.CXT_Element: |
|---|
| | 147 | gdaltest.post_reason( 'wrong node type.' ) |
|---|
| | 148 | return 'fail' |
|---|
| | 149 | |
|---|
| | 150 | # Check <chapter> element |
|---|
| | 151 | node = tree[6] |
|---|
| | 152 | |
|---|
| | 153 | if node[0] != gdal.CXT_Element: |
|---|
| | 154 | gdaltest.post_reason( 'wrong node type.' ) |
|---|
| | 155 | return 'fail' |
|---|
| | 156 | |
|---|
| | 157 | if node[1] != 'chapter': |
|---|
| | 158 | gdaltest.post_reason( 'Wrong element name' ) |
|---|
| | 159 | return 'fail' |
|---|
| | 160 | |
|---|
| | 161 | if len(node) != 7: |
|---|
| | 162 | gdaltest.post_reason( 'Wrong number of children.' ) |
|---|
| | 163 | return 'fail' |
|---|
| | 164 | |
|---|
| | 165 | # Check <chapter><title> subelement |
|---|
| | 166 | subnode = node[2] |
|---|
| | 167 | |
|---|
| | 168 | if subnode[0] != gdal.CXT_Element: |
|---|
| | 169 | gdaltest.post_reason( 'wrong node type.' ) |
|---|
| | 170 | return 'fail' |
|---|
| | 171 | |
|---|
| | 172 | if subnode[1] != 'title': |
|---|
| | 173 | gdaltest.post_reason( 'Wrong element name' ) |
|---|
| | 174 | return 'fail' |
|---|
| | 175 | |
|---|
| | 176 | if len(subnode) != 3: |
|---|
| | 177 | gdaltest.post_reason( 'Wrong number of children.' ) |
|---|
| | 178 | return 'fail' |
|---|
| | 179 | |
|---|
| | 180 | if subnode[2][1] != 'Chapter 1': |
|---|
| | 181 | gdaltest.post_reason( 'Wrong element content.' ) |
|---|
| | 182 | return 'fail' |
|---|
| | 183 | |
|---|
| | 184 | # Check fist <chapter><para> subelement |
|---|
| | 185 | subnode = node[3] |
|---|
| | 186 | |
|---|
| | 187 | if subnode[0] != gdal.CXT_Element: |
|---|
| | 188 | gdaltest.post_reason( 'wrong node type.' ) |
|---|
| | 189 | return 'fail' |
|---|
| | 190 | |
|---|
| | 191 | if subnode[1] != 'para': |
|---|
| | 192 | gdaltest.post_reason( 'Wrong element name' ) |
|---|
| | 193 | return 'fail' |
|---|
| | 194 | |
|---|
| | 195 | if len(subnode) != 3: |
|---|
| | 196 | gdaltest.post_reason( 'Wrong number of children.' ) |
|---|
| | 197 | return 'fail' |
|---|
| | 198 | |
|---|
| | 199 | return 'success' |
|---|
| | 200 | |
|---|
| | 201 | ############################################################################### |
|---|