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