Changeset 11277

Show
Ignore:
Timestamp:
04/17/07 20:36:48 (2 years ago)
Author:
mloskot
Message:

Added test minixml_3 with parsing of complex DOCTYPE element as a test of Ticket #755 fix.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/autotest/gcore/minixml.py

    r11065 r11277  
    127127 
    128128############################################################################### 
     129# Read XML document with complex DOCTYPE element. 
     130 
     131def 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############################################################################### 
    129193# Cleanup 
    130194 
     
    135199    minixml_1, 
    136200    minixml_2, 
     201    minixml_3, 
    137202    minixml_cleanup ] 
    138203