Changeset 11279

Show
Ignore:
Timestamp:
04/17/07 21:28:24 (2 years ago)
Author:
mloskot
Message:

Backported fixes and tests for Ticket #755 to stable branch 1.4.

Files:

Legend:

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

    r10613 r11279  
    136136 
    137137############################################################################### 
     138# Read XML document with complex DOCTYPE element. 
     139 
     140def 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############################################################################### 
    138202# Cleanup 
    139203 
     
    144208    minixml_1, 
    145209    minixml_2, 
     210    minixml_3, 
    146211    minixml_cleanup ] 
    147212 
  • branches/1.4/gdal/port/cpl_minixml.cpp

    r10646 r11279  
    202202                break; 
    203203            } 
     204             
     205            /* Skip the internal DTD subset as NOT SUPPORTED YET (Ticket #755). 
     206             * The markup declaration block within a DOCTYPE tag consists of: 
     207             * - a left square bracket [ 
     208             * - a list of declarations 
     209             * - a right square bracket ] 
     210             * Example: 
     211             * <!DOCTYPE RootElement [ ...declarations... ]> 
     212             * 
     213             * We need to skip all 3 parts, until closing >  
     214             */ 
     215            if( chNext == '[' ) 
     216            { 
     217                do 
     218                { 
     219                    chNext = ReadChar( psContext ); 
     220                } 
     221                while( chNext != ']' 
     222                    && !EQUALN(psContext->pszInput+psContext->nInputOffset,"]>", 2) ); 
     223 
     224                // Skip "]" character to point to the closing ">" 
     225                chNext = ReadChar( psContext ); 
     226                chNext = ReadChar( psContext ); 
     227            } 
     228 
    204229 
    205230            if( chNext == '\"' ) 
     
    17301755 * @param psTree the document tree to write.  
    17311756 * @param pszFilename the name of the file to write to.  
     1757 * @return TRUE on success, FALSE otherwise. 
    17321758 */ 
    17331759